从 VBA 在远程桌面上运行批处理文件 [英] Run a batch file on a remote desktop from VBA
问题描述
我是新手,正在寻求帮助.我手动打开一个远程桌面到服务器并运行我坐在该桌面上的批处理文件.我想通过 VBA 来做到这一点.我不想看到远程桌面,我想知道批处理文件何时完成运行.这是我到目前为止找到的代码.它将我带到远程桌面的密码屏幕,我必须手动从那里获取它.我需要在代码中添加什么才能完成这项工作.
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 地址", 1)
远程批处理文件的路径为:C:\users\path\desktop\batch.bat"
The path for the batch file on the remote is: "C:\users\path\desktop\batch.bat"
推荐答案
如果你不担心登录界面,想远程执行commandfs,你需要看看Windows PowerShell
If you aren't worried about the logon screen, and want to execute commandfs remotely, you need to take a look at Windows PowerShell
我认为这个非常受欢迎的 StackOverFlow 主题也可能很有用(请参阅 Jason R. Coombs 的 200 个赞成票的答案
I think this immensely popular StackOverFlow topic could prove useful too (See the answer with 200 upvotes by Jason R. Coombs
堆栈溢出:如何使用 ssh 在远程机器上运行 shell 脚本
这篇关于从 VBA 在远程桌面上运行批处理文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!