Skip to content

Instantly share code, notes, and snippets.

@stringsn88keys
Created March 31, 2021 22:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stringsn88keys/9437a2d3783462e3e45cbebe76e5456f to your computer and use it in GitHub Desktop.
Save stringsn88keys/9437a2d3783462e3e45cbebe76e5456f to your computer and use it in GitHub Desktop.
"Type" old and new passwords into Windows Server 2016 change password screen went WorkSpaces doesn't allow pasting from your Mac.
#!/usr/bin/osascript -l JavaScript
// Usage:
// export OLDPASS="oldpasswordhere!"
// export NEWPASS="newpasswordgoeshere."
// get to change password screen in WorkSpace prior to running this script and make sure you're on the "old password" field.
// run script without args
var app = Application.currentApplication();
app.includeStandardAdditions = true
var WorkSpace = new Application("WorkSpaces");
var sys_events = Application("System Events");
WorkSpace.activate();
delay(0.2);
var newpw = app.systemAttribute("NEWPASS")
var old = app.systemAttribute("OLDPASS")
array = [old, newpw, newpw]
array.forEach(function(str) {
for(var i = 0; i < str.length; i++) {
var c = str.charAt(i);
switch(c)
{
case '0':
sys_events.keyCode(29);
break;
case '1':
sys_events.keyCode(18);
break;
case '2':
sys_events.keyCode(19);
break;
case '3':
sys_events.keyCode(20);
break;
case '4':
sys_events.keyCode(21);
break;
case '5':
sys_events.keyCode(23);
break;
case '6':
sys_events.keyCode(22);
break;
case '7':
sys_events.keyCode(26);
break;
case '8':
sys_events.keyCode(28);
break;
case '9':
sys_events.keyCode(25);
break;
case '.':
sys_events.keyCode(47);
break;
default:
sys_events.keystroke(str.charAt(i));
}
delay(0.1);
}
sys_events.keystroke('\t')
delay(0.1);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment