![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| Newbie | How to determine a batch file is running as administrator Hi How to determine whether a batch file (*.cmd) is running as an administrator? In the cmd script, I want to add a sentence to determine whether it is running as an administrator, according to the judge to take a different approach. (Sorry, my English is not good...) Now my approach is: -------------------------------------------------- set ADMINTEST=%SystemRoot%\$ADMIN_TEST_JDCHEN copy "%~f0" "%ADMINTEST%" > nul :: 返回值 0=true, 1=false if not errorlevel 1 ( del "%ADMINTEST%" > nul echo Running As Administrator. ) else echo Acquire Administrative Privileges. --------------------------------------------- perhaps there is a better practice? Last edited by J.D.CHEN; 10-04-2008 at 05:09 AM.. |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Running a batch file | Vista General | |||
| Running a batch file | Vista security | |||
| determine version of .exe thru batch file | Vista General | |||
| Running batch files as administrator change working directory | Vista General | |||
| Scheduler does not run batch file and can't run as an administrator | Vista General | |||