How do I call a DOS .bat-file from a pascal program? "Exec()" doesn't seem to support this. 
Author Message
 How do I call a DOS .bat-file from a pascal program? "Exec()" doesn't seem to support this.

Hello,

I am trying to call a DOS batch-file from a Pascal program.
exec('test.bat', '') doesn't work for some reason.

It generates an error message "- is not a valid command, external
command, program or command file" (translated from Swedish Windows XPPro
command window). And yes, it really writes out the "-", I can't
understand what that means.

What is wrong - how could I run a .bat file with Pascal code? Is there
some workaround?

Regards Carl-Jonas Wernhoff



Tue, 25 Oct 2005 21:57:25 GMT  
 How do I call a DOS .bat-file from a pascal program? "Exec()" doesn't seem to support this.


Wed, 18 Jun 1902 08:00:00 GMT  
 How do I call a DOS .bat-file from a pascal program? "Exec()" doesn't seem to support this.

Quote:

> Hello,

> I am trying to call a DOS batch-file from a pascal program.
> exec('test.bat', '') doesn't work for some reason.

Of course not: bat-files are not executable. It's your shell that
interprets bat-files. Therefore you have to execute your shell.

Exec(GetEnv('COMSPEC'),'/c test.bat');

GetEnv('COMSPEC') returns the path to your command.com/cmd.exe or
whatever.

Wolf



Tue, 25 Oct 2005 22:10:39 GMT  
 How do I call a DOS .bat-file from a pascal program? "Exec()" doesn't seem to support this.

Quote:


>>Hello,

>>I am trying to call a DOS batch-file from a pascal program.
>>exec('test.bat', '') doesn't work for some reason.

> Of course not: bat-files are not executable. It's your shell that
> interprets bat-files. Therefore you have to execute your shell.

> Exec(GetEnv('COMSPEC'),'/c test.bat');

That did it, thanks!


Tue, 25 Oct 2005 23:24:45 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Calling dos services "problem"

2. LAST CALL: postdoc "Intentional Programming"

3. The keys "-"/"+"/"*"

4. Calling "C LIB" from Turbo Pascal

5. HELP : "Invalid Paramater", when doing Tquery.Open, seems to not release resources

6. "Structured Programming in Turbo Pascal"

7. EOleSysError: "CoInitialize has not been called"

8. ""256 Color Mouse""

9. Creating executable file + file handling "objects"

10. "Binding" Executables for DOS and Windows

11. Prob: FPC Installation on "DOS 7"

12. Linking DOS "C" libraries with BP

 

 
Powered by phpBB® Forum Software