.bat File Help


Recommended Posts

ZippyDo    0

Can someone tell me why this is not working.... Heres the code, in case the .bat doesn't make it

ren C:\Program Files\DP Desktop\DPDeskTop.exe DPDeskTop.ex_

Pause

Copy x:\DDR\Public\DPDesktop.exe C:\Program Files\DP Desktop\DPDeskTop.exe

pause

Says "Invalid Syntax"

Thanks

Link to post
Share on other sites
ilmcuts    0

parameters are separated by a space unless you put quotes around it... ie. in the first line you give ren four parameters instead of two, same in the third line (copy). Haven't tested this but i think it should work:

ren "C:\Program Files\DP Desktop\DPDeskTop.exe" DPDeskTop.ex_

Pause

Copy x:\DDR\Public\DPDesktop.exe "C:\Program Files\DP Desktop\DPDeskTop.exe"

pause

Link to post
Share on other sites
ZippyDo    0

Another quick question, is there a way to report an error and abort if the file is not initially found in the first line? On Abort, I would like it to say "the program appears to not be found on this system", pause, then exit.... :blink: Would also like to add a brief description line at the beginning that just displays text and asks if you would like to continue with the upgrade....

Thanks

Link to post
Share on other sites
hurting101    0

Yup:

if not exist "C:\Program Files\DP Desktop\DPDeskTop.exe" (

echo.The program appears to not be found on this system&pause>nul&goto:eof)

Also, you can add @echo off to the beginning of the file to make it stop reading out each line.

As for the upgrade thing, you can use echo and pause like this:

echo Welcome to my installation

echo Press any key to continue with installation

pause>nul

Link to post
Share on other sites
ilmcuts    0

if exist "c:\program files\someprogram\app.exe" goto exists

echo File doesn't exist

pause

goto exit

:exists

echo File exists

rem *** etc. ***

:exit

sth like that?

for the choice thingy... from DOS 5.0 or 6.0 on there was choice.com (or was it .exe?) that you could use with if errorlevel, ie. it's also included in win9x; but i don't think NT supports it. SET took over this job iirc. check its command line help (set /?)

Link to post
Share on other sites
ZippyDo    0

Man thanks guys, I am really close, have just one more thing:

Heres where I am:

@echo Welcome to the Datapass Upgrade for Nov 2002

@echo Press any key to begin the upgrade process

if exist "c:\program files\DP Desktop\DPDesktop.exe" goto exists

@echo It appears that Datapass is not installed on this system

pause

goto exit

:exists

ren "C:\Program Files\DP Desktop\DPDeskTop.exe" DPDeskTop.ex_

Pause

Copy x:\DDR\Public\DPDesktop.exe "C:\Program Files\DP Desktop\DPDeskTop.exe"

pause

:exit

Runs and exits appropriately, but after the first two lines are displayed, It lists this:

X:\DDR\Public>if exist "c:\program files\DP Desktop\DPDesktop.exe" goto exists

It appears that Datapass is not installed on this system

X:\DDR\Public>Pause

Press any key to continue ...

Just like that! Is there a way to remove the top part, and only display the text lines below it?

Thanks one last time.... :cry:

Link to post
Share on other sites
hurting101    0

Yes. As mentioned above, just add @echo off to the beginning of the file. Also, if you use @echo off, you don't need to put the @ sign infront of every echo.

Link to post
Share on other sites
ZippyDo    0

Man, you guys are good....Really enjoy and appreciate the help...Can you tell me if it's possible to perform a search of the "C" drive looking for the particular file and then "ren" all of the instances of file, then copying the new file into their folders......

Link to post
Share on other sites
ilmcuts    0

from the "for" command line help (for /?):

FOR /R [[drive:]path] %variable IN (set) DO command [command-parameters]

   Walks the directory tree rooted at [drive:]path, executing the FOR

   statement in each directory of the tree.  If no directory

   specification is specified after /R then the current directory is

   assumed.  If set is just a single period (.) character then it

   will just enumerate the directory tree.

I dunno what you mean with "their folders" but for the rest this should work:

for /R c:\ %%a in (.) do if exist %%a\myfile.ext ren %%a\myfile.ext newname.txt

note that it might take a long time for this statement to complete. it's the best solution i could come up with right now, though there are probably better and faster ones (possibly involving dir /b and a temporary file or some other, probably nested, "for" statements).

Link to post
Share on other sites
hurting101    0
Can you tell me if it's possible to perform a search of the "C" drive looking for the particular file and then "ren" all of the instances of file, then copying the new file into their folders......

I wouldn't recommend this for two reasons:

1) It's slow! Do a dir/b/s \ in command prompt and see what I mean.

2) If they have another unrelated file named with the name you're searching for and you rename it, it could ruin something

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.