![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) | ||||||||||||
| Guest | Re: cannot execute program in dir with space and argument Try this way: $CMD = "D:\Utilities\Password Updater\PasswordUpdaterCmd.exe" & $CMD /cf:servers.txt ----- Shay Levi $cript Fanatic http://scriptolog.blogspot.com
| ||||||||||||
| | #2 (permalink) |
| Guest | Re: cannot execute program in dir with space and argument Try replacing '&' with 'invoke-expression' Brandon Shell --------------- Blog: http://www.bsonposh.com/ PSH Scripts Project: www.codeplex.com/psobject f> Hi, f> f> I am trying to execute a program which resides in a directory with f> spaces in the path and a needed argument. Here is the script: f> f> $CMD = "'D:\Utilities\Password Updater\PasswordUpdaterCmd.exe' f> /cf:servers.txt" f> "command is: $CMD" f> & $CMD f> I have verified that when I manually run the exact command as the f> output from this script it works but when I actually run the script, f> I get this error: f> f> command is: 'D:\Utilities\Password Updater\PasswordUpdaterCmd.exe' f> /cf:servers.txt f> The term ''D:\Utilities\Password Updater\PasswordUpdaterCmd.exe' f> /cf:servers.txt' is not recognized as a cmdlet, function, operable f> program, f> or script file. Verify the term and try again. f> At D:\Utilities\Password Updater\test.ps1:5 char:2 f> + & <<<< $CMD f> [D:\Utilities\Password Updater]: f> Any help is appreciated, f> f> Thanks, f> |
| | #3 (permalink) | ||||||||||||||||||||||||||||||||||||
| Guest | Re: cannot execute program in dir with space and argument Try this & "`"D:\Utilities\Password Updater\PasswordUpdaterCmd.exe`" /cf:servers.txt" Brandon Shell --------------- Blog: http://www.bsonposh.com/ PSH Scripts Project: www.codeplex.com/psobject f> That does work but why couldn't I build that into the command? f> f> Thanks, f> f> "Shay Levi" wrote: f>
| ||||||||||||||||||||||||||||||||||||
| | #4 (permalink) | ||||||||||||||||||||||||||||||||||||
| Guest | Re: cannot execute program in dir with space and argument Because it is interpreted as one long string and obviously there is no such exe file. If you want to execute the command with its switches embeded in a string then use invoke-expression as Brandon suggested. ----- Shay Levi $cript Fanatic http://scriptolog.blogspot.com
| ||||||||||||||||||||||||||||||||||||
| |
| |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Execute error: Type Mismatch: 'Execute' | kellym-global.co.uk | VB Script | 2 | 2 Weeks Ago 10:09 AM |
| Execute application's exe and perform changes in Program Files - V | Abhi | Vista General | 2 | 01-31-2008 07:01 PM |
| Pls doc how to execute an app that has embbedded space in its path | Bob Landau | PowerShell | 1 | 08-18-2007 07:51 PM |
| Unable to download and save or execute program from Internet | FrancisP | Vista security | 6 | 03-26-2007 01:56 PM |
| Unable to download and save or execute a program from Internet | FrancisP | Vista security | 0 | 06-20-2006 07:56 AM |