Computing.Net > Forums > Programming > Batch Script Help

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch Script Help

Reply to Message Icon

Name: pedrorod
Date: May 1, 2008 at 11:05:31 Pacific
OS: Windows XP
CPU/Ram: 3ghz
Product: Dell
Comment:

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?




Sponsored Link
Ads by Google

Response Number 1
Name: klint
Date: May 1, 2008 at 13:57:45 Pacific
Reply:

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.


0

Response Number 2
Name: Mechanix2Go
Date: May 1, 2008 at 15:25:42 Pacific
Reply:

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 EnableDelayedExpansion

set /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


0

Response Number 3
Name: pedrorod
Date: May 1, 2008 at 20:34:33 Pacific
Reply:

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?


0

Response Number 4
Name: Mechanix2Go
Date: May 1, 2008 at 21:17:42 Pacific
Reply:

@echo off
setLocal EnableDelayedExpansion

set /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


0

Response Number 5
Name: klint
Date: May 2, 2008 at 02:28:44 Pacific
Reply:

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.


0

Related Posts

See More



Sponsored Link
Ads by Google
Reply to Message Icon

Split a String - DOS, Bat... malloc in assembly



Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch Script Help

Batch Script Help Needed www.computing.net/answers/programming/batch-script-help-needed/14475.html

Simple Batch Script help www.computing.net/answers/programming/simple-batch-script-help/12744.html

Batch Script Help and Suggestions www.computing.net/answers/programming/batch-script-help-and-suggestions/14552.html