#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
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 1644 anonymous users online.
|
|
|