|
-
Jan 10th, 2007, 09:20 PM
#1
Thread Starter
New Member
Shell command help
Hello all,
I am using the Shell command in VB6 to run some propriatiary dos programs on some files. For one of these programs, running the generated command string from the DOS prompt works but running that same command string with Shell dosen't work.
The following command works:
Generated string cmd =
sfconvert.exe --s2m "C:\Documents and Settings\My Name\My Documents\My Music\pddata-32007\CD Files\01 When We Dance.wav"
result = Shell(cmd, vbMinimizedNoFocus)
If result = 0 Then
MsgBox "Error: " & Format(result)
Else
hProcess = OpenProcess(&H100000, True, result)
WaitForSingleObject hProcess, -1
CloseHandle hProcess
End If
While a similar string dosen't work:
Generated string cmd =
sfcat.exe -o "C:\Documents and Settings\My Name\My Documents\My Music\pddata-32007\CD Files\left.wav" delay.wav "C:\Documents and Settings\My Name\My Documents\My Music\pddata-32007\CD Files\01 When We Dance.wav" < yes
result = Shell(cmd, vbMinimizedNoFocus)
If result = 0 Then
MsgBox "Error: " & Format(result)
Else
hProcess = OpenProcess(&H100000, True, result)
WaitForSingleObject hProcess, -1
CloseHandle hProcess
End If
This same command string works fine when executed from a dos prompt set to the VB applications runtime directory. This directory also contains the files delay.wav and yes (which is a text file) and all dos executables used. Any ideas on why this would not be working? Does it have something to do with the pipe in of the yes file?
Thanks,
Cyrus
-
Jan 11th, 2007, 04:00 AM
#2
Re: Shell command help
try
mycmd = "cmd /c sfcat.exe -o ""C:\Documents and Settings\My Name\My Documents\My Music\pddata-32007\CD Files\left.wav"" delay.wav ""C:\Documents and Settings\My Name\My Documents\My Music\pddata-32007\CD Files\01 When We Dance.wav"" < yes"
don't use cmd for your string as it is a dos command on it's own
i think i got all the quotes in the right places, also the file takes a little while before you can open it
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Jan 11th, 2007, 04:22 AM
#3
Re: Shell command help
The Shell command tends not to like long path/file names and parameters that contain spaces and *required* quotation marks. You're far better off using the ShellExecute API and building the parameter string seperately. For example:
VB Code:
Dim lngRetval As Long
Dim strParameters As String
strParameters = " /e " & Chr(34) & strFilName & Chr(34) & " " & Chr(34) & strSubKey & Chr(34)
lngRetval = ShellExecute(0&, "open", "regedit.exe", strParameters, "C:\", SW_HIDE)
EDIT: or use the GetShortPathName API.
Last edited by schoolbusdriver; Jan 11th, 2007 at 04:35 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|