Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
ShellExecute Problem
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows XP
Database:
MS SQL Server
Divers
Thread ID:
01524461
Message ID:
01524584
Vues:
85
This message has been marked as the solution to the initial question of the thread.
When are you checking the text file? ShellExecute runs async so the process doesn't wait and if you read it too soon the file will always be empty (or locked).

I use CreateProcessEx in wwAPI for this:
************************************************************************
* wwAPI :: CreateprocessEx
****************************************
***  Function: Calls the CreateProcess API to run a Windows application
***    Assume: Gets around RUN limitations which has command line
***            length limits and problems with long filenames.
***            Can do Redirection
***            Requires wwIPStuff.dll to run!
***      Pass: lcExe - Name of the Exe
***            lcCommandLine - Any command line arguments
***    Return: .t. or .f.
************************************************************************
FUNCTION CreateProcessEx(lcExe,lcCommandLine,lcStartDirectory,;
                         lnShowWindow,llWaitForCompletion,lcStdOutputFilename)
which allows capturing the StdOutput data and wait for completion. Since you are a Web Connection user that's easily available to you. Note though that it depends on wwipstuff.dll to handle the async wait loop and command line capture.

Hope this helps,

+++ Rick ---


>I am trying to come up with a way to capture the output of the Qwinsta command to a text file and then later parse it out to determine the current sessions open in RDS. To accomplish the first part I want to use shellexecute to run the command. For a brief time yesterday it worked and then something changed! I don't know what it is but I cannot even see a simple echo command.
>
>Here is what I am trying:
>
>#DEFINE SW_HIDE             0
>DECLARE INTEGER ShellExecute ;
>	    IN SHELL32.DLL ;
>	    INTEGER nWinHandle,;
>	    STRING cOperation,;   
>	    STRING cFileName,;
>	    STRING cParameters,;
>	    STRING cDirectory,;
>	    INTEGER nShowWindow
>
>lcDir=GETENV("APPDATA")
>
>lcCmd = GetEnv("comspec")
>lccdm = "dir"
>
>? lccmd, lcDir
>
>lcPrm = " /c qwinsta >> mytest.txt"
>lcPrm = lcDir+"\mytest.txt"
>lcPrm = " echo hello >> mytest.txt "
>
>=ShellExecute(0, "", lcCmd, lcPrm, lcDir, 0)
>
>
>Thanks in advance
>
>Glenn
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform