-
How to determine in batch-file, if user is administrator
Hi NG!
Is there any possibility to determine in a batch-file, if the logged-on user is member of Administrators-Group?
This should even work, if the user is member of a domain...
Of course I can try, to create a file unter %SYSTEMROOT% or something else, and then check, if it was created... but perhaps there is a better practice?
Any suggestion is greatly appreciated,
-
Re: How to determine in batch-file, if user is administrator
in the batch, add the following lines to determine if the logged on user is a local administrator:
set admin=N
set domain=%USERDOMAIN%\
If /i "%domain%" EQU "%computername%\" set domain=
set user=%domain%%username%
for /f "Tokens=*" %%a in ('net localgroup administrators^|find /i "%user%"') do set admin=Y
Then just test the value of %admin%
If "%admin% EQU "Y" goto isAdmin
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
Bookmarks