【问题标题】:How to open command prompt in specific directory with VB.Net如何使用 VB.Net 在特定目录中打开命令提示符
【发布时间】:2018-07-14 17:02:55
【问题描述】:

我需要以编程方式打开命令提示符,但在特定目录中打开它。

在 Notepad++ 中,有一个选项可以在命令提示符下打开文件的目录。

Here is what it looks like in Notepad++.

你会怎么做?

【问题讨论】:

  • 有一个叫做谷歌的东西会寻找这样的非问题的答案。把它想象成一个研究助理。当我在 Google 上搜索您的标题时,仅在这个网站上,我就获得了 110 万次点击,其中 53,000 次。
  • 真的,我从来没有听说过...
  • ...我已经用谷歌搜索了这个确切的问题,但一无所获。如果我认为可以通过 Google 找到答案,我不会发布问题。
  • google.com/search?q=Open+cmd+in+specific+directory -- 第二个结果,第二个答案。
  • 非常感谢VV

标签: vb.net command-line notepad++ command-prompt


【解决方案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()

问候,保罗

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-09-05
    • 2021-10-06
    • 2011-07-29
    • 1970-01-01
    • 2022-08-22
    • 2020-01-16
    • 2011-03-27
    • 1970-01-01
    相关资源
    最近更新 更多