Powershell script to create shortcut to vision application?

I have a customer with many client computers that wants to automate the installation process. Using powershell and this link - Launchers and Workstation | Ignition User Manual

I was able to download and silently install vision client launcher fine. This works fine but the last step I cannot find in this documentation and hopefully is possible is for the vision client launcher to manually add a gateway, add an application from the gateway and create a shortcut for that application. Is this doable?

1 Like

You would have to write a json config file with the gateway & application information to the user's home directory. Then write a shortcut link on the desktop that calls the launcher with that app name as a parameter. I would expect PowerShell to easily handle those tasks.

1 Like

I'd probably create those on one machine, then copy those into the installation procedure.

1 Like

Thanks, I did find this post helpful How to Deploy Vision Client Launcher - #7 by Jonathan

I found the right JSON file from a existing machine . Now am just working on the shortcut aspect.

I'll note that what you're trying to do is going to be made a lot easier in 8.3, and as far as I know the new launchers for 8.3 will be backwards compatible with (most) older 8.1 gateways.

2 Likes

I tried my best but the shortcut is not working. A few things I noted - in a manually made shortcut I see the target as the C:\...\visionclientlauncher.exe -Dapplication=app and the Start In ($shortcut.WorkingDirectory) is filled in but whne I Try to do that it makes the shortcut not do anything. Here was the closest I Think I got - but it just opens up the vision client launcher. I don't believe my "configuring vsc" part right after the vision client launcher install does anything.

# Constants
$ip="192.168.1.100"
$downloadAddress="http://$ip/system/nativelaunch?type=vision&os=windows"

# Copy json launcher file
# Putting it in clientlauncher-data bricked my whole launcher
#$localConfigFolder= [System.IO.Path]::Combine([System.Environment]::GetFolderPath("UserProfile"),".ignition","clientlauncher-data")
#$localJsonConfig = [System.IO.Path]::Combine($localConfigFolder, "vision-client-launcher.json")
$localConfigFolder="C:\app"
$localJsonConfig=[System.IO.Path]::Combine($localConfigFolder,"app.json")
$networkJsonConfig = "Z:\app.json"

if (-not (Test-Path $localConfigFolder)) {
    New-Item -ItemType Directory -Path $localConfigFolder
}

Copy-Item -Path $networkJsonConfig -Destination $localJsonConfig -Force

# Get the current user's Downloads folder
$downloadPath = [System.IO.Path]::Combine([System.Environment]::GetFolderPath("UserProfile"), "Downloads", "downloadedFile.exe")


# Path to single user executable
$workingDir = [System.IO.Path]::Combine([System.Environment]::GetFolderPath("UserProfile"),"AppData","Roaming","Inductive Automation", "Vision Client Launcher")
$singleUserExe = [System.IO.Path]::Combine($workingDir,"visionclientlauncher.exe")


# Download and install launcher if needed
if (-not (Test-Path $singleUserExe)) {
    Write-Output "Downloading Vision client launcher..."
    # Download the file
    Invoke-WebRequest -Uri $downloadAddress -OutFile $downloadPath
    Write-Output "Installing Vision Client Launcher..."
    $arguments = "/CURRENTUSER /VERYSILENT"
    Start-Process -FilePath $downloadPath -ArgumentList $arguments -NoNewWindow -Wait
    Write-Output "Configuring vsc"
    Start-Process -FilePath $singleUserExe -ArgumentList "config.json=$jsonConfig" -NoNewWindow -Wait
}

# Make shortuct
$shortcutPath = [System.IO.Path]::Combine([System.Environment]::GetFolderPath("Desktop"), "App.lnk")
$WScriptShell = New-Object -ComObject WScript.Shell
$shortcut = $WScriptShell.CreateShortcut($shortcutPath)
$shortcut.TargetPath = $singleUserExe
# Though a manual made shortcut that works has the workingdirectory filled out, if I do it, it bricks the shorcut
#$shortcut.WorkingDirectory=$workingDir
$shortcut.Arguments="config.json=$localJsonConfig"
$shortcut.Save()

Write-Output "Process Complete"

Can someone help me with this?

Just re-read this and I got it thanks. I did need to modify the C:\Users\...\vision-client-launcher.json and then use -Dapplication=app as my argument for in my target and it worked fine along with the right working directory.

What was confusing me was when I made a connection on the gateway just to see how things were supposed to be done I was exporting this -
image

Getting json and referring to that and it was doing nothing, but that's not the JSON I needed. The one I needed was from Vision client launcher - settings -
image

Export Launcher Config (after making the connection to the gateway/project)

1 Like