![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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) |
| | Running batch files as administrator change working directory 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 |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Running batch files as administrator change working directory <corradolab@xxxxxx> wrote in message news:6626364e-e5de-40a1-adf4-495dd5399fe9@xxxxxx Quote: > 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 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? |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Running batch files as administrator change working directory Code: -------------------- @echo off for %%F in (folder1 folder2 folder3) DO xcopy /h /r /k /x /y /S /E "\\servername\folder" "\\servername\%%F" exit -------------------- This will look at the all the folder names 'folder1, folder2, and folder3' and will copy all files from the origin to them -- thesk8rjesus ------------------------------------------------------------------------ thesk8rjesus's Profile: http://forums.techarena.in/members/thesk8rjesus.htm View this thread: http://forums.techarena.in/vista-help/887281.htm http://forums.techarena.in |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| How to determine a batch file is running as administrator | General Discussion | |||
| Batch files, administrator, network drives | Vista General | |||
| running batch files... | Vista General | |||
| Running Batch Files in VISTA | Vista General | |||