Click here to Skip to main content
12,303,940 members (71,319 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# VBScript Process
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.

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 10-Sep-12 0:16am
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Hi MitchG92_24, this displays the first argument text along with a message in a message box


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
Option Explicit
Wscript.Echo "Hello World!" + WScript.Arguments(0)
  Permalink  
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!
Carl Randall 11-Sep-12 7:24am
   
Glad it works for you :)
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

If you are passing any file/folder path as your arguments, then enclose the arguments inside double quotes, like "C:\Program Files\SomeFilePath.ext"
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160530.1 | Last Updated 10 Sep 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100