Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
769 views
in Technique[技术] by (71.8m points)

windows - Automating remote desktop connection

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.

I know there is a command line equivalent for MS Remote Desktop: mstsc. This question suggests to do this as follows:

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.

  • 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?
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The problem in your attempt is the parameter /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.

Do you want the credentials associated with TERMSRV/Computer01 ? (Like your example /generic:TERMSRV/"computername or IP address " said)

No, you want it associated to the normal computername Computer01.

Then you have to remove TERMSRV/.

The working result is:

cmdkey /generic:"computername or IP" /user:"username" /pass:"password"

To your other questions:

  1. See the answer above
  2. 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.
  3. See answer above.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...