Running a Shell Function 
Author Message
 Running a Shell Function

Ie

Shell (" filename.exe " +Path,4)

My problem is long file names

I need the path to have a "" around it in the DOS command line call.

ie

filname.exe "C:\Program Files"

how can I make a " be part of a string or fix the above?



Sat, 21 Oct 2000 03:00:00 GMT  
 Running a Shell Function

strPath = chr(34) & "C:\Program Files" & chr(34)



Sat, 21 Oct 2000 03:00:00 GMT  
 Running a Shell Function

Jon-
        I just tried this and it even works! (;-)
Joe
___________snip__________________________
Option Explicit

Private Sub Command1_Click()
    Dim lRetVal As Long
    Dim szProgram As String
    Dim szCmd As String
    Dim Quote As String
    Quote = Chr(34)
    szProgram = "C:\Program Files\Accessories\WordPad.exe"
    szCmd = "C:\Program Files\Accessories\readme.txt"
    lRetVal = Shell(szProgram & " " & Quote & szCmd & Quote, 1)
End Sub
__________snip_______________________________
--
***********************************************************

Microsoft Developer MVP- Visual Basic
Check out Yankee Clipper Plus (April 1998
PCWorld magazine "Best Free Stuff Online")
www.tiac.net/users/lvasseur/ycphome.html
"He preaches well that lives well, quoth Sancho; that's
all the divinity I understand." Miguel de Cervantes
**********************************************************
PS- Please reply to the newsgroup- except in the
case of flames, insults, etc. (Don't bother.)



Quote:
> Ie

> Shell (" filename.exe " +Path,4)

> My problem is long file names

> I need the path to have a "" around it in the DOS command line call.

> ie

> filname.exe "C:\Program Files"

> how can I make a " be part of a string or fix the above?



Sat, 21 Oct 2000 03:00:00 GMT  
 Running a Shell Function

In Vb if you have to manage quotes (") inside a string you have to
double them.
As Vb assumes quotes as the beginning and the end of a string, when it
encounters the quotes sign (CHR$(34)) doubled it will handle this
combination as a single char.

For example you could write

Dim MyPath as String

MyPath = Chr(34) & "C:\Program Files" & CHR$(34)  'First Method
MyPath = """C:\Program Files"""  'Second method

The two methods lead to the same result. Choose the one you prefer.

Jon ha scritto:

Quote:
> Ie

> Shell (" filename.exe " +Path,4)

> My problem is long file names

> I need the path to have a "" around it in the DOS command line call.

> ie

> filname.exe "C:\Program Files"

> how can I make a " be part of a string or fix the above?

  vcard.vcf
< 1K Download


Mon, 23 Oct 2000 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Close an app running under Shell function?

2. Using the Shell function to run a program asynchronously

3. Help:Running DOS commands from SHELL function

4. Terminating a process/windows after running Shell Function

5. Shell Function not shelling under Windows NT.

6. Shell program: running IE in Shell

7. See Shell. See Shell run

8. Running Excel function from Access function/macro

9. Getting the function's name during runtime while running in the scope of the function

10. The Shell Function

11. Shell function

12. Shell Function

 

 
Powered by phpBB® Forum Software