Reputation: 473
I'm creating an application in Visual Studio. When the user clicks a button, I want the follow CMD command to be executed:
xcopy /s/y "C:\myfile.txt" "D:\"
I've tried this with Process.Start() but it won't work. The button code is:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Process.Start("CMD", "/C xcopy /s/y "C:\myfile.txt" "D:\"")
End Sub
Does anyone know how I can make this work? I suspect that the problem is caused by the /s/y parameters or quotes in the CMD command.
Upvotes: 1
Views: 7304
Reputation: 155726
Your code won't compile: you need to escape the double-quotes in the string. In VB.NET you escape quotes using double-double quotes:
Process.Start( "CMD", "/C xcopy /s/y ""C:\myfile.txt"" ""D:\""" )
Upvotes: 3