Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I am new to batch scripting and need some help. Here is what I wish to do.
Users will download a folder and run a batch script that will call some executables which reference some files. The problem I have is that different users will download the folder to different locations. Hhow do I go about making the batch script run the executables from the current folder no matter where the folder has been saved by the users?

You shouldn't have to do anything special. It should just work, as long as the batch script does not make any assumptions about the absolute location of the folder. I.e. don't run a file as C:\Programs\prog.exe, just run prog.exe and it will be taken from the current folder.

Hi klint,
That only works if the folder is in the path. Unlikely if users are saving here, there and everywhere.
If b 'download' you mean COPY, maybe something like this:
::==
@echo off
setLocal EnableDelayedExpansionset /p dest=choose destination
echo xcopy x:\the\stuff !dest!\/s
echo !dest!\prog.exe
=====================================
If at first you don't succeed, you're about average.M2

Users will download a zip file of a folder containing a few executables and files. There are 3 things that need to run:
winhttpcertcfg.exe -i certificate.pfx -c LOCAL_MACHINE\MY -a %computername%
certmgr.exe -add -c certificate.cer -s -r LocalMwinhttachine Root
dialup.exe /s
Where would I add the above suggestion to the script?

@echo off
setLocal EnableDelayedExpansionset /p dest=choose destination
pushd !dest!\
xcopy x:\the\stuff
pkunzip *winhttpcertcfg.exe -i certificate.pfx -c LOCAL_MACHINE\MY -a %computername%
certmgr.exe -add -c certificate.cer -s -r LocalMwinhttachine Root
dialup.exe /s
=====================================
If at first you don't succeed, you're about average.M2

pedrorod, M2 is providing good help so I won't confuse you by adding any more info, but I'd just like to clarify something mainly for M2's benefit:
When you run a program by typing its name without a path, it doesn't just look for it in the PATH. It first looks in the current directory, and only looks in the PATH if it doesn't find it in the current directory. Note that this differs from how it's done on Unix.

![]() |
Split a String - DOS, Bat...
|
malloc in assembly
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |