This article is copied from Spiceworks Community and should be used with ultimum care and importance
Got users taking company data or loading junk onto their computers? Take that extra security measure and block USBs, thanks to this easy-to-use script from fellow SpiceHead, Pradeep Bedse. You can block and unblock USB ports with a click of a button!
Got users taking company data or loading junk onto their computers? Take that extra security measure and block USBs, thanks to this easy-to-use script from fellow SpiceHead, Pradeep Bedse. You can block and unblock USB ports with a click of a button!
#notrayicon
applicationname=ProUsbtool
gosub iniread
Gui, Color, 808080
Gui, Add, Edit, x116 y60 w130 h20 vuser, %user%
Gui, Font, S8 Cwhite, Times New Roman
Gui, Add, Edit, x116 y100 w130 h20 +Password vpass, %pass%
Gui, Add, Text, x36 y120 w230 h20 +BackgroundTrans, *Please ignore to use "`%" sign in the password
Gui, Font, S11 Cwhite Bold, Times New Roman
Gui, Add, Text, x36 y60 w80 h20 +BackgroundTrans, AdminUser
Gui, Add, Text, x36 y100 w90 h20 +BackgroundTrans, Password
Gui, Add, Text, x16 y250 w160 h30 +BackgroundTrans vstatus, ....
Gui, Add, Text, x246 y100 w20 h30 +BackgroundTrans, *
Gui, Add, Button, x36 y160 w80 h30 gunblock +BackgroundTrans, UnBlock
Gui, Add, Button, x36 y200 w80 h30 gblock, Block
Gui, Add, Button, x136 y160 w110 h70 gguiclose, Exit
Gui, Add, Text, x86 y20 w120 h30 +BackgroundTrans, Pro USB Utility
Gui, Add, Text, x87 y21 w120 h30 cblack +BackgroundTrans, Pro USB Utility
Gui, Font, S5 CDefault, Verdana
Gui, Add, Text, x186 y260 w100 h10 , Script by: Pradeep Bedse
Gui, Add, GroupBox, x26 y140 w230 h100 ,
Gui, Add, GroupBox, x26 y40 w230 h100 ,
Gui, Add, Button, x266 y0 w20 h20 +BackgroundTrans , ?
Gui, Show, x340 y208 h289 w296,
return
applicationname=ProUsbtool
gosub iniread
Gui, Color, 808080
Gui, Add, Edit, x116 y60 w130 h20 vuser, %user%
Gui, Font, S8 Cwhite, Times New Roman
Gui, Add, Edit, x116 y100 w130 h20 +Password vpass, %pass%
Gui, Add, Text, x36 y120 w230 h20 +BackgroundTrans, *Please ignore to use "`%" sign in the password
Gui, Font, S11 Cwhite Bold, Times New Roman
Gui, Add, Text, x36 y60 w80 h20 +BackgroundTrans, AdminUser
Gui, Add, Text, x36 y100 w90 h20 +BackgroundTrans, Password
Gui, Add, Text, x16 y250 w160 h30 +BackgroundTrans vstatus, ....
Gui, Add, Text, x246 y100 w20 h30 +BackgroundTrans, *
Gui, Add, Button, x36 y160 w80 h30 gunblock +BackgroundTrans, UnBlock
Gui, Add, Button, x36 y200 w80 h30 gblock, Block
Gui, Add, Button, x136 y160 w110 h70 gguiclose, Exit
Gui, Add, Text, x86 y20 w120 h30 +BackgroundTrans, Pro USB Utility
Gui, Add, Text, x87 y21 w120 h30 cblack +BackgroundTrans, Pro USB Utility
Gui, Font, S5 CDefault, Verdana
Gui, Add, Text, x186 y260 w100 h10 , Script by: Pradeep Bedse
Gui, Add, GroupBox, x26 y140 w230 h100 ,
Gui, Add, GroupBox, x26 y40 w230 h100 ,
Gui, Add, Button, x266 y0 w20 h20 +BackgroundTrans , ?
Gui, Show, x340 y208 h289 w296,
return
unblock:
Gui,Submit,NoHide
RunAs, %user%, %pass%
runwait, cmd /c cacls %windir%\inf\UsbStor.inf /E /g users:f ,,hide|UseErrorLevel
if errorlevel
goto fail
else
runwait, cmd /c cacls %windir%\inf\UsbStor.inf /E /g everyone:f ,,hide|UseErrorLevel
runwait, cmd /c cacls %windir%\inf\UsbStor.inf /E /g administrators:f ,,hide|UseErrorLevel
regwrite,REG_DWORD, HKEY_LOCAL_MACHINE, SYSTEM\currentcontrolset\services\usbstor, start, 3
run RUNDLL32.EXE USER32.DLL`,UpdatePerUserSystemParameters `,1 `,True
{
gui,font,S8 csilver
GuiControl, Font, status
guicontrol,, status,UnBlocked Sucessfully
}
return
block:
Gui,Submit,NoHide
RunAs, %user%, %pass%
runwait, cmd /c cacls %windir%\inf\UsbStor.inf /E /d users ,,hide|UseErrorLevel
runwait, cmd /c cacls %windir%\inf\UsbStor.inf /E /d everyone ,,hide|UseErrorLevel
if errorlevel
goto fail
else
regwrite,REG_DWORD, HKEY_LOCAL_MACHINE, SYSTEM\currentcontrolset\services\usbstor, start, 4
run RUNDLL32.EXE USER32.DLL`,UpdatePerUserSystemParameters `,1 `,True
{
gui, font,S8 csilver
GuiControl, Font, status
guicontrol,, status,Blocked Sucessfully
}
gosub end
INIWRITE:
IniWrite,%user%,%applicationname%.ini,Settings,user
IniWrite,%pass%,%applicationname%.ini,Settings,pass
return
INIREAD:
IfNotExist,%applicationname%.ini
{
user=
pass=
Gosub,INIWRITE
}
IniRead,user, %applicationname%.ini,Settings, user
IniRead,pass, %applicationname%.ini,Settings, pass
return
fail:
{
gui, font,S8 cRed
GuiControl, Font, status
guicontrol,, status, Failed..
}
RunAs
end:
return
guiclose:
gosub, iniwrite
exitapp
Gui,Submit,NoHide
RunAs, %user%, %pass%
runwait, cmd /c cacls %windir%\inf\UsbStor.inf /E /g users:f ,,hide|UseErrorLevel
if errorlevel
goto fail
else
runwait, cmd /c cacls %windir%\inf\UsbStor.inf /E /g everyone:f ,,hide|UseErrorLevel
runwait, cmd /c cacls %windir%\inf\UsbStor.inf /E /g administrators:f ,,hide|UseErrorLevel
regwrite,REG_DWORD, HKEY_LOCAL_MACHINE, SYSTEM\currentcontrolset\services\usbstor, start, 3
run RUNDLL32.EXE USER32.DLL`,UpdatePerUserSystemParameters `,1 `,True
{
gui,font,S8 csilver
GuiControl, Font, status
guicontrol,, status,UnBlocked Sucessfully
}
return
block:
Gui,Submit,NoHide
RunAs, %user%, %pass%
runwait, cmd /c cacls %windir%\inf\UsbStor.inf /E /d users ,,hide|UseErrorLevel
runwait, cmd /c cacls %windir%\inf\UsbStor.inf /E /d everyone ,,hide|UseErrorLevel
if errorlevel
goto fail
else
regwrite,REG_DWORD, HKEY_LOCAL_MACHINE, SYSTEM\currentcontrolset\services\usbstor, start, 4
run RUNDLL32.EXE USER32.DLL`,UpdatePerUserSystemParameters `,1 `,True
{
gui, font,S8 csilver
GuiControl, Font, status
guicontrol,, status,Blocked Sucessfully
}
gosub end
INIWRITE:
IniWrite,%user%,%applicationname%.ini,Settings,user
IniWrite,%pass%,%applicationname%.ini,Settings,pass
return
INIREAD:
IfNotExist,%applicationname%.ini
{
user=
pass=
Gosub,INIWRITE
}
IniRead,user, %applicationname%.ini,Settings, user
IniRead,pass, %applicationname%.ini,Settings, pass
return
fail:
{
gui, font,S8 cRed
GuiControl, Font, status
guicontrol,, status, Failed..
}
RunAs
end:
return
guiclose:
gosub, iniwrite
exitapp