Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Check for Administrator rights in Batch file.

2 Weeks Ago   #11
Paul Black

Win 7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
 
 

Hi iko22,

Quote   Quote: Originally Posted by iko22 View Post
Rather confusingly, I got the routine to work with NET SESSION. Two points to make: 1) It only works (recognises the errorlevel) if >nul 2>&1 is removed; and 2) The routine outputs System Error 5, but it has to check on errorlevel 2 and errorlevel 0!
No, it still didn't work for me but thanks anyway!

I ran net user administrator /active:yes and switched users to Administrator and ran both my original code and your amended code and it reported 5. I will try and have a more in depth look at this another time!

No worries though as I have what I really need and thank you for your input and help!


My System SpecsSystem Spec
.
Reply

 Check for Administrator rights in Batch file.




Thread Tools




Similar help and support threads
Thread Forum
Remove Admin Rights and Move instead of Copy | Batch file
I have a list of 1000 files names that I put in a text file named list.txt. Need to find them in more folders, sub folders which has 12000+ files in it. The below script works fine but I would like the Admin Right to be removed and also I want the files to be moved permanently into C:\your_files....
General Discussion
shutdown in batch file requires Administrator
Hi all, I've been using GFI Backup 2009 for backups for a while, it does everything I want, and sends email reports after backup is complete. One of its features is to shutdown the computer after a backup, this rarley works, as it wont shutdown if a program is already running, including GFI...
General Discussion
Batch File on USB fails when Ran As Administrator
I am new to this site so please excuse any lack of etiquette I may show. I have recently built a .bat files to perform a large number of configuration changes needed for a Win7 or Win8 workstation to function properly on my network. The .bat file obviously needs to be ran with elevated...
Software
File permissions, administrator rights, sharing issues
We have been having an ongoing problem for several months. I will explain as best I can, but know that there are most likely more issues than what I am presenting here. I apologize in advance for my lengthiness. We have a home network of 7 computers and have been using Win 7 Pro and Office...
Microsoft Office
How to always run batch file as administrator?
I've made a batch file, but i don't know how to make it to always run as administartor. In .bat's file properties the option "always run as administartor" is grayed out. I have to right click it and then choose "run as administartor" from context menu. But i don't want to do it every time because...
General Discussion


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 11:35.
Twitter Facebook