0

我希望我的程序打开 cmd ,更改目录,然后执行命令:“copy /B file1 file2 output”

这就是我目前所拥有的。但所发生的只是一个 cmd 窗口闪烁一秒钟,但没有创建文件

Dim cmd1 As String
Dim cmd2 As String
    cmd1 = "cd " & FolderFromFileName(imagename)
    cmd2 = "copy /B " & NameOnlyFromFullPath(imagename) & "+" & "TEMP.txt" & " " & TextBox1.Text
    Shell("cmd /c" & " " & cmd1 & " " & cmd2, AppWinStyle.NormalFocus)

请帮忙,谢谢:)

4

1 回答 1

0

你真的需要出现命令提示符吗?您可以通过使用 system.io 库来完成所有这些操作,而无需单独的进程。如果你真的需要 cmd 提示符,你可以创建一个进程。

Dim NewProcess = New Process
' a new process is created 
NewProcess.StartInfo.UseShellExecute = False
' redirect IO
' PVWCmd.StartInfo.RedirectStandardOutput = True
'       PVWCmd.StartInfo.RedirectStandardError = True
'      PVWCmd.StartInfo.RedirectStandardInput = True
' don't even bring up the console window
NewProcess.StartInfo.CreateNoWindow = False
' executable command line info
NewProcess.StartInfo.FileName = "cmd"

NewProcess.StartInfo.WorkingDirectory = "C:\"
'        NewProcess.StartInfo.Arguments = +" > """ + "LogFile.log" + """ 2>&1"

NewProcess.Start()
于 2013-02-06T17:37:05.733 回答