Anzeige
Archiv - Navigation
120to124
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
120to124
120to124
Aktuelles Verzeichnis
Verzeichnis Index
Verzeichnis Index
Übersicht Verzeichnisse
Inhaltsverzeichnis

Shell Prozessende abwarten (ohne Kernel!)

Shell Prozessende abwarten (ohne Kernel!)
22.05.2002 09:12:21
Marc Enzler
Hallo Leute,

steck mal wieder fest. Wenn ich nen Batch Prozess wie folgt starte:

ergebnis = Shell("f:\$operations\products\montreal\backtest\backtest.bat", 1)

krieg ich ne task id (in ergebnis) zurueck. Ich möchte nun abfragen, wann das Programm beendet ist und erst dann weiterfahren (so ne do while schleife in verbindung mit doEvents).

Mein problem:

Es gibt im Forum ne Hilfe die sich dazu ner Kernel32 lib bedient. Leider funzt das bei Win2000/Office XP irgendwie nicht (oder nicht mehr). Es muss doch was geben, womit ich direkt mit der TASK-ID herausfinden kann, ob sie noch aktiv ist.

Danke für jede Art von Tip/Hilfe etc..!!!!

Liebe Grüsse
Marc

3
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
Re: Shell Prozessende abwarten (ohne Kernel!)
22.05.2002 13:30:19
Marc Enzler
Da mir (schon wieder) niemand zu diesem Thema helfen kann (habs schon mal vor ein paar Monaten gestellt, hab ich mich durch andere Foren gekämpft und siehe da, ne FEINE LOESUNG GEFUNDEN!! fürs archiv schmeiss ich mal den code hier rein:

'**************************************
' Name: Best Shell & Wait (No API's!)
' Description:Makes it easy to perform a
' clean "Shell & Wait" where your applicat
' oin kicks off an external application an
' d waits for it to return before continui
' ng. Many shell & wait examples I have fo
' und tend to overdrive the proccessor in
' a loop or require you to make API calls.
' This one uses the Windows Script object
' to take advantage of it's built-in wait
' parameter on the .Run method...scripting
's version of Shell.
' By: Matt Roberts
'
' Inputs:FileName - The name of the file
' you wish to run with any required switch
' es included.
'
' Returns:True if the file was run and r
' eturned.
False If there was a file open or save error.
EXAMPLE: ShellAndWait ("notepad.exe c:\temp\teset.txt)
'
' Assumes:Should work on any Windows 98
' machine. Others may need to get the newe
' st VB service pack or install Windows Sc
' ripting Host (http://msdn.microsoft.com/
' scripting/jscript/download/55beta.htm).
' This is also included in Internet Explor
' er 5. If you already have IE5, this will
' work and it will be included when you bu
' ild your setup file for distribution.
'
' Side Effects:None - Will not block oth
' er applications or overdrive the procces
' sor.
'
'This code is copyrighted and has' limited warranties.Please see http://w
' ww.Planet-Source-Code.com/xq/ASP/txtCode
' Id.8349/lngWId.1/qx/vb/scripts/ShowCode.
' htm'for details.'**************************************

Function ShellAndWait(FileName As String)
Dim objScript
On Error Goto ERR_OpenForEdit
Set objScript = CreateObject("WScript.Shell")
' Open a file for editing in Notepad and
' wait for return.
'The second parameter (after the FileNam
' e) is the Display Mode (normal w/focus,
'minimized...even hidden. For more info
' visit:
'http://msdn.microsoft.com/scripting/win


' dowshost/doc/wsMthRun.htm
' The third parameter is the "Wait for r
' eturn" parameter. This should be set to
' True for the Wait.
ShellApp = objScript.Run(FileName, 1, True)
ShellAndWait = True
EXIT_OpenForEdit:
Exit Function
ERR_OpenForEdit:
MsgBox Err.Description
Goto EXIT_OpenForEdit
End Function

Anzeige
Re: Shell Prozessende abwarten (ohne Kernel!)
22.05.2002 15:21:20
Thomas Stache
Kann man auf ähnliche Weise auf ein Objekt am COM-Interface warten? Ich benutze bisher eine while-Schleife mit Application.Wait, wobei oft vorkommt, dass Excel den ganzen Prozessor in anspruch nimmt, sobald das Fenster der gesteuerten Anwendung in den Hintergrund gerät.

Thomas(S)

Re: Shell Prozessende abwarten (ohne Kernel!)
22.05.2002 16:35:17
Marc Enzler
Thomas: kann ich Dir nicht beantworten, da ich ehrlich gesagt nicht ganz verstehe wie dieses WScript.Shell funktioniert.

Aber:

Hast Du in Deine Schlaufe eine DoEvents eingebaut? Das sollte Dir zumindest etwas Luft verschaffen. Leider geht immer noch die meiste Prozessorzeit für den Leerlauf drauf, aber immerhin werden andere Events auch abgehandelt.. Hoffe das hilft.

Gruss Marc

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige