Psexec "run as (remote) admin"
Asked Answered
G

2

18

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

Greywacke answered 12/5, 2010 at 7:14 Comment(0)
T
21

Use psexec -s

The s switch will cause it to run under system account which is the same as running an elevated admin prompt. just used it to enable WinRM remotely.

Tract answered 4/8, 2010 at 16:16 Comment(1)
Sorry, this is just plain wrong. The SYSTEM account is something entirely different than you user account with all privilege tokens (including the administrative ones) enabled! The SYSTEM account is allowed to do everything (usually). Even things that a local administrator can't do. It's also a different user profile so it uses different settings and path names.Seadog
P
36

Simply add a -h after adding your credentials using a -u -p, and it will run with elevated privileges.

Pecuniary answered 25/2, 2013 at 18:59 Comment(4)
psexec does not support the argument -h. At least not in the current version of 2009.Seadog
@LonelyPixel Just came across this... the version I got here does have a -h parameter: If the target system is Vista or higher, has the process run with the account's elevated token, if available.Necessitous
Interesting. Now I also get a version with "-h" from them. Must be an upgraded 1.98. But it fails if I'm not already calling it as admin. (Can't create service, access denied.) Where's the sense in that?Seadog
This helped me, thank you! I had troubles with remotely executing appcmd to stop IIS sites. The error was: redirection.config Cannot read configuration file due to insufficient permissions. In case anyone has similar issues.Longrange
T
21

Use psexec -s

The s switch will cause it to run under system account which is the same as running an elevated admin prompt. just used it to enable WinRM remotely.

Tract answered 4/8, 2010 at 16:16 Comment(1)
Sorry, this is just plain wrong. The SYSTEM account is something entirely different than you user account with all privilege tokens (including the administrative ones) enabled! The SYSTEM account is allowed to do everything (usually). Even things that a local administrator can't do. It's also a different user profile so it uses different settings and path names.Seadog

© 2022 - 2024 — McMap. All rights reserved.