Link to home
Start Free TrialLog in
Avatar of petershaw8
petershaw8

asked on

problem about batch file and DOS window

Hi,
My program call a batch file at runtime.
The batch file like:

D
cd D:\Delphi
someapplication parameter
ren *.abc *.edf

The question is
1)
After I call the batch file, I found the *.abc files didn't renamed to *.edf files. The *.abc are in the D:\Delphi dir.

2)
I used to be able to see the DOS window after called and executed the batch file, but now I  could not to see it because it auto closed after running the batch file.


Peter
Avatar of kretzschmar
kretzschmar
Flag of Germany image

to 1.

D:     <- look at the :
cd D:\Delphi
someapplication parameter
ren *.abc *.edf

if someapplication also a batchfilr then use
call someapplication parameter

to 2.

use winexec

meikl ;-)
appendix to 1

D:     <- look at the :
cd \Delphi    <- no drive char
someapplication parameter
ren *.abc *.edf

Also, if you want to see the window, add the command "pause" as the very last one. This will wait for a keypress after the batch file was processed.
Don't use WinExec since it's not supported anymore with Windows XP!

I repeat: Don't use WinExec since it's not supported anymore with Windows XP!
Avatar of petershaw8
petershaw8

ASKER

Hi,
D:
cd D:\Delphi
someapplication parameter
ren *.abc *.edf
Pause

I add the pause at the end.
The ren not works and the DOS window still shut down automatically.

peter
One tip... Why not use this:

D:
cd D:\Delphi
someapplication parameter
ren D:\Delphi\*.abc *.edf
Pause

The Rename command doesn't move files to another folder. It just renames the files. I think that someapplication changes the current folder before the batch file returns.
Concerning the REN, place the path in front of the *.abc as shown below. If this does not work there is something very strange going on.

D:
cd D:\Delphi
someapplication parameter
ren D:\Delphi\*.abc *.edf
Pause


Concerning the PAUSE not working, try creating a shortcut for the batch file, in the property window try unchecking the "Close windows when finished" so that even if there is no PAUSE the window will stay open. If this helps then you could change the batch file to

@Echo Off
cls
D:
cd D:\Delphi
someapplication parameter
ren D:\Delphi\*.abc *.edf
Pause
cls

Usually the last cls will force a closing of the window. The secert is the first two lines.

Hope this helps




Hi,

Thank u for your help.
I will test the code below although I know someapplication does not change dir.

D:
cd D:\Delphi
someapplication parameter
ren D:\Delphi\*.abc *.edf

In window 2000 proessional, I could not find the "Close windows when finished"  option. In window 98 I delete the shortcut file *.pif, but the window was still auto closed. By the way, now how can I make the shortcut for the batch window?

Peter
Er.... Try this:

@Echo Off
cls
D:
cd D:\Delphi
call someapplication parameter
ren D:\Delphi\*.abc *.edf
Pause
cls
ASKER CERTIFIED SOLUTION
Avatar of gallaghe
gallaghe
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial