How to copy local text file to remote desktop?

Copy local text file to remote desktop.

You just impliment below code.



ExecuteCommand("Copy " & Directory.GetCurrentDirectory & "\Output\Files.txt \\myservername\C$\Files.txt")

' ...

Public Sub ExecuteCommand(ByVal Command As String)
Dim ProcessInfo As ProcessStartInfo
Dim Process As Process
ProcessInfo = New ProcessStartInfo("cmd.exe", "/K " & Command)
ProcessInfo.CreateNoWindow = True
ProcessInfo.UseShellExecute = True
Process = Process.Start(ProcessInfo)
' You might want to wait for the copy operation to actually finish.
Process.WaitForExit()
' You might want to check the success of the operation looking at
' Process.ExitCode, which should be 0 when all is good (in this case).
Process.Dispose()
End Sub

Finally, you could have just used File.Copy instead

File.Copy(Directory.GetCurrentDirectory & “\Output\Files.txt”,
“\\myservername\C$\Files.txt”)

About the Author

avatar