Log in using "mstsc / admin" with a password

I want to use mstsc /admin to log in to the server. My batch file reads the code as

 mstsc /v:xxx.xxx.xxx.xxx /admin 

But he asks me to enter a password. Can someone help me skip this step?

I went to Google and found this site . But I am very new to this material (scripts) and could not understand what to do with this code. Is this a vbscript file? Can I do the same with a batch file. Please specify and I ask you to anoint the food. This is not my arena, but still they make me fight without weapons.

My main need is to start all users from a remote desktop, except mine, to do some repair work. Thanks.

+7
source share
5 answers

This became a popular issue, and I received a notification. Sorry, I forgot to answer before I had to do this. I decided it for a long time.

 net use \\10.100.110.120\C$ MyPassword /user:domain\username /persistent:Yes 

Run it in a batch file and you should get what you are looking for.

0
source

Sent in response: Found an alternative (tested in Win8):

 cmdkey /generic:"<server>" /user:"<user>" /pass:"<pass>" 

Run this, and if you run:

 mstsc /v:<server> 

You should not receive an invitation to authenticate.

+26
source

Same problem, but @Angelo's answer didn’t work for me because I use the same server with different credentials. I used the approach below and tested it on Windows 10.

cmdkey /add:server01 /user:<username> /pass:<password>

Then mstsc /v:server01 to connect to the server.

The point is to use names instead of ip addresses in order to avoid a conflict between credentials. If you do not have local access to the DNS server, try the c:\windows\system32\drivers\etc\hosts file.

+1
source

Save the username, password and server name in the RDP file and run the RDP file from your script

0
source

the team sent by Milad and Sandy did not work for me with mstsc. I had to add TERMSRV to the / generic switch. I found this information here: https://gist.github.com/jdforsythe/48a022ee22c8ec912b7e

cmdkey /generic:TERMSRV/<server> /user:<username> /pass:<password>

Then I could use mstsc /v:<server> without prompting for a login.

0
source

All Articles