Click here to Skip to main content
15,901,373 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I've had a browse on the web but for the answer to this but everything i try doesn't seem to work.

C#
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.Arguments = argument;
proc.StartInfo.FileName = link;
proc.Start();


This throws up an error saying "There is no file extension in "C:\Program""
I've checked that the file used in the variable argument exists and the link is wscript.exe.

Any ideas?

Thanks!
Posted

If you are passing any file/folder path as your arguments, then enclose the arguments inside double quotes, like "C:\Program Files\SomeFilePath.ext"
 
Share this answer
 
Hi MitchG92_24, this displays the first argument text along with a message in a message box


C#
var link = "C:\\MyVbScript.vbs";
string strArgs =  "\"" + "myArg1" + "\" \"" + "myArg2" + "\""; 
var process = System.Diagnostics.Process.Start(link,strArgs);
process.WaitForExit();  // if you want to wait, otherwise, leave this out



Also my .vbs file in C:\\MyVbScript.vbs
VB
Option Explicit
Wscript.Echo "Hello World!" + WScript.Arguments(0)
 
Share this answer
 
v2
Comments
MitchG92_24 11-Sep-12 4:35am    
Thanks Carl! i was under the impression i had to run wscript.exe with my vbs file as an argument but alot clearer your way thanks!
AssemblySoft 11-Sep-12 7:24am    
Glad it works for you :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900