' Device configurator ' (c)oded by offtopic@mail.ru 2004 ' on error resume next Domain = "cohovineyard" path="\\cohovineyard.com\SYSVOL\cohovineyard.com\scripts" Devices=Array("*floppy*", "*CDROM*") Services=Array("Flpydisk", "CDROM") Groups=Array("Floppy Users", "CDROM Users") SDDL="D:AR(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;DCRC;;;SID)(A;;CCLCSWLOCRRC;;;IU)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;SY)S:(AU;FA;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;WD)" Dim objGroup, Sid function Convert(u,l) For x = UBound(Sid)-u to UBound(Sid)-l Step -1 b = AscB(MidB(SID, x + 1)) sTmp = sTmp & Hex(b \ 16) & Hex(b And 15) Next Convert = Clng("&H" & sTmp) end function Function gSiD(aGroup) Dim sTmp, x, b Set objGroup = GetObject("WinNT://" & Domain & "/" & aGroup & ",group") Sid = objGroup.Get("objectSID") sTmp = "" gSID = "S-1-5-"&Convert(16,19)&"-"&Convert(12,15)&"-"&Convert(8,11)&"-"&Convert(4,7)&"-"&Convert(0,3) Set objGroup = Nothing End Function Set Args = WScript.Arguments Set fso = CreateObject("Scripting.FileSystemObject") set WshShell = WScript.CreateObject("WScript.Shell") strAction = Args(0) Sub EnableDev(device, service) set scriptState = WshShell.Exec("sc.exe config "&service&" start= demand") While (scriptState.Status = 0) WScript.Sleep(100) Wend s=scriptState.stdout.readall if instr(S, "Access is denied.")=0 then set scriptState = WshShell.Exec(path&"\devcon.exe enable "&device) While (scriptState.Status = 0) WScript.Sleep(100) Wend end if End Sub Sub DisableDev(device, service, group) set scriptState = WshShell.Exec("sc.exe config "&service&" start= disabled") While (scriptState.Status = 0) WScript.Sleep(100) Wend s=scriptState.stdout.readall if instr(S, "Access is denied.")=0 then s=gSID(group) s=Replace(SDDL, "SID", s) set scriptState = WshShell.Exec("sc.exe sdset "&service&" "&s) While (scriptState.Status = 0) WScript.Sleep(100) Wend set scriptState = WshShell.Exec(path&"\devcon.exe disable "&device) While (scriptState.Status = 0) WScript.Sleep(100) Wend end if End Sub if strAction="enable" then for i = 0 to UBound(Devices) Call EnableDev(Devices(i), Services(i)) Next else for i = 0 to UBound(Devices) Call DisableDev(Devices(i), Services(i), Groups(i)) Next end if