Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Detect user closure of script 3

Status
Not open for further replies.

JPJeffery

Technical User
May 26, 2006
600
GB
Sometimes our users complain that their drives haven't mapped.

Sometimes, according to the log file I get the script to write, this is due to a system or script error.

Sometimes though, I think it's because they close the damn window!

So, is there any way to either
1) prevent users from closing the script window or
2) detecting within the script that the user has closed the script window?

JJ
[small][purple]Variables won't. Constants aren't[/purple]
There is no apostrophe in the plural of PC (or PST, or CPU, or HDD, or FDD, and so on)[/small]
 
How about making your script run without a window at all? Make your script run under WScript.exe instead of CScript.exe. Check the FAQ section of this forum. MarkDMac has posted an excellent logon script.

PSC

Governments and corporations need people like you and me. We are samurai. The keyboard cowboys. And all those other people out there who have no idea what's going on are the cattle. Mooo! --Mr. The Plague, from the movie "Hackers
 
I knew someone would suggest that.
;-)

I had considered it but we like the way it's set to say Good Morning and confirm drive mappings (or failure thereof) and such like.

JJ
[small][purple]Variables won't. Constants aren't[/purple]
There is no apostrophe in the plural of PC (or PST, or CPU, or HDD, or FDD, and so on)[/small]
 
Have you considered using the IEObject to display messages? If it gets closed, at least the rest of your script can continue...with the proper error handling.

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
i would say

1) no
2) no

go with dm4ever's suggestion and have the messages displayed in a different thread from your actual logonscript.

this still doesnt prevent someone closing your logonscript though. the cscript.exe or wscript.exe thread which gets killed by your user should return a non zero exit code of a consistant number. its like chasing your own tail but you would need to call your script from a different thread whcih was logging the outcome of your script! all very circular.

my solution to your problem has historically been:

a) have your logonscript so robust (trap errors, defensive program etc) that it never causes a run-time. that way you know that the 'oh my drives didnt map' excuse can not be blamed on your code.

b) in combination with a) write verbose auditing information at code construct in your logonscript. (perhaps write it to a local text file first then copy that log file to central location towards the end of the logonscript). the log information should contain all error information and how the script is getting on.

by doing both of these things you should be in a position to tell what users are killing your logonscript by checking the contents of the log files...or you can tell what method call is failing and under what circumstances.


 
Some good ideas there, but I'm not sure there's enough to gain from the effort required. I was hoping there was something quick and easy, although I never really felt there was much chance of it.

Thanks all.

JJ
[small][purple]Variables won't. Constants aren't[/purple]
There is no apostrophe in the plural of PC (or PST, or CPU, or HDD, or FDD, and so on)[/small]
 
Put a restart sequence in the script so that if the box gets closed the workstation will simply restart. After a time or two of waiting for a complete re-boot, the users will get the message and keep hands off until login is completed--just like training a monkey.

David.
 
It's cruel. It's harsh. I like it!

I'd never be allowed to do it but still, I want to test it. But how would it be possible? If you close a cscript window then the script stops processing so there'd never be a test to check.

Would there?

JJ
[small][purple]Variables won't. Constants aren't[/purple]
There is no apostrophe in the plural of PC (or PST, or CPU, or HDD, or FDD, and so on)[/small]
 
Maybe I am missing something here. How have you implemented your login script?

If you have followed my FAQ and implemented the code in a GPO, then the users should not see a box to close (and you can still have it say good morning).

Unless you have modified the default script engine to be CSCRIPT.EXE, the script should execute behind the scenes using WSCRIPT.EXE.

Users that have rights on the box to run Task Manager will still be able to stop the process, but the average user would not think to do that for the few seconds your script should be running.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top