Skip to content

Instantly share code, notes, and snippets.

@OsandaMalith
Created June 13, 2018 22:48
Show Gist options
  • Save OsandaMalith/8dd2915ea1992fa1af5cea3de7e9bc7b to your computer and use it in GitHub Desktop.
Save OsandaMalith/8dd2915ea1992fa1af5cea3de7e9bc7b to your computer and use it in GitHub Desktop.
A simple automation to run a program under a different user
<#
# 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