How to Automatically MSTSC or RDP into Windows Server without entering Password again & again
Like always will come directly to point:
Disclaimer: This saves password in clear text in batch file so think before using it on a shared system.If this doesn't bothers you and its really necessary as your connection is too fluctuating go ahead and read below how you can do it.
This is a 2 part process :
Thing to note: If you have passwords with special characters like % & " make sure to escape them like % in your password should be replaced with %% , & should be replaced with ^& as otherwise cmd skips them considering them as special characters and you will receive password incorrect error, to make sure your password is correctly set try printing it on cmd by adding
Disclaimer: This saves password in clear text in batch file so think before using it on a shared system.If this doesn't bothers you and its really necessary as your connection is too fluctuating go ahead and read below how you can do it.
This is a 2 part process :
- Create batch file with all the commands given below and save it as NameOfBatchScript.bat this name is used in VBScript so make sure you replace it accordingly.
- Create a VBScript file with commands given below to load the batch file we created in above step without showing the mstsc yes no prompts, save this file with any name you like(May be your Jump Server Name is best Choice for its name in case you have multiple due to multiple clients) but make sure to save it with extension as .VBS
Thing to note: If you have passwords with special characters like % & " make sure to escape them like % in your password should be replaced with %% , & should be replaced with ^& as otherwise cmd skips them considering them as special characters and you will receive password incorrect error, to make sure your password is correctly set try printing it on cmd by adding
echo %PASSWORD%
right after SET PASSWORD
line in batch script for test and then remove it if its all good.
Batch file content:
@echo off SET IP=172.X.Y.XY SET USERNAME=DOMAIN_NAME_REPLACE\USERNAME_REPLACE SET PASSWORD=PASSWORD_REPLACE cmd /c cmdkey /add:TERMSRV/%IP% /user:%USERNAME% /pass:%PASSWORD% cmd /c "cmdkey /generic:TERMSRV/%IP% /user:%USERNAME% /pass:%PASSWORD%" cmd /c "mstsc /f /v:%IP%" cmd /c "timeout /t 0 /nobreak" cmd /c "cmdkey /delete:TERMSRV/%IP%"
VBScript content:
Set WshShell = CreateObject("WScript.Shell") WshShell.Run chr(34) & "NameOfBatchScript.bat" & Chr(34), 0 Set WshShell = Nothing
How to use:
- Make sure you have both these files saved in the same folder.
- To use it just double click on the VBScript file and wait for Remote Session to Server to get loaded.
Comments
Post a Comment
Note:Please be gentle while commenting and avoid spamming as comment are anyways moderated thank you.