开发者

how to call a VScript file (.vscript file extension) in C# Windows application

开发者 https://www.devze.com 2023-02-15 06:59 出处:网络
I need to call a VScript file (.vscript file extension) in my C# Windows application. Ho开发者_开发问答w can I do this? I don\'t know what a .vscript file is, but if you would normally run it by doubl

I need to call a VScript file (.vscript file extension) in my C# Windows application. Ho开发者_开发问答w can I do this?


I don't know what a .vscript file is, but if you would normally run it by double-clicking it, you can simply do:

  var process = System.Diagnostics.Process.Start("myscript.vscript");
  process.WaitForExit();  // if you want to wait, otherwise, leave this out


Do you mean .vbs? That is a Visual Basic Script file.
Anyway, to call it you might want to use the following lines. This method is also fool-proof. Some people might have assigned .vbs to a different program.

System.Diagnostics.Process.Start("wscript.exe \"" + filepath + "\"").WaitForExit();

If you also want a console, I think it is csript.exe instead of wscript.exe.

Anyways, whether your file is really .vscript or not, wcript.exe and cscript.exe will run it.

0

精彩评论

暂无评论...
验证码 换一张
取 消