Cult of Frank Guest
|
Posted: Fri Apr 29, 2005 11:10 pm Post subject: CD Tray Lock/Unlock Programs |
|
|
This is my first script, just downloaded AutoHotKey today and tried it out. I must say that it's actually a terrific program and that the name is a bit of a misnomer since it's far more powerful than that. Thanks for saving me oodles of time, hope this can help someone...
There are two programs, one to lock the CD tray closed and one to unlock it. Locking is very simple and meant to run on startup without being noticed.
Unlocking will check if the current user is an admin, and if not, request the administrator's password (can be changed to be any user) before unlocking. If the user(s) to be locked out are also admins, you can easily bypass the exemption.
Finally, it logs all attempts at unlocking the drive to a specified location, with the date. The current user could easily be incorporated as well, but wasn't necessary for me.
CD LOCK
| Code: |
;
; AutoHotkey Version: 1.0.31.07
; Language: English
; Platform: Win9x/NT/XP
; Author: Dean Katsiris (katsiris@yahoo.com)
;
; Script Function:
; Locks CD Drive tray. Meant to be used on boot and in conjunction
; with CD Unlock to control access to the CD Player
;
#NoTrayIcon
Drive, Lock, D:
|
CD UNLOCK
| Code: |
;
; AutoHotkey Version: 1.0.31.07
; Language: English
; Platform: Win9x/NT/XP
; Author: Dean Katsiris (katsiris@yahoo.com)
;
; Script Function:
; To be used with CD Lock. This unlocks the CD tray again, prompting for
; a password if the current user is not an admin. This can be changed so
; that ALL users must enter a password. Be sure to change the user name
; where commented below so that you're authenticating from the correct
; user's password.
;
; Also, silently logs time/date of CD Unlock attempts to C:\CDunlock.log so
; an admin can later see if someone has succeeded/attempted to unlock.
; Path and filename easily changed, and could be made a hidden file.
;
; This was largely adapted from MikeG's password checking program here:
; http://www.autohotkey.com/forum/viewtopic.php?t=2110
;
#NoTrayIcon
; Admin doesn't need password to unlock
; Comment out to force administrator users to enter password
if (A_IsAdmin)
{
Drive, Unlock, D:
ExitApp
}
Loop
{
InputBox,pw,Unlock CD Drive,Password:,HIDE,,
If ErrorLevel
Exit
; CHANGE VALUE OF USER TO THE USER WHOSE PASSWORD UNLOCKS THE DRIVE
User=manager
GoSub,PassCheck
FormatTime,vDate,,
if (pw = "correct")
{
; CHANGE FILENAME AND PATH OF LOGFILE HERE
FileAppend, SUCCESS: %vDate%`r`n, C:\CDunlock.log
Drive, Unlock, D:
ExitApp
}
else
{
; CHANGE FILENAME AND PATH OF LOGFILE HERE (TO SAME AS ABOVE)
FileAppend, FAIL: %vDate%`r`n, C:\CDunlock.log
Msgbox, 4112, Invalid Password, You must enter the manager password to enable the CD-ROM
}
}
PassCheck:
RunAs,%User%,%pw%
RunWait,hh.exe,,UseErrorLevel
RunAs
If ErrorLevel=ERROR
pw=incorrect
Else
pw=correct
Return
|
|
|