Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
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.

Go Back   Vista Forums > Vista Forums > General Discussion

Vista Tutorial - How to determine a batch file is running as administrator

Reply
 
Old 10-04-2008   #1 (permalink)
Newbie


Join Date: Oct 2008
vista ultimate 32bit
 
 

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 SpecsSystem Spec
Reply

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


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46