Domino 9 und frühere Versionen > Entwicklung

script soll warten . . .

(1/2) > >>

ReneX:
Guten morgen,
ich habe folgendes Problem: Ich starte über ein script eine Batch Datei.
Leider wartet das script nicht bis die externe Anwendung abgeschlossen wurde, das soll es aber. Die Ausführung dieser Anwendung dauert unterschiedlich lange.
Gibt es da eine Möglichkeit das script auf die Anwendung "wartet" und dann erst weiter macht?

Ich starte die Anwendung mit taskId% = Shell("c:\test.bat", 2)

Vielen Dank

Rene
 ???

wflamme:
Aus meiner KB (ungeprüft):

Starting a Program from Notes and Waiting for It to Finish
02/08/2000
At times, you might find it useful to start a program from Notes and wait for the program to finish. For example, when a user must complete a task in a non-Notes application before a Notes app can continue, such as creating a spreadsheet in Excel that a Notes application will use. Note that although the following sample code works under Win32, you could adapt it for other operating systems. The code below starts a program in Notes and waits for it to finish.

Public Type STARTUPINFO
cb As Long
lpReserved As String
lpDesktop As String
lpTitle As String
dwX As Long
dwY As Long
dwXSize As Long
dwYSize As Long
dwXCountChars As Long
dwYCountChars As Long
dwFillAttribute As Long
dwFlags As Long
wShowWindow As Integer
cbReserved2 As Integer
lpReserved2 As Long
hStdInput As Long
hStdOutput As Long
hStdError As Long
End Type

Public Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessID As Long
dwThreadID As Long
End Type

Declare Function WaitForSingleObject Lib "kernel32" (Byval _
hHandle As Long, Byval dwMilliseconds As Long) As Long

Declare Function CreateProcessA Lib "kernel32" (Byval _
lpApplicationName As Long, Byval lpCommandLine As String, Byval _
lpProcessAttributes As Long, Byval lpThreadAttributes As Long, _
Byval bInheritHandles As Long, Byval dwCreationFlags As Long, _
Byval lpEnvironment As Long, Byval lpCurrentDirectory As Long, _
lpStartupInfo As STARTUPINFO, lpProcessInformation As _
PROCESS_INFORMATION) As Long

Declare Function CloseHandle Lib "kernel32" (Byval _
hObject As Long) As Long

Public Const NORMAL_PRIORITY_CLASS = &H20&
Public Const INFINITE = -1&

Public Sub ShellAndWait(Byval RunProg As String)
' From Kevin Pauli (kcpauli@usa.net)
Dim RetVal As Long
Dim proc As PROCESS_INFORMATION
Dim StartInf As STARTUPINFO
StartInf.cb = Len(StartInf)
'Execute the given path
RetVal = CreateProcessA(0&, RunProg, 0&, 0&, 1&, _
NORMAL_PRIORITY_CLASS, 0&, 0&, StartInf, proc)

'Disable this app until the shelled one is done
RetVal = WaitForSingleObject(proc.hProcess, INFINITE)
RetVal = CloseHandle(proc.hProcess)
End Sub

ReneX:
@wflamme

Erst ein mal Vielen Dank,

da ich aber nicht so der script Experte bin, ist dein script relativ uneinsichtig für mich.
Ich wäre für eine ganz kurze Erklärung sehr dankbar.

Vielen Dank

harkpabst_meliantrop:
Würde nicht auch vielleicht die billigere Variante reichen?

Sleep(x.xx) lässt ein Script für x.xx Sekunden warten, ohne Rechenzeit zu verbrauchen. Wenn man das in eine passend dimensionierte Zählschleife packt (und in jedem Durchlauf prüft, ob die Ausgabe der Batchdatei schon erfolgt ist), hat man zwar keine 100%ig saubere, aber dafür sehr einfache (und auch noch palttformunabhängige) Lösung.

BimboBuster2000:
Versuch es mal mit

Shell("start /w c:\test.bat", 2)

 /w heisst: warten bis diese aufgabe beendet is, dan das naechste commando starten


The Buster

=======================================

Es gibt bereits so viele Irren im Universum
Ein paar mehr oder weniger, das merckt doch Keiner...

Bernd, das Brot

Navigation

[0] Themen-Index

[#] Nächste Seite

Zur normalen Ansicht wechseln