Click here to Skip to main content
Rate this: bad
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;
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?
Posted 10-Sep-12 0:16am
Rate this: bad
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)
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
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"

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

Advertise | Privacy | Mobile
Web04 | 2.8.140926.1 | Last Updated 10 Sep 2012
Copyright © CodeProject, 1999-2014
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