VB编程中调用CMD命令处理出现的问题
本人初学者,想用VB实现copy/bX:\*.jpg+X:\*.RARX:\*.JPG这个命令。我首先通过Commondialog.FileName获取了两个文件的路径,...
本人初学者,想用VB实现 copy /b X:\*.jpg+X:\*.RAR X:\*.JPG 这个命令。我首先通过Commondialog. FileName 获取了两个文件的路径,之后调用CMD,加入路径参数来,调试说p1不是内部或外部命令...这是哪里出问题了?代码如下,请各位指教,谢谢
Private Sub Command1_Click()
Dim p1 As String
CommonDialog1.ShowOpen '打开文件
p1$ = CommonDialog1.FileName '取路径
Text1 = p1
End Sub
Private Sub Command2_Click()
Dim p2 As String
CommonDialog2.ShowOpen '打开文件
p2$ = CommonDialog2.FileName '取路径
Text2 = p2
End Sub
Private Sub Command3_Click()
Shell "cmd.exe /k p1 + p2 p1", vbNormalFocus '问题应该在这里
End Sub 展开
Private Sub Command1_Click()
Dim p1 As String
CommonDialog1.ShowOpen '打开文件
p1$ = CommonDialog1.FileName '取路径
Text1 = p1
End Sub
Private Sub Command2_Click()
Dim p2 As String
CommonDialog2.ShowOpen '打开文件
p2$ = CommonDialog2.FileName '取路径
Text2 = p2
End Sub
Private Sub Command3_Click()
Shell "cmd.exe /k p1 + p2 p1", vbNormalFocus '问题应该在这里
End Sub 展开
展开全部
Private Sub Command1_Click()
Dim p1 As String
CommonDialog1.ShowOpen '打开文件
p1 = CommonDialog1.FileName '取路径
Text1 = p1
End Sub
Private Sub Command2_Click()
Dim p2 As String
CommonDialog2.ShowOpen '打开文件
p2 = CommonDialog2.FileName '取路径
Text2 = p2
End Sub
Private Sub Command3_Click()
Dim shellcode As String
shellcode = "copy " & Text1 & "+" & Text2 & " " & Text1
Open App.Path & "\temp.bat" For Output As #1
Print #1, shellcode
Print #1, "del temp.bat"
Close #1
Shell "temp.bat"
End Sub
请复制这段代码,不要自己输入,因为差一个空格就会出错
可以用文本文件测试
Dim p1 As String
CommonDialog1.ShowOpen '打开文件
p1 = CommonDialog1.FileName '取路径
Text1 = p1
End Sub
Private Sub Command2_Click()
Dim p2 As String
CommonDialog2.ShowOpen '打开文件
p2 = CommonDialog2.FileName '取路径
Text2 = p2
End Sub
Private Sub Command3_Click()
Dim shellcode As String
shellcode = "copy " & Text1 & "+" & Text2 & " " & Text1
Open App.Path & "\temp.bat" For Output As #1
Print #1, shellcode
Print #1, "del temp.bat"
Close #1
Shell "temp.bat"
End Sub
请复制这段代码,不要自己输入,因为差一个空格就会出错
可以用文本文件测试
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询