How do you start a program stored on a UNC share from the command line with parameters?
-
08-07-2019 - |
Question
There's an in-house program we use and it's stored on a UNC share so that updates are transparent. I'd like to supply it some command line parameters like so:
\\server\share\in_house_thingy.exe myusername mypassword
But I can't seem to get it to work in either CMD or PowerShell or via a shortcut.
Anyone got any ideas?
Solution
For a shortcut, change the target to be like:
"\\server\share\in_house_thingy.exe" myusername mypassword
unless you really do want to have to use powershell to make this work.
OTHER TIPS
You could use:
$app = '\\server\share\in_house_thingy.exe'
$arguments = 'myusername mypassword'
$process = [System.Diagnostics.Process]::Start($app, $arguments)
The $process object will give you a live process object if you want to get an exit code or other information from that process.
use %~dp0
in a batch file for the current (unc) path including the trailing \
in a powershell script use this for the current (unc) path without trailing \
$0 = $myInvocation.MyCommand.Definition
$dp0 = [System.IO.Path]::GetDirectoryName($0)
I just noticed that there's a .CMD file that's copying the file from the share to the temp directory and running it locally.
If y'all could just vote this answer up if there's no better solution, that'll work.