|
| ||||||||||
| Tags: administrator, batch file, directory, windows vista |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| Running batch files as administrator change working directory
As far as I know the best method to edit the batch file is by changing the current directory. For example like this CD \my_directory CALL another_batch_file Am I right up to here? If yes, then I would like to know if there is reason because the working directory is not respected or is simply a missing functionality. Any idea? |
|
#2
| |||
| |||
|
Well i am not sure whether this will work for you but i think you should try out putting "cmd /c" before the batch file location. Just try out doing this and see if it fixes the issue. |
|
#3
| |||
| |||
| 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 |
|
#4
| |||
| |||
| Re: Running batch files as administrator change working directory
In XP, %~dp0 should give you the path of the batch file. I don't have a box nearby to test Vista. http://www.microsoft.com/resources/d....mspx?mfr=true |
|
#5
| |||
| |||
| Re: Running batch files as administrator change working directory
The OP are not the only people looking for the answers to this issue on the internets. Moron. |
|
#6
| |||
| |||
| Re: Running batch files as administrator change working directory
Thank you very much for all your helps guys. But still i have a bit problem, actually a small confusion. I request you to please tell me how exactly i can create the batch file that will copy one file to multiple drives. Also please let me know how to do this with a file that is password protected. Many thanks. |
|
#7
| |||
| |||
| Re: Running batch files as administrator change working directory
just put this as the first line: chdir %~dp0 works in xp, vista, and win7 |
|
#8
| |||
| |||
| Re: Running batch files as administrator change working directory Quote:
(e.g. on drive D: - chdir changes directory but not the drive letter) |
|
#9
| |||
| |||
| Re: Running batch files as administrator change working directory
you need to use chdir /D %~dp0 to be sure that also the drive letter is correct |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "Running batch files as administrator change working directory" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to change the order of files in directory | mAHASWETA | Operating Systems | 5 | 08-01-2011 11:09 PM |
| Need help to working on Windows Server 2008 Files and Directory sharing | Atalaya | Networking & Security | 5 | 29-11-2010 10:59 PM |
| Delete the contents of a directory using Batch | GUSSIE | Operating Systems | 3 | 11-09-2009 12:43 PM |
| Retrieving the current directory in batch | Jacques25 | Software Development | 3 | 15-07-2009 11:36 PM |
| Can't change file association for DOS batch files | pushpendra | Windows XP Support | 6 | 11-03-2009 12:10 AM |