Fabian Röling
Fabian Röling

Reputation: 1356

Run file NOT as administrator

I'm trying to test a batch file that should test for administrator privileges, but I have the weird problem that I can't run it without administrator privileges.

net session >nul 2>&1
if %errorLevel% == 0 (
    rem do whatever...

Sure, I can just create another user account and run it from there, but that's a bit much effort just for one little test.

The script example above may not exactly be what I wanted because I need a general solution, for example to test if an installer can run without admin rights.

Is there an easier way? A command line argument for running something without administrator privileges maybe?

BTW, I disabled UAC if that makes any difference.

Upvotes: 0

Views: 732

Answers (1)

MC ND
MC ND

Reputation: 70961

You can try with

runas /trustlevel:0x20000 "cmd.exe /c ....."

use runas /showtrustlevels to see the available levels

Upvotes: 3

Related Questions