Well, sometimes an admin will try to make the system secure by annoying the people who have to use it. Yeah, that always works. My situation is that I have to login every day into a virtual machine that is on a "secure network". So after using a very restrictive password policy that forces everybody to be creative in the way they write "password" and "123456", he also disallowed the saving credentials in Remote Desktop Connection. So every day I have to enter the damn complicated password. I couldn't have that. Here is a .js script that you execute with WScript and it logs you in automatically:
var shell = WScript.CreateObject("WScript.Shell");
shell.Run("mstsc /v:[remote server] /console");
while (!shell.AppActivate("Windows Security")) {
WScript.Sleep(100);
}
WScript.Sleep(100);
shell.SendKeys("[password]{enter}");

Save this into a Javascript file and replace [remove server] and [password] with your settings and either double click the .js file or create a batch file like this:
@echo off
start "Auto log on!" wscript c:\Batches\autologin.js

Of course, this means your secure password will be stored in a stupid text file somewhere, so be warned.

Comments

Siderite

<p>This is a simple hack with a very simple tool. SendKeys is not even guaranteed to work, since between you send the keys and when they take effect the app may have switched to something else, already. Even so, SendKeys doesn't work with RDP. You probably need an external application, like AutoKey, or a program you make yourself and copy to the remote machine. Check out this answer: <a href="https://social.msdn.microsoft.com/Forums/en-US/01d1c501-880a-48c3-8b82-d3b08e974ff0/remote-desktop-connection-sendkeys" rel="nofollow noopener" title="https://social.msdn.microsoft.com/Forums/en-US/01d1c501-880a-48c3-8b82-d3b08e974ff0/remote-desktop-connection-sendkeys">https://social.msdn.microso...</a></p>

Siderite

KAPIL MEHTA

<p>Can i use sendKeys on remote machine to perform some operations on remote machine ?</p><p>How can i swich focus to remote machine window ?</p><p>Tried below code but didn't work :-</p><p>shell.AppActivate("10.x.x.x - Remote Desktop Connection")</p>

KAPIL MEHTA

Post a comment