Alaska Software Inc. - Runsheell() quesstion
Username: Password:
AuthorTopic: Runsheell() quesstion
Toma GromRunsheell() quesstion
on Mon, 24 Jul 2006 12:53:51 +0200
Below is the code, that tryes to start MS Word within xBase++.

The problem is, that the code, which is marked, works, and the code (first 
line), that is unmarked, does not work.
First line has no path to the desired executable, on the other hand other 
lines has it and trying to find that file in different places depending on 
the operating system.
The difficultie is, that if user install for example MS Office to any other 
part of the HDD, even that code does not work any more.

Conclusion:
Within (WindowsXP -> Start -> Run) window 'WINWORD" starts without any 
problem, but within xBase RunShell() does not.
Why is that so?
Is there any cure for that ?

Best regards

Toma

  RunShell( cFile, "WINWORD.EXE", lAsync )

 DO CASE
 CASE FILE("C:\Program Files\Microsoft Office\Office11\WINWORD.EXE")
  RunShell( cFile, "C:\Program Files\Microsoft 
Office\Office11\WINWORD.EXE", lAsync )
 CASE FILE("C:\Program Files\Microsoft Office\Office10\WINWORD.EXE")
  RunShell( cFile, "C:\Program Files\Microsoft 
Office\Office10\WINWORD.EXE", lAsync )
 CASE FILE("C:\Program Files\Microsoft Office\WINWORD.EXE")
  RunShell( cFile, "C:\Program Files\Microsoft Office\WINWORD.EXE", 
lAsync )
 OTHERWISE
  OPOZORILO( , "Can not find the program WinWord.exe!",3)
  lVrni := .F.
 ENDCASE
Toma GromRe: Runsheell() quesstion
on Mon, 24 Jul 2006 12:55:35 +0200
Sorry, I mooved that question to the xBase++ generc thread ...
James Loughner Re: Runsheell() quesstion
on Mon, 24 Jul 2006 11:16:45 -0400
Did you try START Winword.exe???

Can you start it from a command shell??

Jim

Toma¾ Grom wrote:
> Below is the code, that tryes to start MS Word within xBase++.
> 
> The problem is, that the code, which is marked, works, and the code (first 
> line), that is unmarked, does not work.
> First line has no path to the desired executable, on the other hand other 
> lines has it and trying to find that file in different places depending on 
> the operating system.
> The difficultie is, that if user install for example MS Office to any other 
> part of the HDD, even that code does not work any more.
> 
> Conclusion:
> Within (WindowsXP -> Start -> Run) window 'WINWORD" starts without any 
> problem, but within xBase RunShell() does not.
> Why is that so?
> Is there any cure for that ?
> 
> Best regards
> 
> Toma¾
> 
>   RunShell( cFile, "WINWORD.EXE", lAsync )
> 
>  DO CASE
>  CASE FILE("C:\Program Files\Microsoft Office\Office11\WINWORD.EXE")
>   RunShell( cFile, "C:\Program Files\Microsoft 
> Office\Office11\WINWORD.EXE", lAsync )
>  CASE FILE("C:\Program Files\Microsoft Office\Office10\WINWORD.EXE")
>   RunShell( cFile, "C:\Program Files\Microsoft 
> Office\Office10\WINWORD.EXE", lAsync )
>  CASE FILE("C:\Program Files\Microsoft Office\WINWORD.EXE")
>   RunShell( cFile, "C:\Program Files\Microsoft Office\WINWORD.EXE", 
> lAsync )
>  OTHERWISE
>   OPOZORILO( , "Can not find the program WinWord.exe!",3)
>   lVrni := .F.
>  ENDCASE 
> 
> 
> From - Mon
Igor FERKRe: Runsheell() quesstion
on Thu, 27 Jul 2006 09:04:17 +0200
Hi Toma,
I think it's "path" problem (spaces) ...
Try folowing (double quote):
  RunShell( cFile, '"C:\Program Files\Microsoft 
Office\Office11\WINWORD.EXE"', lAsync )

Or eaven better - chek "who" open ".doc" from registry
            HKEY_CLASSES_ROOT\***filetype***file\shell\open\command
or you can find something better 

And maybe the best (?) solution :
simply use
  ShellOpenFile('c:\path\example.doc') - it will open file with registered 
application.

[CODE] - can't remember the author 
/*
  Use the shell function to display a document
  
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/functions/shellexecute.asp
 */
#define SW_HIDE             0
#define SW_NORMAL           1
#define SW_SHOWMINIMIZED    2
#define SW_SHOWMAXIMIZED    3
#define SW_MAXIMIZE         3
#define SW_SHOWNOACTIVATE   4
#define SW_SHOW             5
#define SW_MINIMIZE         6
#define SW_SHOWMINNOACTIVE  7
#define SW_SHOWNA           8
#define SW_RESTORE          9
#define SW_SHOWDEFAULT      10


PROCEDURE ShellOpenFile( cFile, hWnd, lpOperation, lpParameters, 
lpDirectory, nShowCmd)
DEFAULT hWnd         TO AppDesktop():GetHWND()  && Parent window handle ...
DEFAULT lpOperation  TO "open"                  && Operacija
DEFAULT lpParameters TO NIL                     && Parametri
DEFAULT lpDirectory  TO CurDir()
DEFAULT nShowCmd     TO SW_SHOWDEFAULT

   DllCall( "SHELL32.DLL"  , DLL_STDCALL, ;
            "ShellExecuteA", hWnd , lpOperation, cFile, ;
            lpParameters, lpDirectory, nShowCmd )
RETURN
[OF CODE]

Regards,
Igor

"Toma Grom" <tomaz.grom@siol.net> je napisal v sporoilo 
news:49041db5$6c9a91d7$1e3ed@news.alaska-software.com ...
> Below is the code, that tryes to start MS Word within xBase++.
>
> The problem is, that the code, which is marked, works, and the code (first 
> line), that is unmarked, does not work.
> First line has no path to the desired executable, on the other hand other 
> lines has it and trying to find that file in different places depending on 
> the operating system.
> The difficultie is, that if user install for example MS Office to any 
> other part of the HDD, even that code does not work any more.
>
> Conclusion:
> Within (WindowsXP -> Start -> Run) window 'WINWORD" starts without any 
> problem, but within xBase RunShell() does not.
> Why is that so?
> Is there any cure for that ?
>
> Best regards
>
> Toma
>
>  RunShell( cFile, "WINWORD.EXE", lAsync )
>
>  DO CASE
>  CASE FILE("C:\Program Files\Microsoft Office\Office11\WINWORD.EXE")
>   RunShell( cFile, "C:\Program Files\Microsoft 
> Office\Office11\WINWORD.EXE", lAsync )
>  CASE FILE("C:\Program Files\Microsoft Office\Office10\WINWORD.EXE")
>   RunShell( cFile, "C:\Program Files\Microsoft 
> Office\Office10\WINWORD.EXE", lAsync )
>  CASE FILE("C:\Program Files\Microsoft Office\WINWORD.EXE")
>   RunShell( cFile, "C:\Program Files\Microsoft Office\WINWORD.EXE", 
> lAsync )
>  OTHERWISE
>   OPOZORILO( , "Can not find the program WinWord.exe!",3)
>   lVrni := .F.
>  ENDCASE
>
Toma GromRe: Runsheell() quesstion
on Mon, 28 Aug 2006 07:51:19 +0200
Hvala, Igor !
Richard PulliamRe: Runsheell() quesstion
on Mon, 25 Jun 2007 14:47:03 -0500
Hered is my adapted solution from some of my code:


FUNCTION MSWord(cFile)
LOCAL   cWordExe:=FindMSWord(), cCommand, aInfo, cTrash:="C:\_TRASH_.TXT",;
i, nLen, cFile

IF EMPTY(cWordExe)
   FERASE(cTrash)
   cCommand:="/C DIR /B/S WINWORD.EXE > "+cTrash
   RUNSHELL(cCommand,,FALSE,TRUE)
   aInfo:={}
   IF FILE(cTrash) .AND. LEN(MEMOREAD(cTrash))>10  10 IS REASONABLE SIZE?
      aInfo:=File2Array(cTrash)
   ENDIF
   IF (nLen:=LEN(aInfo))>0
      FOR i:=1 TO nLen
         cFile:=ALLTRIM(aInfo[i])
         IF FILE(cFile)
            cWordExe:=cFile
            EXIT
         ENDIF
      NEXT
   ENDIF
ENDIF

IF !EMPTY(cWordExe)
   RUNSHELL(cFile, cWordExe)
ENDIF

RETURN(NIL)

/* 
*/
#DEFINE CRLF CHR(13)+CHR(10)

FUNCTION File2Array(cFile)
LOCAL aRetVal:={}, cBuff, nPos

IF !FILE(cFile)
   RETURN(aRetVal)
ENDIF

cBuff:=MEMOREAD(cFile)
WHILE( (nPos:=AT(CRLF, cBuff))> 0 )
   AADD(aRetVal, SUBSTR(cBuff, 1, nPos-1))
   cBuff:=SUBSTR(cBuff, nPos+2)
ENDDO
AADD(aRetVal, cBuff)

RETURN(aRetVal)

/* 
*/
STATIC FUNCTION FindMSWord()
LOCAL cRetVal:=""

IF FILE("C:\PROGRA~1\MICROS~1\OFFICE\WINWORD.EXE")
   cRetVal:="C:\PROGRA~1\MICROS~1\OFFICE\WINWORD.EXE"
ENDIF
IF FILE("C:\PROGRA~1\MICROS~2\OFFICE\WINWORD.EXE")
   cRetVal:="C:\PROGRA~1\MICROS~2\OFFICE\WINWORD.EXE"
ENDIF
IF FILE("C:\PROGRA~1\MICROS~3\OFFICE\WINWORD.EXE")
   cRetVal:="C:\PROGRA~1\MICROS~3\OFFICE\WINWORD.EXE"
ENDIF
IF FILE("C:\PROGRA~1\MICROS~4\OFFICE\WINWORD.EXE")
   cRetVal:="C:\PROGRA~1\MICROS~4\OFFICE\WINWORD.EXE"
ENDIF
IF FILE("C:\PROGRA~1\MICROS~5\OFFICE\WINWORD.EXE")
   cRetVal:="C:\PROGRA~1\MICROS~5\OFFICE\WINWORD.EXE"
ENDIF
RETURN(cRetVal)

/* 
*/



"Toma Grom" <tomaz.grom@siol.net> wrote in message
news:2601087$21003c93$18116d@news.alaska-software.com...
> Hvala, Igor !
>
>
AUGE_OHRRe: Runsheell() quesstion
on Mon, 25 Jun 2007 22:18:34 +0200
hi,

>  RunShell( cFile, "WINWORD.EXE", lAsync )

this solution use GERMAN Word and will open Word
with latest Document you have used.
*** snip ***
PROCEDURE ReadLastDOC()
LOCAL oReg, uVal

oReg := 
XbpReg():NEW('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App 
Paths\Winword.exe')
IF ! oReg:Status()
      MSGBOX("Kein WINWORD installiert")
      RETURN
ENDIF

oReg:ReadBinType("C")
uVal := oReg:Standard()

RunShell( "/mfile1 /mZurckEinfgemarke", uVal, .T. )

RETURN
*** eof ***
greetings by OHR
Jimmy