I wrote some c# code that uses PSexe. I want it to run a remote exe on a machine connected to my LAN.
That exe creates a new local user. When I run that exe locally on the remote machine (after right click --> "run as Admin") - it works fine. I don;t know how to simulate the right click --> "run as Admin" from Psexec. I have tried the -l flag but it didn't work
When you run cmd.exe interactively through PsExec under a remote user, you have no way to elevate privileges (as Admin) when the UAC is enabled. To run the commands with the account's elevated token, use the –h option. This option means that all commands will be executed in the “Run as Administrator” mode.
Normally PSExec will run with the credentials of the local user that has run the command. By using a domain account instead, you will be able to elevate to that command.
Prerequisites for PsExec File and printer sharing must be enabled on both local and remote computers (TCP port 445 must be open on remote computers). It could be a potential security risk, so make sure you enable this port for the Private profile in the Windows firewall.
Simply add a -h
after adding your credentials using a -u -p
, and it will run with elevated privileges.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With