WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Functions

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Using IntControl 1005 and Shutdown

Keywords: 	  IntControl(1005

NOTICE:

IntControl 1005 was removed from documentation as it did not work as people wished. It worked on on Windows 95/98/ME machines, but was not at all satifactory on NT/2000/XP/2003 machines.

WORKAROUND:

This is a possible workaround for IntControl 1005 on NT platforms. The idea is to Launch a WinBatch service (.exs) and have it monitor for the Shutdown/Logoff message, execute any shutdown/logoff code then exit! You can install the service on the fly using wntSvcCreate then start it using wntSvcStart. http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/Functions+IntControl~1005.txt


Question:

I created the following code which seemed pretty straight forward from the examples and infromation contained in the help files. Problem is that I must be missing something. The example for IntControl(1005...) was also referenced, but somehow, the file write does not want to function. I'd appreciate any help that anyone can provide. Is it timing related? Also, can the window that is generated asking to close all the other programs be prevented from being displayed or otherwise seen? Here's the code snip-it.
;Add the appropriate Winbatch  Extender
AddExtender("WWWNT34I.DLL")


;Get needed information concerning user
username=wntUserInfo(0)
server = wntUserInfo(3)
logouttime=TimeDate( )


; Put program into 'shutdown' mode
IntControl(1005, 1, 0, 0, 0) 


; Proceed with logout tasks
handle = fileopen("c:\logout.txt", "write")
Filewrite(handle, "%username%     %   server%     %logouttime%")
Fileclose(handle)

Answer:

I would check the example of the IntControl 1005 function again.

The IntControl(1005,1,0,0,0) basically stops the script. You will never get to the FileWrite. IntControl(1005,1,0,0,0) says STOP the entire script right now, and start it over when shutdown occurs.

If you examine the example a bit closer, you will see that the first thing this example does is to check to see if a shutdown is in progress or not. If so it goes to the shutdown code. Otherwise it then does the IntControl(1005,1,0,0,0)


Question:

I'm trying to use IntControl(1005 to shut down Windows NT session but each time get, quoting Help file description, "Windows queries each running application in turn, asking whether it agrees to close. When it queries WinBatch, WinBatch displays a message box, asking the user to first close all other open windows".

I can get the dialog box to be answered using AutoIT.exe or scriptit.exe but have got to ask whether it would be possible for WilsonWare to modify the code to this IntControl function to allow the batch developer the opportunity to decide whether that prompt shows or not.

My reason behind the request, Winbatch+Compiler was purchased to assist in automating tasks on user desktops; giving the user a prompt that they must answer just adds to the amount of manual involvement by the user. If there is another way of preventing this prompt from displaying or answering it automatically, I would greatly appreciate some information as to how it can be done.

Answer:

Well, let's be careful.

In using IntControl 1005 you want to run some code right before shutting down windows.

What do you want this code to do? What if there are other applications still running when WinBatch is told to shutdown. Should WinBatch run the shutdown scripts,and then have the user cancel the shutdown later?

The problem is that Windows NT shuts down each application in turn. So you could have Winbatch shutdwon, the user change their mind, and stay logged on for hours.

It is a real problem with no solution. The handling of IntControl 1005 is the best we could figure out.

Yes, another script - even another Winbatch script can watch for the box and press the button -- but then the question is does it do anything useful.

If you specify what you want the shutdown script to do, then we can discuss it.

Question (cont'd):

This Intcontrol function, I guess, gets triggered by NT and then the logic you have built in triggers the message box to be displayed. Can a few extra lines of code be placed prior to the execution of the message box statement to account for checking of other open apps?

Answer:

I never did like the implementation of IntControl 1005 under NT. The problem is that NT waits for the Winbatch script to respond before shutting down the other applications.

WinBatch could *try* to shut them down, but then covering all the cases gets 'orribly complex.

If you open a file in notepad, type a few characters, run your Winbatch script with IntControl 1005, open ANOTHER notepad and type a few more characters then try to shutdown you can see the process occurring.


Article ID:   W13083
Filename:   Intcontrol 1005 and Shutdown.txt
File Created: 2014:07:18:09:51:38
Last Updated: 2014:07:18:09:51:38