#20532 - 2002-04-24 05:19 PM
Cleanly log off a Windows 95 PC Remotely!!
|
Rocco Capra
Hey THIS is FUN
   
Registered: 2002-04-01
Posts: 380
Loc: Mansfield Ohio
|
Since I could not get win 95 to cleanly reboot or shutdown without hanging every other time, the best I could do was log off.
Here is what I have had to do to get a clean Log-Off on a Windows 95 PC. (not tested on 98 or ME yet).
You will need the folowing 'stuff'... AutoIT.exe from... http://www.hiddensoft.com/AutoIt/ JT.exe from... ftp://ftp.microsoft.com/reskit/win2000/jt.zip ScheduleTask UDF by Jens Meyer (sealeopard@usa.net) from... http://81.17.37.55/board/ultimatebb.php?ubb=get_topic;f=12;t=000060
==================================================================== I call the ScheduleTask UDF to place a schedule on the 95 PC. It will execute AutoIt and a script file to send key strokes to the PC to close any open programs without saving them and then log the current user off (the ScheduleTask UDF does work for a non-admin user).
Here is the AutoIt script used to close the Apps and log off, this will close up to 8 Apps...
code:
HideAutoItWin, On
Send, !{TAB} Send, !{f} Sleep, 1000 Send, {x},{c} Sleep, 2000
Send, !{TAB} Send, !{f} Sleep, 1000 Send, {x},{c} Sleep, 2000
Send, !{TAB} Send, !{f} Sleep, 1000 Send, {x},{c} Sleep, 2000
Send, !{TAB} Send, !{f} Sleep, 1000 Send, {x},{c} Sleep, 2000
Send, !{TAB} Send, !{f} Sleep, 1000 Send, {x},{c} Sleep, 2000
Send, !{TAB} Send, !{f} Sleep, 1000 Send, {x},{c} Sleep, 2000
Send, !{TAB} Send, !{f} Sleep, 1000 Send, {x},{c} Sleep, 2000
Send, !{TAB} Send, !{f} Sleep, 1000 Send, {x},{c} Sleep, 3000
Send, {n},{n},{n},{n},{n},{n},{n},{n} Sleep, 2000
WinActivate, Program Manager Send, !{F4} WinWaitActive, Shut Down Windows Send, !c Send, {ENTER}
EXIT
Here is the ScheduleTask UDF I modified to work on Windows 95...
code:
;======================================================== ;I create a file to check if it exists. If it does I know ;the task is there and thus do not even call this script. ;======================================================== $RC = Open(1,"%WINDIR%\Log-Off.txt",5) $RC = WriteLine(1,"Log-Off Task installed.") $RC = Close(1) ;===================================================== ;I copy the files needed to the WINDOWS directory so I ;know that they are all in the executable "PATH". ;===================================================== IF NOT EXIST(("%WINDIR%\jt.exe")AND("%WINDIR%\AutoIt.exe")AND("%WINDIR%\LogOff_9x.aut")) COPY @STARTDIR + "\_auxfiles\new\jt.exe" "%WINDIR%" COPY @STARTDIR + "\_auxfiles\new\AutoIt.exe" "%WINDIR%" COPY @STARTDIR + "\_auxfiles\new\LogOff_9x.aut" "%WINDIR%" ENDIF ? "[ Setting Task Scheduler Job ]" $taskname="Log-Off.job" $computer="@WKSTA" ;Don't use this on 9x $date="04/24/2002" $time="1:32" $type="DAILY" $userid="administrator" ;Don't use this on 9x $userpw="password" ;Don't use this on 9x $comment='"This task is to force Log-Off every night On this PC."' $command="AutoIt.exe" ;======================================================== ;I found that I need to include the %WINDIR% cause AutoIt ;looks to the root of "C:\" to find the script. ;======================================================== $parameters='" %WINDIR%\LogOff_9x.aut"'
$RC = scheduletask($taskname,$computer,$date,$time,$type,$userid,$userpw,$comment,$command,$parameters)
:END EXIT
;======================================================================= ;FUNCTION SCHEDULETASK ;AUTHOR Jens Meyer (sealeopard@usa.net) ;ACTION Schedules a task on any computer using the Task Scheduler ;======================================================================= function scheduletask($taskname, $computer, $date, $time, $type, $userid, $userpw, $comment, $command, $parameters) Dim $jtexe, $shellcmd, $retcode ;This should point to your copy of jt.exe $jtexe="jt.exe" ;================================================ ;I found that if a task does not already exist ;the script errors and exits on this delete part. ;================================================ ; delete a potentially existing task ; $shellcmd=$jtexe+' /SM \\'+$computer+' /SD '+$taskname ; shell '%COMSPEC% /e:1024 /c '+$shellcmd ; if @ERROR ; $scheduletask=@ERROR ; return ; endif
; create a new task, save it, and force a run $shellcmd = $jtexe $shellcmd = $shellcmd+ " /SAJ "+$taskname ;Had to move this up here from below for 9x $shellcmd = $shellcmd+ " /CTJ StartDate="+$date $shellcmd = $shellcmd+ " StartTime="+$time $shellcmd = $shellcmd+ " HasEndDate=0" $shellcmd = $shellcmd+ " KillAtDuration=0" $shellcmd = $shellcmd+ " Disabled=0" $shellcmd = $shellcmd+ " Type="+$type ; $shellcmd = $shellcmd+ ' /SC '+$userid+' '+$userpw ;Don't use this on 9x $shellcmd = $shellcmd+ " /SJ ApplicationName="+$command $shellcmd = $shellcmd+ " Parameters="+$parameters ; $shellcmd = $shellcmd+ " WorkingDirectory=%WINBOOTDIR%" ;Don't use this on 9x $shellcmd = $shellcmd+ " Comment="+$comment ; $shellcmd = $shellcmd+ ' Creator="'+@USERID+'"' ;Don't use this on 9x $shellcmd = $shellcmd+ " Priority=Normal" $shellcmd = $shellcmd+ " MaxRunTime=3600000" ;3600000 = 1 hour $shellcmd = $shellcmd+ ' DontStartIfOnBatteries=0' $shellcmd = $shellcmd+ ' KillIfGoingOnBatteries=0' $shellcmd = $shellcmd+ ' RunOnlyIfLoggedOn=0' ; $shellcmd = $shellcmd+ ' SystemRequired=0' ;Don't use this on 9x $shellcmd = $shellcmd+ ' DeleteWhenDone=0' $shellcmd = $shellcmd+ ' Suspend=0' $shellcmd = $shellcmd+ ' StartOnlyIfIdle=0' $shellcmd = $shellcmd+ ' KillOnIdleEnd=0' $shellcmd = $shellcmd+ ' RestartOnIdleResume=0' $shellcmd = $shellcmd+ ' Hidden=0' ; $shellcmd = $shellcmd+ ' TaskFlags=0' ;Don't use this on 9x ; $shellcmd = $shellcmd+ ' /SM \\'+$computer ;Don't use this on 9x $shellcmd = $shellcmd+ " /SAC Log-Off.job" shell "%COMSPEC% /e:1024 /c "+$shellcmd+" >NUL" ;">NULL" = Supress output from JT.exe $scheduletask=@ERROR endfunction
The first time the ScheduleTask UDF runs I create a file in the Windows dir. When I call the ScheduleTask UDF I look for that file and if it is found I don't run it, like this...
code:
IF NOT EXIST("%WINDIR%\Log-Off.txt") CALL @STARTDIR + "\_auxscr\s_task_9x.kix" ENDIF
Hey a FREE way to remotely log off users on Windows 95. So what do you think? Any comments welcome!
Rocco
_________________________
I Love this board!!
--------------------
My DEV PC is running
KIX 4.22 WINXP Pro
|
|
Top
|
|
|
|
#20533 - 2002-04-24 07:10 PM
Re: Cleanly log off a Windows 95 PC Remotely!!
|
BrianTX
Korg Regular
Registered: 2002-04-01
Posts: 895
|
Just curious... do you know what was causing the Win95 machines to hang on shutdown? If it is a certain application (i.e. Outlook), you can use the kill95.exe utility to kill it first before shutting down. You could even write a script that checked for all programs open via the kill95 utility and shut them all down one by one before issuing the shutdown command.
Brian
|
|
Top
|
|
|
|
#20535 - 2002-04-25 01:18 PM
Re: Cleanly log off a Windows 95 PC Remotely!!
|
Dean R
Starting to like KiXtart
Registered: 2002-03-15
Posts: 115
Loc: Ireland, but Im an Aussie
|
If you run the critical updates/security patches etc from the Microsoft.com windows update page, it fixes this problem, I have not had the 95/98 shutdown bug since doing this.
_________________________
--------------------------------
When you can take this stone from my hand Gwasshoppa you are read...
*yoink*
Gwasshoppa?
Gwasshoppa? Where did you go?
---------------------------------
|
|
Top
|
|
|
|
#20537 - 2002-04-25 02:18 PM
Re: Cleanly log off a Windows 95 PC Remotely!!
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
Rocco,
From http://www.robvanderwoude.com , Please find the following FAQ - Shutdown/Restart - options.
I started to question whether or not you needed to use AutoIT.
- Win31* ECHO G=FFFF:0000 ¦ DEBUG Popup Task Manager, sometimes reboot
- Win9* RUNDLL USER.EXE,ExitWindows Shutdown (3)
- Win9* RUNDLL USER.EXE,ExitWindowsExec Win95: various results, usualy fast shutdown (and lock PC), sometimes restart Windows, sometimes reboot.
- Win98: Restart Windows, sometimes reboot.
- Win9* RUNDLL SHELL.DLL,RestartDialog "System Settings Change, Do you want to restart your computer now?" dialog
- Win98/ME RUNDLL32 SHELL32.DLL,SHExitWindowsEx n Where n can be any combination (sum) of the following numbers: (4)
0 Logoff 1 Shutdown 2 Reboot 4 Force 8 Poweroff (if supported by the hardware)
Notes:
- 3 Thanks for Bill James and Tom Lavedas, for the information on RUNDLL.
Find more RUNDLL examples I collected on my RUNDLL page. - 4 See article Q234216 in the Microsoft Knowledge base for more information.
Thanks for Alec Soroudi for pointing out this information. Windows NT also has a RUNONCE.EXE, but I am not sure what its purpose is -- RUNONCE.EXE -q does not shut down NT.
HTH, - Kent [ 25 April 2002, 14:18: Message edited by: kdyer ]
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(Allen)
and 1047 anonymous users online.
|
|
|