Forum Home
Press F1
 
Thread ID: 111623 2010-08-04 08:16:00 Batch Install (2) The Error Guy (14052) Press F1
Post ID Timestamp Content User
1124664 2010-08-04 20:41:00 I could be wrong but pushd will only set the dir that you tell it to, it won't find the batches current location and set the command line to use that dir to run the commands from The Error Guy (14052)
1124665 2010-08-05 02:42:00 Note that the "%0" variable gives the name of the batch file, and using command extensions, you can modify that with drive & path expansion, so the variable "%~dp0" gives you the drive & path of the batch file. Hopefully that's what you need. MushHead (10626)
1124666 2010-08-05 03:15:00 I could be wrong but pushd will only set the dir that you tell it to, it won't find the batches current location and set the command line to use that dir to run the commands from

Are you going to answer my last post?
Snorkbox (15764)
1124667 2010-08-05 04:27:00 Its not working, its either a mistake of that command line isnt working



%~dp pushd
pause
xcopy %~dp Fonts\ C:\Users\Mac\Desktop
popd
The Error Guy (14052)
1124668 2010-08-05 06:01:00 yes fred_fish (15241)
1124669 2010-08-05 07:33:00 yes to what? The Error Guy (14052)
1124670 2010-08-05 08:00:00 Yes, to "If you provided some detail as to what you are trying to do, and actually read the answers people are giving you, you might get somewhere".

For a start %~dp0 gives you the path of the currently running batch script, not %~dp

There is no point trying to find the current directory to do the xcopy, because that is the working directory of the batch script anyway (unless you 'cd' earlier in the script but then %CD% is not what you want either) .

The error is due to your xcopy command. Check the validity of your arguments, there are only two, one or more of them are wrong.
fred_fish (15241)
1124671 2010-08-05 09:03:00 I have read the replys, when I copied the text from the forum to the bat I must have missed an 0 (which explains a lot)

I found out that %CD% isn't right either and I should be using cd
(should have cross-referenced forums)

To clarify The .bat and files to be installed will be in a .zip that the user will the unzip giving it a dir structure similar to X:\Path\to\extracted\files\Fonts I need to find out X:\Path\to\extracted\files\ so I can tell the bat to copy X:\Path\to\extracted\files\Fonts

Thanks
The Error Guy (14052)
1124672 2010-08-05 11:18:00 OK
So, if the .zip is extracted somewhere like D:\random you end up with a tree like:

D:\random\your.bat
D:\random\otherfile.whatever
D:\random\Fonts\font1.ttf
D:\random\Fonts\font2.ttf
etc.

when the user executes the batch script by double-clicking it, its working directory will be D:\random
so you don't need to know where it is and your xcopy line should be

xcopy Fonts %HOME%\Desktop\
The environment variable %HOME% is replaced with the current users home directory as the user is presumably not always 'mac', the %HOMEDRIVE% is not always 'C:' etc.

You may want to be a bit more specific about how xcopy behaves so check out
xcopy /?and add the switches you require.
fred_fish (15241)
1 2