cancel
Showing results for 
Search instead for 
Did you mean: 

Quit Script

Former Member
0 Kudos

Hi All - I was wondering how to use the Wscript.Quit to stop execution of the svript. It does not like that command. Am I missing another line of code to maek it work? Or is there another way of stopping the script?

Thanks

Umur

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Michael - I used the error trap trick in other cases but did not think of using it here. However, since I am doin gthis in a loop, followed by another one, it was not going to be slick. So I put the whole code in a do-while and used an 'exit do' after comparing the input and assigning a value to end the loop if user selects the exit key. This way the error message does not pop up that I need to worry about suppressing it with on-error statement. Your solution would have worked as well with different set up. This is the good thing about this forum, - you get different perspectives and options to do something in other ways.

Thanks Michael...

Regards

Umur

Former Member
0 Kudos

Hi Michael - when I try your set of code, I am still getting the same "Object required: 'WScript' -" message from SAP Frontend. Server. I wonder if I am missing something else, like another line of code to trigger that object.

Regards

Umur

michael_hobbins
Active Participant
0 Kudos

Umur, I imagine you're working on Windows, seems like there's something wrong with the wscript application. What Windows are you using (XP, Vista, 7, something older)?

Can you test that script on another computer?

Michael

Former Member
0 Kudos

Michael - I am using Windows XP Professional with SAP GUI 7.10. All computers at the office are on the same operating environment and it has to work for all my distributed users. So I have to get this to work on my set up. Worst case scenario is I insert that line and when the user wants to exit, he will get that cryptic message but at least the script will stop.

Maybe I can throw this question : I am placing an Inputbox for the user to type a date in. So the OK and CANCEL buttons are there. I don't want him to leave it blank as it will kill the script later on. But if I loop the input box while the input value is blank, then he can't exit the script. So I said 'type X to exit'. Then I check to see if he entered X. If he enters X, that is where I want the script to end gracefully. Can you recommend something to accomplish this?

Regards

Umur

michael_hobbins
Active Participant
0 Kudos

I have exactly the same OS + SAPGUI versions

What about this "dirty" way around

msgbox "hello1"
on error resume next
wscript.Quit
if err.number = 0 then
   msgbox "hello2"
end if
msgbox "END!"

If your computer handles the Quit correctly, it'll quit, if it sends the error, it'll go (should) around safely

Regards

Michael

michael_hobbins
Active Participant
0 Kudos

Hello Umur, the method is correct, and I haven't come across an alternative.

Try this code to confirm

wscript.echo "hello1"
wscript.quit
wscript.echo "hello2"

Run it, you'll get hello1, but not hello2.

Regards

Michael