Created
June 13, 2018 22:48
-
-
Save OsandaMalith/8dd2915ea1992fa1af5cea3de7e9bc7b to your computer and use it in GitHub Desktop.
A simple automation to run a program under a different user
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
# Title: A simple automation to run a program under a different user | |
# Author: Osanda Malith (@OsandaMalith) | |
# Website: https://osandamalith.com | |
#> | |
add-type -AssemblyName microsoft.VisualBasic | |
add-type -AssemblyName System.Windows.Forms | |
$args = "/user:jane " + $args[0] | |
Start-Process runas -ArgumentList $args | |
start-sleep -Milliseconds 1000 | |
[Microsoft.VisualBasic.Interaction]::AppActivate("runas.exe") | |
[System.Windows.Forms.SendKeys]::SendWait("abc123{ENTER}") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment