让我说我有一个shell
"chdir * && whoami.exe >> $$$"
我有这个替换命令
Dim ReplaceCommand as String = sCommand.Replace("*", UserDirect)
我也希望用用户选择的文件路径替换$$$。 我可以选择文件路径,但它永远不会将它放入shell中。
我试过了
Dim ReplaceCommand1, ReplaceCommand2 as String = sCommand.Replace("*" & "$$$", UserDirect & filepath)
Shell("cmd.exe" & ReplaceCommand1 & ReplaceCommand2)
Dim ReplaceCommand as String = sCommand.Replace("*", UserDirect) & ("$$$", filepath)
Shell("cmd.exe" & ReplaceCommand)
也
Dim ReplaceCommand1 as String = sCommand.Replace("*", UserDirect)
Dim ReplaceCommand2 as String = sCommand.Replace("$$$", filepath)
Shell("cmd.exe" & ReplaceCommand1 & ReplaceCommand2)
编辑: 当我在shell而不是&
中使用逗号时,获得一条错误路径Dim ReplaceCommand1 as String = sCommand.Replace("*", UserDirect)
Dim ReplaceCommand2 as String = sCommand.Replace("$$$", filepath)
Shell("cmd.exe", ReplaceCommand1 , ReplaceCommand2)
答案 0 :(得分:0)
您的部分示例未编译语法错误的原因。
你没有像你想的那样使用Shell()。
Public Function Shell(
PathName As String,
Optional Style As Microsoft.VisualBasic.AppWinStyle = MinimizedFocus,
Optional Wait As Boolean = False,
Optional Timeout As Integer = -1
) As Integer
从您给出的示例中,看起来您只是把东西放在一起。停下来思考一下:)
答案 1 :(得分:0)
您可以将替换链接在一起:
Dim ReplaceCommand1 as String = sCommand.Replace("*", UserDirect).Replace("$$$", filepath)
Shell("cmd.exe" & ReplaceCommand1)