Run a batch file on a remote desktop from VBA

前提是你 提交于 2019-12-13 02:22:41

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!