Cynosure.X International LLC

:

Add Comment | Related Links | TrackBack
Related Content

Running Batch File as Administrator vs. Running as User

Much like executables, Windows can run batch scripts as either administrator or regular user. Running batch file as user is easy, all it takes is to double-click the batch file. To run the batch script as administrator, right-click on the batch file and click on the "Run as administrator" menu option.

But Windows behaves differently when the batch script is running one way vs. another way. In this thread, we point out the subtle differences.

Current Working Directory: When you run the batch file as a user, the working directory is where the batch file resides. But when you run the batch file as administrator, the current working directory is "%SystemDrive%\WINDOWS\system32".

Because of this difference, when programming batch scripts, try not to rely on the current directory as the script location. Instead, determine the script location using batch variables. For example:

  set scriptDir=%~d0%~p0
set scriptName=%~n0%~x0

Mel
Wed, 12 Nov 2014 08:13:45 +0300

Add Comment | Related Links | TrackBack
Related Content

Did your message disappear? Read the Forums FAQ.

Add Comment

Spam Control | * indicates required field
Your Name: *
E-mail:
Remember Me!
Comment: *
File attachment is optional. Please do not attach a file to your submission unless it is relevent.
Attach File:
(20 MB Max)
Spam Protection: * Answer of 9 + 3?
Click button only once, please!

TrackBack

TrackBack only accepted from WebSite-X Suite web sites. Do not submit TrackBacks from other sites.

Send Ping | TrackBack URL | Spam Control

No TrackBacks yet. TrackBack can be used to link this thread to your weblog, or link your weblog to this thread. In addition, TrackBack can be used as a form of remote commenting. Rather than posting the comment directly on this thread, you can posts it on your own weblog. Then have your weblog sends a TrackBack ping to the TrackBack URL, so that your post would show up here.

Messages, files, and images copyright by respective owners.

Products | Services
Forums | Latest | RSS
Library | Search | Wiki
Help | Licenses

Login | Register

62 Users Online

Hacking Digital Cameras
Fun for Photographers



Amazon Associate

Copyright © 1996 - 2024. All Rights Reserved.