我需要以编程方式打开命令提示符,但在特定目录中打开它。
在Notepad ++中,有一个选项可以在命令提示符下打开文件的目录。
Here is what it looks like in Notepad++.
你会怎么做?
答案 0 :(得分:1)
你需要这样的东西:
Const WorkingDirectory As String = "E:\Shared" ' the directory you want to be on
Dim exePath As String = Environment.SystemDirectory & "\cmd.exe"
Dim StartInfo As New ProcessStartInfo(exePath)
Dim cmdSession As New Process
StartInfo.UseShellExecute = False
StartInfo.WorkingDirectory = WorkingDirectory ' start in this directory
StartInfo.Arguments = "/k" ' let cmd.exe remain running using /k
cmdSession.StartInfo = StartInfo
cmdSession.Start()
问候,保罗