KnowledgeSponge Posted June 10, 2004 Share Posted June 10, 2004 Hello. I wrote the following script for my work. They seemed disinterested at first but now they are on me to get it running on all pc's that our kids use. I am wondering how I can get this script to auto run on every startup for all users and disable task manager using the registry. It works fine with Hkey_Current_User but this would be a huge hassle if I have to go through and run it once for each individual user. Where can a key be placed where it will be used for all users? Thanks for your help. Script follows. expandcollapse popup;####################################### ; TLC Auto Logoff v1.2 ; Script written for TLC ; by Seth Hopkinson ;####################################### Opt ("TrayIconHide", 1); Hide Icon to help prevent the script from being exited RegWrite("HKEY_CURRENT_USER\SOFTWARE\MICROSOFT\WINDOWS\CURRENTVERSION\POLICIES\SYSTEM", "DisableTaskMgr", "REG_DWORD", "1") RegWrite("HKEY_CURRENT_USER\SOFTWARE\MICROSOFT\WINDOWS\CURRENTVERSION\RUN", "Manager", "REG_SZ", "C:\Windows\System32\Manager\Manager.exe") Global $HOUSEPARENT = ""; This is the password $USER = @UserName $DAY = @WDAY Global $LOOK = 0; HotKeySet( "!^p", "Password" ); HotKeySet( "!^e", "Killit" ); $FIRSTRUN = FileExists( "Users.ini" ) Sleep(5000); If $FIRSTRUN = 0 Then IniWrite( "Users.ini", $USER, "LAST", @YEAR & @MON & @MDAY ) IniWrite( "Users.ini", $USER, "TIME", "0" ) EndIf $LAST = IniRead( "Users.ini", $USER, "LAST", "NA" ) $CHECKTAMPER = IniRead( "Users.ini", $USER, "CHECK", "NA" ) If $LAST > @YEAR & @MON & @MDAY Or $CHECKTAMPER = @YEAR & @MON & @MDAY Then MsgBox( 0, "Logging Off", "Computer time confiscated for tampering. 1", 5 ) Shutdown(4); Exit EndIf If $LAST <> @YEAR & @MON & @MDAY Then IniWrite( "Users.ini", $USER, "LAST", @YEAR & @MON & @MDAY ) IniWrite( "Users.ini", $USER, "TIME", "0" ) IniWrite( "Users.ini", $USER, "RAN", "NA" ) EndIf $TIMELEFT = IniRead( "Users.ini", $USER, "TIME", "NA" ) $PWTRY = IniRead( "Users.ini", $USER, "RAN", "NA" ) If $PWTRY = "MIS" And $LAST = @YEAR & @MON & @MDAY Then MsgBox( 0, "Logging Off", "You have made an incorrect password entry. You cannot log in again today.", 5 ) Shutdown(4) Exit EndIf If $LAST = @YEAR & @MON & @MDAY And $DAY <> 1 And $DAY <> 7 And $TIMELEFT > 29 Then WinMinimizeAll( ) $TIMEUSED = MsgBox( 4, "Notice", "You have already used your computer time today. Has a HOUSE PARENT given you more time?" & @CRLF & "You will be prompted for a password if you select YES.", 20 ) If $TIMEUSED = 7 Or $TIMEUSED = -1 Then MsgBox( 0, "Logging Off", "You are not allowed any more time today unless given permission by a HOUSE PARENT.", 5 ) Shutdown( 4 ); Exit ElseIf $TIMEUSED = "6" Then $PW = InputBox( "Houseparent Check", "Please enter the password." & @CRLF & "If an incorrect password is entered, you will not be able to log in again today.", "QWERTY", "*", 190, 160, -1, -1, 30) If $PW = $HOUSEPARENT Then $TIMELEFT = 0; IniWrite( "Users.ini", $USER, "TIME", "0" ) MsgBox( 0, "Notice", $USER & "'s time has been allocated.", 5 ) ElseIf @error = 1 Then Shutdown( 4 ); Else IniWrite( "Users.ini", $USER, "RAN", "MIS" ) MsgBox( 0, "Password Error", "The password is incorrect.", 2 ) Shutdown( 4 ); Exit EndIf EndIf EndIf If $LAST = @YEAR & @MON & @MDAY And $DAY = 1 And $TIMELEFT > 59 Or $LAST = @YEAR & @MON & @MDAY And $DAY = 7 And $TIMELEFT > 59 Then WinMinimizeAll( ) $TIMEUSED = MsgBox( 4, "Notice", "You have already used your computer time today. Has a HOUSE PARENT given you more time?" & @CRLF & "You will be prompted for a password if you select YES.", 20 ) If $TIMEUSED = 7 Or $TIMEUSED = -1 Then MsgBox( 0, "Logging Off", "You are not allowed any more time today unless given permission by a HOUSE PARENT.", 5 ) Shutdown( 4 ); Exit ElseIf $TIMEUSED = 6 Then $PW = InputBox( "Houseparent Check", "Please enter the password." & @CRLF & "If an incorrect password is entered, you will not be able to log in again today.", "QWERTY", "*", 190, 160, -1, -1, 30) If $PW = $HOUSEPARENT Then $TIMELEFT = 0; IniWrite( "Users.ini", $USER, "TIME", "0" ) MsgBox( 0, "Notice", $USER & "'s time has been allocated.", 5 ) ElseIf @error = 1 Then Shutdown( 4 ); Else IniWrite( "Users.ini", $USER, "RAN", "MIS" ) MsgBox( 0, "Password Error", "The password is incorrect.", 2 ) Shutdown( 4 ); Exit EndIf EndIf EndIf ;################MAIN################ $WARNING = 0; HotKeySet( "^1", "Time" ); Pressing CTRL + 1 brings up time logged on in minutes $TIME = $TIMELEFT; If $TIME > 0 And $DAY <> 1 And $DAY <> 7 Then MsgBox( 0, "Notice", "You currently have " & 30 - $TIME & " minutes of computer time remaining today.", 5 ) ElseIf $TIME > 0 And $DAY = 1 Or $TIME > 0 And $DAY = 7 Then MsgBox( 0, "Notice", "You currently have " & 60 - $TIME & " minutes of computer time remaining today.", 5 ) EndIf $HOURCHECK = @HOUR While 1; Infinite Loop If $HOURCHECK + 1 < @HOUR And $HOURCHECK <> 23 Then MsgBox( 0, "Notice", "Computer time confiscated for tampering. 2", 5 ) Shutdown(4); Exit EndIf If $LAST <> @YEAR & @MON & @MDAY And @HOUR <> 0 Then IniWrite( "Users.ini", $USER, "CHECK", @YEAR & @MON & @MDAY ) MsgBox( 0, "Notice", "Computer time confiscated for tampering. 3", 5 ) Shutdown(4); Exit EndIf Sleep(60000); $TIME = $TIME + 1; If $TIME < 31 And $DAY <> 1 And $DAY <> 7 Then IniWrite( "Users.ini", $USER, "TIME", $TIME ) ElseIf $TIME < 61 And $DAY = 1 Or $TIME < 61 And $DAY = 7 Then IniWrite( "Users.ini", $USER, "TIME", $TIME ) EndIf If $TIME >= 30 And $DAY <> 1 And $DAY <> 7 Then Shutdown(4); Exit ElseIf $TIME >= 60 And $DAY = 1 Or $TIME >= 60 And $DAY = 7 Then Shutdown(4); Exit EndIf If $TIME = 25 And $DAY <> 1 And $DAY <> 7 And $WARNING = 0 Then WinMinimizeAll( ) MsgBox( 0, "Notice", "You have 5 minutes of computer time remaining. You will be logged off automatically when your time is up.", 5 ) WinMinimizeAllUndo( ) $WARNING = 1; ElseIf $TIME = 29 And $DAY <> 1 And $DAY <> 7 Then WinMinimizeAll( ) MsgBox( 0, "Notice", "You have 1 minute of computer time remaining. You will be logged off 1 minute after this message is closed." & @CRLF & "Please save any data you wish to save within this time frame.", 10 ); WinMinimizeAllUndo( ) EndIf If $TIME = 55 And $DAY = 1 And $WARNING = 0 Or $TIME = 55 And $DAY = 7 And $WARNING = 0 Then WinMinimizeAll( ) MsgBox( 0, "Notice", "You have 5 minutes of computer time remaining. You will be logged off automatically when your time is up.", 5 ) WinMinimizeAllUndo( ) $WARNING = 1; ElseIf $TIME = 59 And $DAY = 1 Or $TIME = 59 And $DAY = 7 Then WinMinimizeAll( ) MsgBox( 0, "Notice", "Your computer time has been used. You will be logged off 60 seconds after this message is closed." & @CRLF & "Please save any data you wish to save within this time frame.", 10 ); WinMinimizeAllUndo( ) Sleep(60000); Shutdown( 4 ); Exit EndIf Wend ;##############HOTKEY FUNCTION############### Func Time() HotKeySet( "^1", ); HotKeySet( "!^p", ); HotKeySet( "!^e", ); If $LOOK < 60 Then If $TIME = 29 And @WDAY <> 1 And @WDAY <> 7 Then MsgBox( 0, "Time Remaining", "Time Left: " & 30 - $TIME & " Minute", 3 ); ElseIf @WDAY <> 1 And @WDAY <> 7 Then MsgBox( 0, "Time Remaining", "Time Left: " & 30 - $TIME & " Minutes", 3 ); ElseIf $TIME = 59 And @WDAY = 1 Or $TIME = 59 And @WDAY = 7 Then MsgBox( 0, "Time Remaining", "Time Left: " & 60 - $TIME & " Minute", 3 ); ElseIf @WDAY = 1 Or @WDAY = 7 Then MsgBox( 0, "Time Remaining", "Time Left: " & 60 - $TIME & " Minutes", 3 ); EndIf EndIf $LOOK = $LOOK + 1; HotKeySet( "^1", "Time" ); HotKeySet( "!^p", "Password" ); HotKeySet( "!^e", "Killit" ); EndFunc ;==>Time ;###############PASSWORD ENTRY############### Func Password() HotKeySet( "!^p", ); HotKeySet( "!^e", ); HotKeySet( "^1", ); If $LOOK < 60 Then $ENTRY = InputBox( "Houseparent Check", "Please enter the password." & @CRLF & "If an incorrect password is entered, you will not be able to log in again today.", "QWERTY", "*", 190, 160, -1, -1, 30) If $ENTRY = $HOUSEPARENT Then $TIMELEFT = 0; $HOURCHECK = @HOUR IniWrite( "Users.ini", $USER, "TIME", "0" ) IniWrite( "Users.ini", $USER, "CHECK", "NA" ) IniWrite( "Users.ini", $USER, "RAN", "NA" ) MsgBox( 0, "Notice", $USER & "'s time has been allocated.", 5 ) ElseIf @error = 1 Then SetError(0 ) Else MsgBox( 0, "Password Error", "The password is incorrect.", 2 ) IniWrite( "Users.ini", $USER, "RAN", "MIS" ) Shutdown( 4 ); Exit EndIf EndIf $LOOK = $LOOK + 1; HotKeySet( "!^p", "Password" ); HotKeySet( "!^e", "Killit" ); HotKeySet( "^1", "Time" ); EndFunc ;==>Password ;#################KILLIT##################### Func Killit() HotKeySet( "!^p", ); HotKeySet( "!^e", ); HotKeySet( "^1", ); If $LOOK < 60 Then $KILL = InputBox( "Houseparent Check", "Please enter the password." & @CRLF & "If an incorrect password is entered, you will not be able to log in again today.", "QWERTY", "*", 190, 160, -1, -1, 30) If $KILL = $HOUSEPARENT Then MsgBox( 0, "Exiting", "Logoff will now exit.", 2 ) Exit ElseIf @error = 1 Then SetError(0 ) Else MsgBox( 0, "Password Error", "The password is incorrect.", 2 ) IniWrite( "Users.ini", $USER, "RAN", "MIS" ) Shutdown( 4 ); Exit EndIf EndIf $LOOK = $LOOK + 1; HotKeySet( "!^p", "Password" ); HotKeySet( "!^e", "Killit" ); HotKeySet( "^1", "Time" ); EndFunc ;==>Killit Link to comment Share on other sites More sharing options...
emmanuel Posted June 10, 2004 Share Posted June 10, 2004 RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "your app's name", "REG_SZ", 'c:\path\app.exe') "I'm not even supposed to be here today!" -Dante (Hicks) Link to comment Share on other sites More sharing options...
pekster Posted June 10, 2004 Share Posted June 10, 2004 (edited) I am wondering how I can get this script to auto run on every startup for all users and disable task manager using the registry. It works fine with Hkey_Current_User but this would be a huge hassle if I have to go through and run it once for each individual user.I'm not sure about a setting globally, but I think that would be a bad idea even if it is doable because you might have some users that need to use the taskman (administrators, backup operators, etc.) However, why don't you place your script into the startup registry for all users? Then, you could test to make sure the user is not the administrator (or any other users you want to keep access to the taskman) and then change it for that user.To help you out, follow this link to a program calledl Startup Control Panel. It is very helpful in an administrative environment because it allows you to change common startup tasks, and startup tasks specific to a single user. For example, you can eaisily use the Startup Control Panel to add your compiled script into the HKLM/Run section of the registry, and then your script will disable the control panel for any specific user as soon as they log in. Just remember to test to make sure that administrator users do not have their setting changed, otherwise you won't be able to start it yourself.Also, you might want to change your system policy for users that will have this disabled so that they do not have permission to change the registry key. Otherwise, a more savy kid could simply use regedit, a reg file, or a scripting langauge to change it back themselves.Edited to make a bit more sense Edited June 10, 2004 by pekster [font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes. Link to comment Share on other sites More sharing options...
KnowledgeSponge Posted June 12, 2004 Author Share Posted June 12, 2004 (edited) Only the kids use the comps. They are house computers, 1 per house for the kids that live there. I figured out how to disable through system policies which are global. Where is the ability to disable registry access in system policies? Edited June 12, 2004 by KnowledgeSponge Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now