通过完整的地址VB.NET

问题描述:

我努力的方案是在通过完整的地址VB.NET

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

程序在正常的目录中运行运行.vbs脚本,是不是在同一个目录下运行的程序对于去窃听

C:\用户\用户\文档\ Visual Studio 2010的\项目...

我已经试过的方法,但没有加载成功运行它

任何帮助将是真棒 感谢

+0

什么是“不工作”是什么意思?例外?消息框?主板着火了? –

+0

对不起汉斯,现在编辑 – reblerebel

+0

它没关系,它在一个不同的目录中。你遇到了什么错误?另外,在连接字符串时,应该使用&,而不是+。 – UnhandledExcepSean

您需要使用the version of Process.Start,需要一个ProcessStartInfo结构。

这将允许你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属性:

+0

它是用VB.NET编写的,但我找到了一种方法来做到这一点 – reblerebel

+0

@reblerebel:我在这里提供的VB.Net代码没有解决你的问题吗?如果此代码帮助您,请确保接受答案。 –

+0

昏暗ProcessProperties作为新的ProcessStartInfo ProcessProperties.FileName = “记事本” ProcessProperties.Arguments = “blaaa.txt” ProcessProperties.WorkingDirectory = “C:/” ProcessProperties.WindowStyle = ProcessWindowStyle.Maximized 昏暗MyProcess作为过程=过程。启动(ProcessProperties),我使用的是 – reblerebel