Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Vista General Discussion > Running batch files as administrator change working directory

Reply
Thread Tools Display Modes

Running batch files as administrator change working directory

 
 
corradolab@ngi.it
Guest
Posts: n/a

 
      01-07-2008
Hi,

if you start a batch file from Explorer the working directory is the
directory which holds the file.
If you start a batch file from a shortcut you can specify a different
one.
But if you start a batch file as Administrator the working directory
is always C:\Windows\System32, even if the file is in a different
directory or is started from a shortcut whit an explict working
directory.

This cause every batch file calling another executable (batch, exe,
ecc.) to fail if not using absolute paths.
The quickest workaround is probably to edit the batch file changing
the current directory.
Something like:

CD \my_directory
CALL another_batch_file

My question is: why?
Is there a reason because the working directory is not respected or is
simply a missing functionality?

Kind regards,
Corrado
 
Reply With Quote
 
 
 
 
Bob
Guest
Posts: n/a

 
      01-07-2008

<> wrote in message
news:6626364e-e5de-40a1-adf4-...
> Hi,
>
> if you start a batch file from Explorer the working directory is the
> directory which holds the file.
> If you start a batch file from a shortcut you can specify a different
> one.
> But if you start a batch file as Administrator the working directory
> is always C:\Windows\System32, even if the file is in a different
> directory or is started from a shortcut whit an explict working
> directory.
>
> This cause every batch file calling another executable (batch, exe,
> ecc.) to fail if not using absolute paths.
> The quickest workaround is probably to edit the batch file changing
> the current directory.
> Something like:
>
> CD \my_directory
> CALL another_batch_file
> My question is: why?
> Is there a reason because the working directory is not respected or is
> simply a missing functionality?
>
> Kind regards,
> Corrado

Sorry, I don't know why, but if you insert cmd /c before the batch file
location I think it will solve the problem.

Maybe you can help me with a batch file. I Googled it but can't find an
answer.

I would like to know how I can create a batch file that will copy one file
to multiple drives.

I would also like to know how to do this with a file that is password
protected.

Any ideas?








 
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Offline Files "Change Limits" button not working. Cannot change Offline Files Settings Eriq Windows Vista General Discussion 1 07-09-2008 10:54 PM
In Vista, can .wps files be converted to .rtf files as a batch i.e.instead of one at a time? Mike Arnold Windows Vista General Discussion 4 03-20-2008 12:43 PM
Batch files, administrator, network drives ToddAndMargo Windows Vista General Discussion 0 02-02-2008 04:08 AM
running batch files... maya Windows Vista General Discussion 12 08-23-2007 01:26 AM
Running Batch Files in VISTA Peeky Windows Vista General Discussion 8 06-24-2007 12:43 PM



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 47 48 49 50 51 52 53 54 55 56 57 58 59