troubleshooting Question

Script for making changes in the registry

Avatar of expertblr
expertblr asked on
Windows Server 2003
10 Comments1 Solution1639 ViewsLast Modified:
Hi expert,

I have got a script(VBS) which disables the cd rom, floppy & usb store in the registry, which i have applied to O U in our domain controller(windows 2003) , i.e in windows settings -->startup. If any user computer is in that O U and after applying the script if the user restarts the machine the script will run at the startup and disables the cd rom, floppy & usb store. This script will disables the computers which are in that particular O U in which we have applied the script.

Now my problem is, i need a similar script which enables the cd rom, floppy and usb store which i will apply to another  O U so that if any user requests for enabling his computer CD Rom , floppy and USB store by moving his computer to this O U. The other option to enable these is by manually editing the registry.

Here i am attaching the script ( its a VB script) which is zipped (password is india@123). Pls let me know can we change the values in the script ie edit the same script for enabling. Pls let me know its very urgent.

'// This script will Disable CD FLOPPY USB system driver service
Dim oWsh,g_fVerbose
g_fVerbose = False
Set oWsh = WScript.CreateObject("WScript.Shell")

If WScript.Arguments.Named.Exists("V") Then g_fVerbose = True

      '// Disable support for USB Storage Devices
      ChangeMode "USBSTOR","DISABLE"
         '//oWsh.RegWrite "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR\Start", "00000004", "REG_DWORD"
      '// Disable support for Floppy disk
      ChangeMode "Flpydisk","DISABLE"
      '//oWsh.RegWrite "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Flpydisk\Start", "00000004", "REG_DWORD"

      '// Disable support for CDROM
      ChangeMode "Cdrom","DISABLE"
      '//oWsh.RegWrite "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Cdrom\Start", "00000004", "REG_DWORD"

Sub ChangeMode (strDeviceName,blnMode)

Dim strRegKey : strRegKey = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\"&strDeviceName&"\Start"
On Error Resume Next
Dim strTmp : strTmp = oWsh.RegRead (strRegKey)

      If strTmp <> Empty Then
      '// Key Already exists so change its value
            If blnMode = "DISABLE" Then
            '// Disable the Service
                  oWsh.RegWrite strRegKey , "00000004", "REG_DWORD"
                  oWsh.Run "cmd /c net stop """ & strDeviceName & """",0,False                  
            '// Enable the Service
                  oWsh.RegWrite strRegKey , "00000001", "REG_DWORD"
                  oWsh.Run "cmd /c net start """ & strDeviceName & """",0,False
            End If
      end if  
      '// Manage rights of user to read inf file
      '// CACLS.EXE stops for user input... which currently not able to automate
'      If blnMode = "ENABLE" Then
'            oWsh.Run "cmd /c cacls %systemroot%\inf\" & strDeviceName & ".inf /G BUILTIN\Users:R ""BUILTIN\Power Users:R"" BUILTIN\Administrators:F ""NT AUTHORITY\SYSTEM"":F",0,False      
'      Else
'            oWsh.Run "cmd /c cacls %systemroot%\inf\" & strDeviceName & ".inf /G BUILTIN\Administrators:F ""NT AUTHORITY\SYSTEM"":F",0,False
'      End If

End Sub


Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 10 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 10 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros