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?

Josh Kodroff
  • 27,301
  • 27
  • 95
  • 148
  • 1
    Could you clarify what exactly you mean by "can't get it to work"? It doesn't start, it's unable to parse its command line, it runs over your dog, etc, etc? The current description is much too vague. – Mihai Limbășan Nov 19 '08 at 16:01

4 Answers4

7

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
  • 10,959
  • 41
  • 53
3

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
  • 309
  • 2
  • 6
  • That would work in PowerShell too. There are added benefits to using the Process object. – Steven Murawski Nov 20 '08 at 18:55
  • You will want to begin that line with an Ampersand (&) to get Powershell to switch into command mode before it attempts to parse the quoted string. & "\\quoted\path\to execute.exe" For more on running non-Powershell commands in Powershell, see the gotcha posted here: http://stackoverflow.com/questions/803521/powershell-pitfalls/7028380#7028380 – Nathan Hartley Sep 01 '11 at 13:29
1

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)
H. Pauwelyn
  • 13,575
  • 26
  • 81
  • 144
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.

Josh Kodroff
  • 27,301
  • 27
  • 95
  • 148
  • 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 May 06 '09 at 14:51