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: Stefan Wuebbe
  Where is Stefan Wuebbe?
 Hamburg
 Germany
 Stefan Wuebbe
 Tags
Subject: RE: Using WScript.Shell to run a program
Thread ID: 365695 Message ID: 365700 # Views: 35 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: Classes and Objects
Date: Sunday, December 30, 2012 2:24:54 PM         
   


Thanks Stefan!

It worked fine.

Just a question: as my program will exectute this code snipet over and over, it is not a problem to DECLARE INTEGER ShellExecute many times?

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,
> >
>
> Hi Fernando,
>
> I'd try "quoting the quotation marks", e.g.
>
> cParameters = '"c:\temp\My_Spreadsheet.xls" "c:\temp\Another_Spreadsheet.xls"'
> 

>
> And would prefer to use the WinAPI directly rather than an optional add-on like WSH which can get uninstalled by client-PC admins, and might probably be doing the same internally:
>
>
> DECLARE INTEGER ShellExecute ;
> 	IN SHELL32.DLL ;
> 	INTEGER nWinHandle, ;
> 	STRING cOperation, ;
> 	STRING cFileName, ;
> 	STRING cParameters, ;
> 	STRING cDirectory, ;
> 	INTEGER nShowWindow
> ShellExecute( 0, "open", "D:\temp\test.exe", '"parameter 1" "parameter 2"', "",1 )
> 

>
>
>
>
> hth
> -Stefan

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