mossmis
asked on
VB6 Run-time error '5' when calling shell
I get this error from VB6 when calling this line:
Run-time error '5'
GetApp = Shell(App.Path & "\updateapp.bat", vbNormalNoFocus)
I do not see any setfocus in my code that I usually see through this error. This code does work by the way in a clean project with noting else.
Any suggestions?
Run-time error '5'
GetApp = Shell(App.Path & "\updateapp.bat", vbNormalNoFocus)
I do not see any setfocus in my code that I usually see through this error. This code does work by the way in a clean project with noting else.
Any suggestions?
Does your App.Path contain spaces?
--
Chris
--
Chris
ASKER
Chris, the app.path does contain spaces. But this works when I isolate the code in a new project with just that command. I'm not sure what else might be causing the error.
Can you post the code (at least the full subroutine which has the offending line in it)?
ASKER
Public Sub UpdateCurrentApp()
'If the App version doesn't match automatically update the app
Dim fso As New FileSystemObject
If Not fso.FileExists(App.Path & "\updateapp.bat") Then
fso.CreateTextFile "updateapp.bat"
End If
Open App.Path & "\errors.txt" For Output As #1
Print #1, "ECHO Please Wait.....Automatically Updating to New Version"
Print #1, "Timeout 5"
Print #1, "%~d1"
Print #1, "cd ""%~p1"""
Print #1, "copy /y """; UpdateAppFolder; UpdateAppEXE; """"; " "; UpdateAppEXE
Print #1, "Timeout 1"
Print #1, "start "; UpdateAppEXE
Print #1, "exit"
Close #1
GetApp = Shell(App.Path & "\updateapp.bat", vbNormalNoFocus)
End
End Sub
Quote-delimit the path/filename:
GetApp = Shell(Chr(34) & App.Path & "\updateapp.bat" & Chr(34), vbNormalNoFocus)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
No. You should use a quote delimiter.
@aikmark
actually, it should be Chr(32), which is the character code for a SPACE and not Chr(34), which is the character code for a double quote (")
No. You should use a quote delimiter.
Yes, that's right. My bad. I forgot that referencing a directory that has space in it must be enclosed by double quotes.
ASKER
Son of a........... line 9 had a bad file name (I copied code from another project of mine). That little thing fixed it. I didn't need to add extra quotes; I took care of it in line 14.
Thanks for catching that mistake.
Thanks for catching that mistake.
ASKER
jkaios caught my mistake. Why isn't he getting the points?
How is your current setup not clean?