I basically want to check if the user has Administrator rights before executing the rest of the code. I want to have something like a bit of standalone code that can be added to the top of other scripts to check for Administrator rights first!
Am I right in saying that this code . . .
. . . will not run Run_Go unless the user has elevated command privileges [Administrator rights]? Also, do I need an IF...ELSE in there instead of using Call?
I have seen other code like this . . .
. . . that I run on a machine with Administrator rights and it said that I didn't have Administrator rights!
Any help will be appreciated.
Am I right in saying that this code . . .
Code:
FOR /F "tokens=1,2*" %%V IN ('bcdedit') DO SET adminTest=%%V
IF (%adminTest%)==(Access) GOTO Not_Admin
Call :Run_Go
:Not_Admin
Code goes here.
:Run_Go
Code goes here.
. . . will not run Run_Go unless the user has elevated command privileges [Administrator rights]? Also, do I need an IF...ELSE in there instead of using Call?
I have seen other code like this . . .
Code:
echo off
goto check_Permissions
:check_Permissions
echo Administrative permissions required. Detecting permissions...
net session >nul 2>&1
if %errorLevel% == 0 (
echo Success: Administrative permissions confirmed.
) else (
echo Failure: Current permissions inadequate.
)
pause >nul
. . . that I run on a machine with Administrator rights and it said that I didn't have Administrator rights!
Any help will be appreciated.
My Computer
- Computer type
- Laptop
- Computer Manufacturer/Model Number
- Fujitsu LIFEBOOK
- OS
- Win 7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
- CPU
- Intel(R) Pentium(R) CPU P6200 @ 2.13GHz
- Motherboard
- FUJITSU FJNBB06
- Memory
- 4.00 GB
- Graphics Card(s)
- Intel(R) Graphics Media Accelerator HD
- Sound Card
- [1] Realtek High Definition Audio [2] Intel(R) Display Audio
- Screen Resolution
- 1366 x 768 x 32 bits (4294967296 colors) @ 59 Hz
- Hard Drives
- TOSHIBA MK5076GSX
- Antivirus
- AVG FREE