Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > Still stuck in shell (program file)


Reply
 
Thread Tools Display Modes
  #1  
Old 03-27-2005, 06:39 PM
odehmohd odehmohd is offline
Freshman
 
Join Date: Sep 2004
Location: JOR
Posts: 25
Default SHELL NOT paths+spaces


Dear friends,
When using Shell command to open a file with a program rather than the associated one we use
Shell "%path%\program.exe %path%\file.xyz"

This command wont work if the file path contain spaces such as "d:\New Folder\file.xyz" any body can help?!??!?
Thank u
Moh'd I. Odeh
Reply With Quote
  #2  
Old 03-27-2005, 06:48 PM
OnErr0r's Avatar
OnErr0r OnErr0r is offline
Obsessive OPtimizer

Administrator
* Guru *
 
Join Date: Jun 2002
Location: Debug Window
Posts: 13,688
Default

Wrap the string you pass to the Shell Function in quotes, then the spaces will be handled correctly.
__________________
Quis custodiet ipsos custodues.
Reply With Quote
  #3  
Old 03-27-2005, 07:11 PM
odehmohd odehmohd is offline
Freshman
 
Join Date: Sep 2004
Location: JOR
Posts: 25
Default

didnt work!
Shell "d:\windows\system32\mspaint.exe D:\Documents and Settings\Moh'd.ABUALOUD\My Documents\image\1.bmp"
Reply With Quote
  #4  
Old 03-27-2005, 07:22 PM
NEOLLE's Avatar
NEOLLE NEOLLE is offline
fully realized avatar

Super Moderator
* Expert *
 
Join Date: Jun 2004
Location: Davao Philippines
Posts: 2,295
Smile

Hi odehmohd,
Try
Code:
Shell ("d:\windows\system32\mspaint.exe ""D:\Documents and Settings\Moh'd.ABUALOUD\My Documents\image\1.bmp")
Reply With Quote
  #5  
Old 03-27-2005, 07:34 PM
dcbasic dcbasic is offline
Junior Contributor
 
Join Date: Jun 2003
Posts: 261
Default

Never tried open a file with a specified program, but wouldn't you need to use Chr(34) to return a quote?

Something like Msgbox(Chr(34) & "Hello world!" & Chr(34)) would give you "Hello world!".

So I assume this would work:
Code:
Shell(Chr(34) & "c:\prog.exe" & Chr(34) & " " & Chr(34) & "c:\file.txt" & Chr(34))

Hope that helps.

Last edited by dcbasic; 03-27-2005 at 07:43 PM.
Reply With Quote
  #6  
Old 03-27-2005, 07:38 PM
odehmohd odehmohd is offline
Freshman
 
Join Date: Sep 2004
Location: JOR
Posts: 25
Default

Gr8,
Thank u OnError
Thank u Neolle
Reply With Quote
  #7  
Old 03-27-2005, 07:38 PM
Aseen Aseen is offline
Junior Contributor
 
Join Date: Feb 2005
Location: Philippines
Posts: 305
Default

Quote:
Originally Posted by dcbasic
Never tried open a file with a specified program, but wouldn't you need to use Chr(34) to return a quote?

Something like Msgbox(Chr(34) & "Hello world!" & Chr(34)) would give you "Hello world!".
yep, you can do that
but you can also do this Msgbox("""Hello world!""")
Reply With Quote
  #8  
Old 03-27-2005, 07:44 PM
dcbasic dcbasic is offline
Junior Contributor
 
Join Date: Jun 2003
Posts: 261
Default

Quote:
Originally Posted by Aseen
yep, you can do that
but you can also do this Msgbox("""Hello world!""")
Thanks for the tip! Typing Chr(34) gets tiresome!
Reply With Quote
  #9  
Old 03-28-2005, 11:19 AM
odehmohd odehmohd is offline
Freshman
 
Join Date: Sep 2004
Location: JOR
Posts: 25
Default Still stuck in shell (program file)

A=”d:\windows\sytem32\mspaint.exe”
B=”d:\documents and setting\a.bmp”
C= A & “ “ & B
Shell C ‘this command cannot handle spaces in D string correctly as:

Shell ”d:\windows\sytem32\mspaint.exe ””d:\documents and setting\a.bmp”
any one help?
Moh'd I. Odeh
Reply With Quote
  #10  
Old 03-28-2005, 11:25 AM
OnErr0r's Avatar
OnErr0r OnErr0r is offline
Obsessive OPtimizer

Administrator
* Guru *
 
Join Date: Jun 2002
Location: Debug Window
Posts: 13,688
Default

You thanked us, but apparently didn't take the advice of wrapping the strings in quotes.
__________________
Quis custodiet ipsos custodues.
Reply With Quote
  #11  
Old 03-28-2005, 02:50 PM
odehmohd odehmohd is offline
Freshman
 
Join Date: Sep 2004
Location: JOR
Posts: 25
Default

I did it man,,,,,
Thank u again
Moh'd I. Odeh
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->