Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Fernando Alvares
  Where is Fernando Alvares?
 Porto Alegre
 Brazil
 Fernando Alvares
 To: Glen Villar
  Where is Glen Villar?
 Palayan City
 Philippines
 Glen Villar
 Tags
Subject: RE: Using WScript.Shell to run a program
Thread ID: 365695 Message ID: 365699 # Views: 41 # Ratings: 1
Version: Visual FoxPro 9 SP2 Category: Classes and Objects
Date: Sunday, December 30, 2012 2:17:37 PM         
   


Thanks Glen!

cParameters = '"My Spreadsheet.xls"' + '"c:\temp\Another Spreadsheet.xls"'

Worked fine.

Regards,

Fernando

> > Hi,
> >
> > I want to run programs via the WScript.Shell and, optionally, pass a parameter list, like below.
> >
> >
> > cProgram    = "excel.exe"
> > cParameters = "c:\temp\My_Spreadsheet.xls c:\temp\Another_Spreadsheet.xls"
> > 
> > oShell = createobject("WScript.Shell")
> > oShell.Run (cProgram + " " + cParameters,,.T.)
> > 

> > The above example runs OK, the problem is that, when a parameter contains embedded spaces, like below, Excel gives an error message.
> >
> >
> > cParameters = "c:\temp\My Spreadsheet.xls c:\temp\Another Spreadsheet.xls"
> > 

> > How can I pass a parameter list, to WScript.Shell, where some of the parameters may contain embedded spaces?
> >
> > Thanks,
> >
> > Fernando
>
> Hi,
>
> Just put another pair of single quote to enclose your original string.
>
>
> cProgram    = "excel.exe"
> cParameters = '"c:\temp\Another Spreadsheet.xls"'
> oShell = createobject("WScript.Shell")
> oShell.Run (cProgram + " " + cParameters,,.T.)
> 

>
> Regards
>
> (coffee)
> It's never too late to be who you might have been.
> -George Eliot. English Novelist (1819-1880)
>

> http://thereportersassistant.blogspot.com
> http://fruitypc.blogspot.com

ENTIRE THREAD

Using WScript.Shell to run a program Posted by Fernando Alvares @ 12/30/2012 1:25:57 PM
RE: Using WScript.Shell to run a program Posted by Glen Villar @ 12/30/2012 1:34:52 PM
RE: Using WScript.Shell to run a program Posted by Fernando Alvares @ 12/30/2012 2:17:37 PM
RE: Using WScript.Shell to run a program Posted by Stefan Wuebbe @ 12/30/2012 1:43:01 PM
RE: Using WScript.Shell to run a program Posted by Fernando Alvares @ 12/30/2012 2:24:54 PM
RE: Using WScript.Shell to run a program Posted by Stefan Wuebbe @ 12/30/2012 8:45:18 PM
RE: Using WScript.Shell to run a program Posted by Fernando Alvares @ 12/30/2012 2:47:54 PM