问题
I am new and seeking help. I manually open a remote desktop to a server and run a batch file I have sitting on that desktop. I want to do this thru VBA. I don't want to see the remote desktop and I would like to know when the batch file is finished running. Here is the code I have found so far. It brings me to the password screen for the remote desktop and I must take it from there manually. What do I need to add to the code to get this done.
TestVar = Shell("C:\windows\system32\mstsc.exe /v:" & "IP Address", 1)
The path for the batch file on the remote is: "C:\users\path\desktop\batch.bat"
回答1:
If you aren't worried about the logon screen, and want to execute commandfs remotely, you need to take a look at Windows PowerShell
- MS Technet - PowerShell INVOKE Command to execute a script on one or more remote computers
- MS Technet - Running Remote Commands with PowerShell
I think this immensely popular StackOverFlow topic could prove useful too (See the answer with 200 upvotes by Jason R. Coombs
Stack Overflow: how to use ssh to run shell script on a remote machine
来源:https://stackoverflow.com/questions/16422856/run-a-batch-file-on-a-remote-desktop-from-vba