views:

567

answers:

4

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?

A: 

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.

Josh Kodroff
this is no answer but a workaround. That's why nobody up voted this answer I guess. I would suggest accepting the other example which does show how to invoke an application on a UNC path.
Davy Landman
+6  A: 

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.

Steven Murawski
this was exactly the trick i needed; thanks!
David Alpert
Glad to have helped!
Steven Murawski
+3  A: 

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.

Orihara
That would work in PowerShell too. There are added benefits to using the Process object.
Steven Murawski
+1  A: 

use %~dp0 in a batchfile 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)