从 VBA 在远程桌面上运行批处理文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16422856/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 21:00:24  来源:igfitidea点击:

Run a batch file on a remote desktop from VBA

excel-vbaremote-desktopvbaexcel

提问by user2358848

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.

我是新手,正在寻求帮助。我手动打开一个远程桌面到服务器并运行我坐在该桌面上的批处理文件。我想通过 VBA 来做到这一点。我不想看到远程桌面,我想知道批处理文件何时完成运行。这是我到目前为止找到的代码。它将我带到远程桌面的密码屏幕,我必须手动从那里获取它。我需要在代码中添加什么才能完成这项工作。

TestVar = Shell("C:\windows\system32\mstsc.exe /v:" & "IP Address", 1)

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"

远程批处理文件的路径为:“C:\users\path\desktop\batch.bat”

回答by Our Man in Bananas

If you aren't worried about the logon screen, and want to execute commandfs remotely, you need to take a look at Windows PowerShell

如果你不担心登录屏幕,并想远程执行commandfs,你需要看看Windows PowerShell

I think this immensely popularStackOverFlow topic could prove useful too (See the answer with 200 upvotesby Jason R. Coombs

我觉得这个非常流行的StackOverflow的话题也被证明是有用的(参阅的答复200个upvotes贾森R.库姆斯

Stack Overflow: how to use ssh to run shell script on a remote machine

Stack Overflow:如何使用 ssh 在远程机器上运行 shell 脚本