-
May 24th, 2001, 03:55 AM
#1
Shell command
I am running a VB prog in a folder with two-word name (something like "My Folder").
When I use the shell command with App.Path :
Shell(App.Path + "\data\my_exe.exe" I have the problem that
c:\My Folder\data\my_exe.exe can not be executed.
Instead you have to type :
c:\"My Folder"\data\my_exe.exe
How can I solve this problem?
Thanks
-
May 24th, 2001, 04:24 AM
#2
Re: Shell command
Hello,
Try
Shell("""" & App.Path + "\data\my_exe.exe"""
The result will be
"c:\my folder\data\my_exe.exe"
Bye
Peter
-
May 24th, 2001, 04:25 AM
#3
Re: Shell command
Hello,
I am not sure if this will work....but you could try:
shell ("'" & App.path & "\data\my_exe.exe & "'");
This would encase the whole string in single quotes, hopefully removing the problem. Or I could just be talking rubbish :-)
-
May 24th, 2001, 04:49 AM
#4
Re: Shell command
You canalso use short file name (dos format). Have a look at getshortpathname api
ie:
Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal lBuffer As Long) As Long
Public Function GetShortPath(strFileName As String) As String
'KPD-Team 1999
'URL: http://www.allapi.net/
'E-Mail: KPDTeam@Allapi.net
Dim lngRes As Long, strPath As String
'Create a buffer
strPath = String$(165, 0)
'retrieve the short pathname
lngRes = GetShortPathName(strFileName, strPath, 164)
'remove all unnecessary chr$(0)'s
GetShortPath = Left$(strPath, lngRes)
End Function
Private Sub Form_Load()
MsgBox GetShortPath("c:\Program Files\")
End Sub
Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, Bruno Paris and all the other wonderful people who made and make Codeguru a great place. Come back soon, you Gurus.
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
-
May 24th, 2001, 01:00 PM
#5
Re: Shell command
This is wierd. I tried this on mine where I have RGB.EXE in App.Path and my App.Path evaluates to E:\Projects\VB\RGB Generator. Calling Shell(App.Path & "\RGB.EXE") works fine for me. Does it have anything to do with OS? I'm using WIN2K so have not tested this with Win9x.
-Cool Bizs
Good Luck,
-Cool Bizs
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
|