Technical Articles
How To Execute Any File With GuiXT
Everbody knows GuiXT – the comfortable library to individualize the SAP screens. It is standard part of the SAP GUI for Windows and you can use it without any problems. You can find more information about GuiXT here.
GuiXT offers the possibility to use function calls from DLLs inside a GuiXT script, with the command Call. Here an GuiXT script example how to use the Windows API function ShellExecute. On this way you can execute any file you like.
//-Begin----------------------------------------------------------------
//-With InputAssistant------------------------------------------------
//-Flags------------------------------------------------------------
//-ShowWindow-----------------------------------------------------
Set V[SW_HIDE] "0"
Set V[SW_SHOWNORMAL] "1"
Set V[SW_NORMAL] "1"
Set V[SW_SHOWMINIMIZED] "2"
Set V[SW_SHOWMAXIMIZED] "3"
Set V[SW_MAXIMIZE] "3"
Set V[SW_SHOWNOACTIVATE] "4"
Set V[SW_SHOW] "5"
Set V[SW_MINIMIZE] "6"
Set V[SW_SHOWMINNOACTIVE] "7"
Set V[SW_SHOWNA] "8"
Set V[SW_RESTORE] "9"
Set V[SW_SHOWDEFAULT] "10"
Set V[SW_FORCEMINIMIZE] "11"
Set V[SW_MAX] "11"
//-ShellExecute-----------------------------------------------------
Set V[hWnd] "0"
Set V[Operation] "open"
Set V[File] "Test.vbs"
Set V[Parameters] ""
Set V[Directory] "C:\Dummy"
Set V[ShowCmd] V[SW_SHOWNORMAL]
Call "ShellExecuteA" dll="shell32.dll" In="&V[hWnd]" In="&V[Operation]" In="&V[File]" In="&V[Parameters]" In="&V[Directory]" In="&V[ShowCmd]" Out="rc"
//-Without InputAssistant---------------------------------------------
//-ShellExecute-----------------------------------------------------
Call "ShellExecuteA" dll="shell32.dll" In="0" In="open" In="Test.vbs" In="" In="C:\Dummy" In="1" Out="rc"
//-End------------------------------------------------------------------
Is it possible to launch an exe and WAIT for it to complete before continuing the script?
Hello James,
sure, try this:
Use instead the script your executable program.
Cheers
Stefan
Thanks, but that doesn't work. The "Call ..." exits immediately. It's the call I want to block until the executed program completes. I don't see the point of the call command to be asynchronous in a synchronous script...!?
Hello James,
thanks for your reply. You are right, ShellExecute returns immediately, independently if the started programs runs or not. Sorry for my failure.
Here a possible solution with a DLL:
This function can call via GuiXT
And in this case the execution of the script waits until the cmd.exe is terminated.
Cheers
Stefan