cancel
Showing results for 
Search instead for 
Did you mean: 

Pausing a script

Former Member
0 Kudos

noob here...

I am trying to cause a script to pause for a bit, and while I have tried <b>Wscript.Sleep 1000</b>, the script bugs out and says :

<b>Microsoft VBScript runtime error - Object required: 'WScript'</b>

I'm assuming that the answer is pretty simple, but... I'm a noob... so nothing is simple for me right now.

Any ideas?

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hello I checked this tscipt above and says that Object required: 'Wscript'

please tell me how to make a pause for SAP GUI script for pause for 10 sec

Best Regards

Slawomir Korman

Former Member
0 Kudos

A added

before MsgBox "Pre-Pause"

On Error Goto 0

it works )

Slawek

Christian_Cohrs
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi,

the wscript object is only available when the script is executed using the Windows Script Host. This happens for example when you double click the VBS file.

If however you run the script from SAP GUI then it will be executed using the MS Script Control, and this control does not support the wscript object and its members.

Best regards,

Christian

Former Member
0 Kudos

Thank You for Reply,

Now is Clear for Me

Best Regards

Slawek, Korman

Former Member
0 Kudos

Hello Slawek,

I am trying to decipher your answer. Your code was very similar to mine, but I did not understand what code you added where to make your PAUSE function work. Please tell me again?

Thank you,

Nick

****************************************************************************** Not Clear:

A added

before MsgBox "Pre-Pause"

On Error Goto 0

***********************************************************************************************************

********************************************************My Code (I want Pause after SendVKey8)

If Not IsObject(application) Then

   Set SapGuiAuto  = GetObject("SAPGUI")

   Set application = SapGuiAuto.GetScriptingEngine

End If

If Not IsObject(connection) Then

   Set connection = application.Children(0)

End If

If Not IsObject(session) Then

   Set session    = connection.Children(0)

End If

If IsObject(WScript) Then

   WScript.ConnectObject session,     "on"

   WScript.ConnectObject application, "on"

End If

session.findById("wnd[0]").resizeWorkingPane 263,47,false

session.findById("wnd[0]").sendVKey 8

session.findById("wnd[0]").sendVKey 3

session.findById("wnd[0]").sendVKey 8

session.findById("wnd[0]").sendVKey 3

session.findById("wnd[0]").sendVKey 8

session.findById("wnd[0]").sendVKey 3

Former Member
0 Kudos

can you post more of the script? Kind of hard to debug a line that appears to be fine.

Make sure you are using wscript to run it and not cscript

Mike

Former Member
0 Kudos

ok, here is a very basic version (for testing purposes):

---

If Not IsObject(application) Then

Set SapGuiAuto = GetObject("SAPGUI")

Set application = SapGuiAuto.GetScriptingEngine

End If

If Not IsObject(connection) Then

Set connection = application.Children(0)

End If

If Not IsObject(session) Then

Set session = connection.Children(0)

End If

If IsObject(WScript) Then

WScript.ConnectObject session, "on"

WScript.ConnectObject application, "on"

End If

MsgBox "Pre-Pause"

Wscript.Sleep 1000

MsgBox "Post-Pause"

---

This scrip runs fine until it hits the Wscript.Sleep 1000 line.0

Then the error message appears.

And... just another note (in case this matters):

I connect to SAP remotely via a Citrix server over the internet.

Not sure if that matters, but I figured that it might be worth mentioning just in case.