windows 自动化远程桌面连接
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16479652/
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
Automating remote desktop connection
提问by Mahesha999
We use many remote desktops in our development environment and there are many servers deployed in multiple environments. It is tedious to remember their IP addresses, usernames, and passwords. I want to write a small utility with buttons on it. When clicked, I want to start those remote desktops, automatically fetching usernames and passwords from some list.
我们在开发环境中使用了许多远程桌面,并且在多个环境中部署了许多服务器。记住他们的 IP 地址、用户名和密码很乏味。我想写一个带有按钮的小实用程序。单击后,我想启动那些远程桌面,自动从某个列表中获取用户名和密码。
I know there is a command line equivalent for MS Remote Desktop: mstsc
.
Thisquestion suggests to do this as follows:
我知道 MS 远程桌面有一个等效的命令行:mstsc
.
这个问题建议这样做:
cmdkey /generic:TERMSRV/"computername or IP address" /user:"username" /pass:"password"
mstsc /v:"computer name or IP"
I run the first line, and it says credential successfully added. Then when I run the second line it simply runs Remote Desktop Connection for the specified IP address and asks for username and password. I would like it to simply open the remotely connected desktop at specified IP address by automatically applying the credential specified in cmdkey
.
我运行第一行,它说凭据已成功添加。然后当我运行第二行时,它只是为指定的 IP 地址运行远程桌面连接,并要求输入用户名和密码。我希望它通过自动应用cmdkey
.
- What's wrong here? Is it possible using such PowerShell script?
- Can I invoke this script through an HTML page (since there are many other resources that I will be laying onto the webpage which will serve as one spot links for we developers, so that we will not be wasting time and effort finding them each time we want them)? Is it possible by registering the application to a URI scheme?
- Is there another (standard) way?
- 这里有什么问题?是否可以使用这样的 PowerShell 脚本?
- 我可以通过 HTML 页面调用这个脚本吗(因为我将在网页上放置许多其他资源,这些资源将作为我们开发人员的单点链接,这样我们每次都不会浪费时间和精力去寻找它们要他们)?是否可以通过将应用程序注册到 URI 方案?
- 还有另一种(标准)方式吗?
回答by Solaflex
The problem in your attempt is the parameter /generic
.
您尝试中的问题是参数/generic
.
According to the official website for cmdkey, /generic
identifies the computer or domain name that this entry will be associated with.
标识将与此条目关联的计算机或域名。
In my example, I will call the computer Computer01.
在我的示例中,我将调用计算机Computer01。
Do you want the credentials associated with TERMSRV/Computer01 ? (Like your example /generic:TERMSRV/"computername or IP address "
said)
您想要与 TERMSRV/Computer01 关联的凭据吗?(就像你的例子/generic:TERMSRV/"computername or IP address "
说的)
No, you want it associated to the normal computername Computer01.
不,您希望它与普通计算机名Computer01相关联。
Then you have to remove TERMSRV/
.
然后你必须删除TERMSRV/
.
The working result is:
工作结果是:
cmdkey /generic:"computername or IP" /user:"username" /pass:"password"
To your other questions:
对于您的其他问题:
- See the answer above
- I don't know if it's possible with HTML only. I don't think so. But I also implement some PowerShell scripts into ASP.NET. This works.
- See answer above.
- 看上面的回答
- 我不知道是否可以仅使用 HTML。我不这么认为。但我也在 ASP.NET 中实现了一些 PowerShell 脚本。这有效。
- 见上面的回答。
回答by Mahesha999
A lot has changed since 2013. Many system operators already suggested to use ready-made tools which does this. Back in year 2013, Windows store wasn't that great a place (*my opinion). But now it's OK.
自 2013 年以来发生了很多变化。许多系统运营商已经建议使用可以做到这一点的现成工具。早在 2013 年,Windows 商店就不是一个好地方(*我的意见)。不过现在好了。
There is Microsoft's own Remote Desktop applicationin the store. The application is universal, that is, it runs on PCs, mobile phones, and holographic devices.
商店中有微软自己的远程桌面应用程序。该应用程序具有通用性,即可以在PC、手机和全息设备上运行。
What's good? Microsoft has made the same app available on Android. I have tried for PC and Android. Both work great.
有什么好的?微软已经在 Android 上提供了相同的应用程序。我已经尝试过 PC 和 Android。两者都很好用。
So have a try. I am regular user of these applications now.
所以试试吧。我现在是这些应用程序的常客。