Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Don't close DOS-box

Status
Not open for further replies.

speek

Technical User
Mar 29, 2008
25
US
I'm trying to modify a vbscript for the MPEGplus audio encoder (something like MP3). I have the script on the desktop and when I drag-'n-drop wav files on it they get automatically compressed. Only thing is that the DOS-box closes immediately after the encoding is finished. But I don't want it to get closed automatically. This is the vbscript I use:

------------------------------------------------
' *** change path to your needs ***
path = "C:\Progs\Encoders\MP+\"
mppenc = "mppenc.exe"

' *** change default options to your needs ***
opts = "-forcewrite"






' no changes needed below this line
' #############################################
Dim wsh, args, infile, fs
title="MPEGplus Script"

' get input files
Set wsh = WScript.CreateObject("WScript.Shell")
Set args = WScript.Arguments
If args.Count = 0 Then
MsgBox "Please use drag & drop to specify input files.", vbInformation, title
WScript.Quit
End If

' check path
Set fs = CreateObject("Scripting.FileSystemObject")
If Not fs.FileExists(path & mppenc) Then
wsh.Popup "Could not find mppenc!" & vbCR & "(looked for '" & mppenc & "')", ,title, 16
WScript.Quit
End If

'process files
For i = 0 To args.Count-1
infile = args(i)
' check input file
If Not fs.FileExists(infile) Then
wsh.Popup "Error opening input-file" & vbCR & "'" & infile & "'", ,title, 16
Else
' run mppenc
ret = wsh.Run(CHR(34) & path & mppenc & CHR(34) & Chr(32) & Chr(34) & _
infile & Chr(34) & Chr(32) & opts, 1, True)

' diagnostics
Select Case ret
Case (-1)
MsgBox "mppenc aborted by user!", vbExclamation, title
Case (1)
MsgBox "Error returned by mppenc!" & vbCR & "(Check mppenc options and input file formats.)" & vbCR & "Used Options: " & opts, vbCritical, title
Case Else
Rem ignore
End Select
End If
Next

WScript.Quit
-----------------------------------------------------

So my question is: what must be changed to prevent the DOS-box from automaticaly closing? The OS is Win2k.

Thanx for your help!
Speek
 

Speek,

Put this in your wsh.run command. This open a DOS window and keeps it open.

"cmd /K "

Fengshui1998
 
FengShui1998,

Thanx for your answer. I still have problems to get it working properly. The new wsh.Run command looks like this:

wsh.Run("cmd /K " & Chr(34) & Chr(34) & path & mppenc & Chr(34) & Chr(32) & Chr(34) & infile & Chr(34) & Chr(32) & opts & Chr(34), 1, True)

The rest of the script is unchanged. The problem now is that it doesn't go on with the next file until I close the DOS window.

And there's something else I would want to change. I would like it if all files were processed (encoded) in the same DOS window. Would that be possible?

Any suggestions are much appreciated :)

Speek
 
Speek,

I know you're writing double quotes to the string but can't really see the total string before it's executed. Try writing the string first to see what you are executing.

If your are still having trouble, include it in a reply.


Fengshui1998
 
FengShui1998,

The command line is: cmd /K ""path\mppenc" "infile" options"
cmd /K means: open DOS window, execute string, don't close dos window. That's fine, but why is the next file not being processed?

Even nicer would it be if the second (and following) file(s) would be processed in the DOS window that's already open. But I've no clue how to achieve that.

Regards,
Speek
 


Speek,

It appears to be your quote marks. If you use double quotes in a quoted string, then double the double quotes is the rule. Your string should look like:

cmd /K """path\mppenc"" ""infile"" options"

Fengshui1998
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top