Here’s something for all you windows network admins out there.
(I apologize in advance to Johnathon’s linux followers)
Here’s a little script I wrote to be used as a group policy logoff script to remind users to remove their USB memory sticks/keys when logging off.
I wrote it while working in IT Support for a High School, to help out our IT teachers and ourselves as we were weekly gathering a collection of various USB Memory Sticks and memory keys (and since i was the one trying to reunite them with their owners each week.)
It’s written in VBS so it’s perfect for using as a group policy in active directory on say a Windows 2003 server/XP network. I haven’t tried it on Vista, Windows 7, or Server 2008 because I wasn’t using those technologies at the time, but it will most likely work with Vista and Windows 7 when deployed from a 2k3 or 2k8 server.
It detects removable drives (the type it looks for can be modified) that are connected and won’t pop-up without a drive detected.
If a USB drive is connected, it pops up a dialog reminding the user to take their memory stick with them and then auto-closes after a few seconds (as not to hang the logoff procedure).
I hope this is usefull to someone. If you use it, please leave me a comment.
[LICENCE GPL? NC-SA?]Also, feel free to modify and redistribute this script, but please don’t remove my details, as I’d like to know if it gets used and of any usefull additions others can think of.
' Script to display a list of drives connected to this machine
' MODIFIED to detect only removable drive. GTinsley 2008 @ Wallington County Grammar School.
' May cause false positives on some SATA 'puters.
' Tested working on 'puters with card readers.
Set FileSystemObject = CreateObject("Scripting.FileSystemObject") 'Create a filesystem object
Set Drives = FileSystemObject.Drives 'Create a drives collection
' Step through the drive collection, and get both the drive letter and the drive type.
' There are 6 distinct types of drive:
'Select Case DriveType
' Case "0" DriveType = "Unknown type of drive"
' Case "1" DriveType = "Removable drive"
' Case "2" DriveType = "Fixed drive"
' Case "3" DriveType = "Network drive"
' Case "4" DriveType = "CD-ROM drive"
' Case "5" DriveType = "RAM Disk"
For Each DiskDrive in Drives
DriveLetter = DiskDrive.DriveLetter
DriveType = DiskDrive.DriveType
' Check for a removable drive connected that:
' Is not the drive letter A B or C
' Folder exists (proves the drive exists)
IF Drivetype = "1" and not driveletter = "C" and not driveletter = "A" and not driveletter = "B" and FileSystemObject.FolderExists(driveletter & ":\") then
' Old method. Waits until user has clicked OK before logoff completes.
'WScript.Echo "The removable disk drive " & DriveLetter & " is a still connected. Don't forget your USB drive!"
' New method waits 5 seconds then logs off.
time_out = 5 ' wait max. 5 seconds
title = "Forgetting something?"
button = vbOKonly ' vbOKOnly
message = "The Removable Disk (" & DriveLetter & ":\) is a still connected. Don't forget your USB drive!"
Set objWSH = WScript.CreateObject("Wscript.Shell") ' create object
objWSH.Popup message, time_out, title, buttons ' popup
' Clear objects and collections
Set Drives = nothing
Set FileSystemObject = nothing