How to run a program stored on a UNC resource from the command line with parameters?

There is an internal program that we use here, and it is stored on a UNC share so that updates are transparent. I would like to provide it with some command line options:

\\server\share\in_house_thingy.exe myusername mypassword 

But I can not get it to work in CMD or PowerShell or through a shortcut.

Does anyone have any ideas?

+4
source share
4 answers

For the shortcut, change the target as:

 "\\server\share\in_house_thingy.exe" myusername mypassword 

unless you really want to use powershell to do the job.

+3
source

You can use:

 $app = '\\server\share\in_house_thingy.exe' $arguments = 'myusername mypassword' $process = [System.Diagnostics.Process]::Start($app, $arguments) 

The $ process object will give you an actual process object if you want to get the exit code or other information from this process.

+6
source

use %~dp0 in the batch file for the current (unc) path, including the final \

in powershell script use this for current (unc) path without binding \

 $0 = $myInvocation.MyCommand.Definition $dp0 = [System.IO.Path]::GetDirectoryName($0) 
+1
source

I just noticed that there is a .CMD file that copies the file from the share to the temp directory and runs it locally.

If you could just vote for this answer, if there is no better solution, this will work.

0
source

All Articles