cancel
Showing results for 
Search instead for 
Did you mean: 

How to Pause a script

Former Member
0 Kudos

Hello everyone,

I have a script that I run but I need a way to pause the script (I.e. Kind of like hitting a pause button and then hitting play again to continue the script).  I am not looking for the code to pause during the script (i.e. wscript.sleep 1000) since i already have that in the script.  So when i'm running my script, if someone comes over to my desk to ask me a question, i'd like to be able to pause, and then after they leave, i'd like to be able to hit a play button so that i can continue the script.  I've tried using the pause button on the keyboard, but it did not work.  Any suggestions?  Any help is greatly appreciated!!  🙂

Accepted Solutions (0)

Answers (2)

Answers (2)

stefan_schnell
Active Contributor
0 Kudos

Hello Christina,

it isn't so easy to suspend a VBScript resp. a SAP GUI Script. One way is to download from SysInternals the Process Explorer. Start your SAP GUI Script with a double click from the Windows Explorer. If you choose this way, the Windows Scripting Host - WScript.exe or CScript.exe - is the executing program. Now you have the possibilities, with the context menu of the process, to suspend and to resume this process with the running script.

If you drag'n'drop your script to the session, the executing program is the SAPLogon.exe, also if you start the script with the recorder. If you suspend SAPLogon.exe, you can't use SAP GUI for Windows furthermore until you resume.

I use this little script to try it:


'-Begin-----------------------------------------------------------------

  '-Variables-----------------------------------------------------------
    Dim SapGuiAuto, application, connection, session, i

  If IsObject(WScript) Then

    Set SapGuiAuto = GetObject("SAPGUI")
    Set application = SapGuiAuto.GetScriptingEngine
    Set connection = application.Children(0)
    Set session = connection.Children(0)

    i = 1
    While i = 1
      session.findById("wnd[0]/tbar[0]/okcd").text = "/nse16"
      session.findById("wnd[0]/tbar[0]/btn[0]").press
      session.findById("wnd[0]/usr/ctxtDATABROWSE-TABLENAME").text = "usr01"
      session.findById("wnd[0]/tbar[1]/btn[7]").press
      session.findById("wnd[0]/tbar[0]/btn[3]").press
      session.findById("wnd[0]/tbar[0]/btn[3]").press
      WScript.Sleep(1250)
    Wend

  Else

    MsgBox "Not running with WSH"

  End If

'-End-------------------------------------------------------------------

Cheers

Stefan

Former Member
0 Kudos

On *nix you need to send the STOP (sigstop) signal.  The easiest method to do this is CTRL-z.

For Windows, take a look at the discussion at http://stackoverflow.com/questions/100480/how-to-pause-resume-any-external-process-under-windows