New-Shortcut but it's for a JAR file at a remote URL

What it says on the tin…I have to use local javaws.exe to launch a remote .jnlp.

New-Shortcut -Path "$envCommonStartMenu\A_Folder\ThisApp.lnk" -TargetPath "C:\Program Files (x86)\Java\jre8\bin\javaws.exe https:\\somesite.com\app.jnlp" -IconLocation "C:\stuff\icon.ico" -IconIndex 0 -Description 'App'

This fails always cannot create link. It works if I leave off the url, just drops a shortcut to javaws.

I’ve tried

"'C:\program Files (x86)\path\javaws.exe' https:\\somesite.com\app.jnlp"

and lots of other iterations, but it doesn’t like the URL. I have another link that looks like “microsoft-edge:https:\somesite.com” and this works fine. I tried “explorer:https\url” and “javaws:” and “javaws.exe” and no joy. It makes the shortcut but requests the application.

Any help or am I trying to do a thing in a dumb way?

Any help for a nub?

TIP: Sometimes you need to look at the source instead of the manual.
If you look in \AppDeployToolkit\AppDeployToolkitMain.ps1 for the definition of the New-Shortcut function, it starts with this:

#region Function New-Shortcut
Function New-Shortcut {
<#
.SYNOPSIS
	Creates a new .lnk or .url type shortcut
.DESCRIPTION
	Creates a new shortcut .lnk or .url file, with configurable options
.PARAMETER Path
	Path to save the shortcut
.PARAMETER TargetPath
	Target path or URL that the shortcut launches
.PARAMETER Arguments
	Arguments to be passed to the target path
.PARAMETER IconLocation
	Location of the icon used for the shortcut
.PARAMETER IconIndex
	The index of the icon. Executables, DLLs, ICO files with multiple icons need the icon index to be specified. This parameter is an Integer. The first index is 0.
.PARAMETER Description
	Description of the shortcut
.PARAMETER WorkingDirectory
	Working Directory to be used for the target path
.PARAMETER WindowStyle
	Windows style of the application. Options: Normal, Maximized, Minimized. Default is: Normal.
.PARAMETER RunAsAdmin
	Set shortcut to run program as administrator. This option will prompt user to elevate when executing shortcut.
.PARAMETER Hotkey
	Create a Hotkey to launch the shortcut, e.g. "CTRL+SHIFT+F"
.PARAMETER ContinueOnError
	Continue if an error is encountered. Default is: $true.
.EXAMPLE
	New-Shortcut -Path "$envProgramData\Microsoft\Windows\Start Menu\My Shortcut.lnk" -TargetPath "$envWinDir\system32\notepad.exe" -IconLocation "$envWinDir\system32\notepad.exe" -Description 'Notepad' -WorkingDirectory "$envHomeDrive\$envHomePath"
.NOTES
	Url shortcuts only support TargetPath, IconLocation and IconIndex. Other parameters are ignored.
.LINK
	http://psappdeploytoolkit.com
#>

Notice there is a -Arguments parameter.

So try this:

New-Shortcut -Path "$envCommonStartMenu\A_Folder\ThisApp.lnk" -TargetPath "C:\Program Files (x86)\Java\jre8\bin\javaws.exe" -Arguments "https:\\somesite.com\app.jnlp" -IconLocation "C:\stuff\icon.ico" -IconIndex 0 -Description 'App'
1 Like

Welp. As always I feel dumb. Thanks so much!!!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.