通过完整的地址VB.NET运行程序

时间:2011-12-11 21:26:24

标签: vb.net visual-studio

我正在尝试运行一个与程序在

中不在同一目录中的.vbs脚本

Dim CustomInstalaionPath As String = "C:\Users\user\Desktop\Test"
Process.Start(CustomInstalationPath + "/run.vbs")

Dim CustomInstalaionPath As String = "C:\Users\user\Desktop\Test" Process.Start(CustomInstalationPath + "/run.vbs")

程序正在正常目录中运行以进行调试

C:\ Users \ user \ Documents \ Visual Studio 2010 \ Projects ...

我已经尝试了许多方法但没有成功运行它

任何帮助都会很棒 感谢

1 个答案:

答案 0 :(得分:2)

您需要使用ProcessStartInfo结构的the version of Process.Start

这将允许您set the WorkingDirectory property,这是您正在寻找的。

类似的东西:

Dim p As New System.Diagnostics.Process 

p.StartInfo.FileName = "cscript"
p.StartInfo.Arguments = "//B //Nologo C:\Users\user\Desktop\Test\myfile.vbs"
p.StartInfo.WorkingDirectory = "C:\Users\user\Desktop\Test"

p.Start(p.StartInfo) 

另请参阅此问题(对于使用相同类的C#)。如果您查看,请务必添加WorkingDirectory属性: