Click here to Skip to main content
Rate this: bad
good
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 at 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 at 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
0 OriginalGriff 300
1 Maciej Los 180
2 Richard MacCutchan 115
3 arvind mepani 104
4 Tino Fourie 92


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