How to run a script when the path of the program contains a space
i searched "space in path" both here , in google , found lots of information none of suggestions seem work.
following script runs start\run command prompt, demo.exe program(a c# program) throws system.io.exception: handle invalid.
i think because exe argument, contains space, not enclosed in double quotes. how done? tried using 2 sets of double quotes , 3 sets did not work either. if path not contain space, no exception , demo.exe program displays in console window. however, if run same script inside powershell console, io exception. separate issue, have been reading, way path must handled varies on how script executed.
$exe=& "c:\development test\demo.exe"
#the following works because has no spaces
#$exe="c:\development\demo.exe"
$cmd="${exe}"
invoke-expression $cmd
works me when use:
$exe = "& 'c:\development test\demo.exe'"
richard mueller - mvp directory services
Windows Server > Windows PowerShell
Comments
Post a Comment