【问题标题】:Shell Command Gives Error "error after : and."Shell 命令给出错误“错误之后:和。”
【发布时间】:2011-11-28 14:44:58
【问题描述】:

我用过:

Shell("cmd /k type " & System.IO.Path.GetTempPath & "file.exe > " & Application.ExecutablePath & ":file.exe")

临时文件夹:C:\Documents and Settings\Admin\Local Settings\Temp\

命令提示窗口给出错误:找不到文件,之后出现错误:and。系统找不到目标路径。

我认为问题出在这个名字上:Documents and Settings

我应该怎么做才能让它栩栩如生?

P.S:文件存在,当我使用:start 命令时它可以工作。

【问题讨论】:

    标签: vb.net visual-studio-2008 shell cmd command-prompt


    【解决方案1】:

    您需要额外的引号。

    Shell("cmd /k type """ & System.IO.Path.GetTempPath & "file.exe"" > " & Application.ExecutablePath & ":file.exe")
    

    空格是命令行参数中的分隔符。如果单个参数中有空格,则需要将整个参数括在引号中。

    【讨论】:

      【解决方案2】:

      您可能需要将路径放在“”之间。像

      Shell("cmd /k type \"" & System.IO.Path.GetTempPath & "file.exe\" > " & Application.ExecutablePath & ":file.exe")
      

      【讨论】:

      • 谢谢,但在 Vb 中是 "" 而不是 \"
      猜你喜欢
      • 2016-12-10
      • 1970-01-01
      • 2019-09-08
      • 2016-04-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-01
      相关资源
      最近更新 更多