Bad Command or File name when Shelling DOS Batch File 
Author Message
 Bad Command or File name when Shelling DOS Batch File

I am trying to write a "simple" program as a front end to a DOS batch file.  
Basically it uses drive, directory and file boxes to get the name of a file to
convert from postscript to PDF using the GhostScript 5.50  ps2pdf.bat batch.  
the idea is to save having to type long path and file names.

I am using VB 3.0 and Windows 95 and the program seems to generate the correct
command line because I can paste it into the Win95 "RUN" window and it works
correctly.

The command I execute is:

x = Shell("c:\gstools\gs5.50\ps2pdf.bat c:\mydocu~1\sdfler5.ps  
c:\mydocu~1\sdfler5.pdf", 1)

Running this produces a "Bad Command or File Name Error" at the point the
batch tries to execute the command.

I tried the same thing in Qbasic with the same results.

Does anyone have any ideas??

Lloyd



Fri, 22 Jun 2001 03:00:00 GMT  
 Bad Command or File name when Shelling DOS Batch File
If it's IN the batch file, you might need to set the Curdir$ first?

(CHDRIVE, CHDIR)

Batch file should use;

Myprog.exe %1

Where %1 is the parameter (command$)
Extendend parameters;

Myprog.exe %1 %2 etc...

Quote:

>I am trying to write a "simple" program as a front end to a DOS batch file.
>Basically it uses drive, directory and file boxes to get the name of a file
to
>convert from PostScript to PDF using the GhostScript 5.50  ps2pdf.bat
batch.
>the idea is to save having to type long path and file names.

>I am using VB 3.0 and Windows 95 and the program seems to generate the
correct
>command line because I can paste it into the Win95 "RUN" window and it
works
>correctly.

>The command I execute is:

>x = Shell("c:\gstools\gs5.50\ps2pdf.bat c:\mydocu~1\sdfler5.ps
>c:\mydocu~1\sdfler5.pdf", 1)

>Running this produces a "Bad Command or File Name Error" at the point the
>batch tries to execute the command.

>I tried the same thing in Qbasic with the same results.

>Does anyone have any ideas??

>Lloyd



Sat, 23 Jun 2001 03:00:00 GMT  
 Bad Command or File name when Shelling DOS Batch File

Quote:

>x = Shell("c:\gstools\gs5.50\ps2pdf.bat c:\mydocu~1\sdfler5.ps  
>c:\mydocu~1\sdfler5.pdf", 1)

>Running this produces a "Bad Command or File Name Error" at the point the
>batch tries to execute the command.

  The "Bad Command or Filename" is a DOS error message, which means that
the Shell statement does execute your batch file. The problem is this:
if you execute a command from the Start->Run dialog, Windows sets the
current drive/directory to the one the executable (or, in your case,
batch file) resides in. The VB Shell statement does no such thing. As a
result, when the batch file tries to execute ghostscript, it can't find
it. The solution therefore is: change drive and directory to those of
the program you want to execute before you run the Shell statement.

Gertjan.



Thu, 28 Jun 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Close DOS Batch File after Shell Command

2. Detecting end of shelled MS-DOS batch file

3. Help with DOS shells under Win 95 (batch files)

4. Running a batch file using Shell command

5. Shelling to a Batch file with 2 command line arguments

6. DOS Batch File to Copy Files from an Access Application

7. Api function to convert Long File Names To Short Dos File Names

8. How can i truncate long file name to get dos file name

9. Help: hiding a DOS window when executing a DOS batch file

10. question on hiding a DOS window when executing a DOS batch file

11. shell command with space in path/file name does not work

12. shell command with space in path/file name does not work

 

 
Powered by phpBB® Forum Software