11
4
I am using psexec.exe
to run programs in a different security context. However the programs start but it does not seem to be running in the specified security context.
In its minimal form:
psexec -u wsadmin -p password cmd
Starts a new cmd window if I type in that window whoami
C:\Windows\system32>whoami
win-k1r7g38nlkt\wsadmin
C:\Windows\system32>net localgroup administrators
Alias name administrators
Comment Administrators have complete and unrestricted access to the computer/domain
Members
-------------------------------------------------------------------------------
Administrator
wsadmin
The command completed successfully.
As you can see I am definately the other user. And I can confirm that this user is member of the "Administrators group"
C:\Windows\system32>mkdir test
Access is denied.
If I use runas with the specified user it works as supposed. But I need to supply the password on the commandline.
For me the -h flag did not work and disabling UAC was troubling, but I found a better alternative
– mTorres – 2019-11-16T11:39:20.6334The other way around this that doesn't require changing the registry is to just add the
-h
flag to thepsexec
command. This tells it to run the command with the elevated token, which is equivalent to launching a process "as administrator" from the context menu. – nhinkle – 2013-01-28T10:09:41.4405
Setting
– Vlastimil Ovčáčík – 2013-07-27T13:06:10.290EnableLUA
to0
disablesAdmin Approval Mode
, which is basically the core of UAC. As a result the UAC will get disabled. Source.