

Note the need to `-escape the embedded double quotes.Īlternatively, with fixed strings such as the one at hand, you could use '.' (single quotes) as the outer quotes, in which case you needn't escape embedded double quotes.Ĭonversely, consider use of $env:ProgramFiles and specifying the username via a variable, in which case you do need "." for the outer quoting to ensure that string expansion (interpolation) is performed. See the WshShortcut documentation for an overview of all available properties. "/user:capeplc\a-bhargate /savecreds `"C:\Program Files\Internet Explorer\iexplore.exe`"" #` (dummy comment to fix broken syntax highlighting) $WScriptShell = New-Object -ComObject 'WScript.Shell' Any help would be great!Īs gpunktschmitz points out in a comment on the question, you must:Īnd assign the rest of the command line to the. Copy-Item sourcepath destination Get the lnk we want to use as a template shell New-Object -COM WScript.Shell shortcut shell. The script outcome is fine, just need the shortcuts target changing to the one mentioned above in bold. $Shortcut = $WScriptShell.CreateShortcut($ShortcutFile) $ShortcutFile = "$env:USERPROFILE\desktop\IEadmin.lnk" $TargetFile = "C:\Program Files\Internet Explorer\iexplore.exe"

This is the script I've currently got I just want it to add it to the end or something to change the target of the shortcut: #. I've got it to create a shortcut on the users desktop but I want the script to change the target of it from: "C:\Program Files\Internet Explorer\iexplore.exe" to runas.exe /user:capeplc\a-bhargate /savecreds "C:\Program Files\Internet Explorer\iexplore.exe" However, the only drawback is that the web version only works on a admin run internet explorer process. The Script works fine and installs Java 6.21 and both Crosslink Components and also installs through DISM. \lnkping 1.1.1.1 - invocation immediately returns, new conhost window is open and output is displayed there.I've got a script that installs a certain BP Program called iLink (Crosslink). Open powershell.exe, cd to shortcut directory, run. \lnkping.lnk 1.1.1.1, output is inline as normal. Open cmd.exe, cd to shortcut directory, run. lnk shortcut to a native command, for example to C:/Windows/System32/PING.EXE, with a different name, so you can run it (so, maybe D:/shortcuts/lnkping.lnk). Is it possible to make the linked commands behave as normal console program executables do?Ĭreate a. When I do the same from Powershell (it does not matter if it is the old powershell.exe or new pwsh.exe), there is no stdout output, and a new conhost window with the output appears instead. When I run ffplay from cmd, it works as expected, outputs usage help to my terminal and exits. As a result, I can just type ffplay in my shell, and Windows automatically finds the D:/shortcuts/ffplay.lnk file and runs the ffplay.exe executable it points to. The shortcut folder is added to PATH, and my PATHEXT contains the ".lnk" extension. lnk shortcuts to CLI apps in different folders.
