home *** CD-ROM | disk | FTP | other *** search
Text File | 2008-01-05 | 37.0 KB | 1,176 lines |
- '********************************************************************
- '*
- '* Copyright (c) Microsoft Corporation. All rights reserved.
- '*
- '* Module Name: SCregEdit.wsf
- '*
- '* Abstract: Enables an administrator to edit particular registry
- '* settings.
- '*
- '* Version # 1.0.0.1005
- '*
- '********************************************************************
-
- <job>
-
- <script language="VBScript">
-
-
- ' Global declaration
- OPTION EXPLICIT
-
- 'ON ERROR RESUME NEXT
- Err.Clear
- ' Set constants for use throughout script
- CONST HKEY_CURRENT_USER = &H80000001
- CONST HKEY_LOCAL_MACHINE = &H80000002
- const KEY_SET_VALUE = &H0001
- CONST ForReading = 1
-
- CONST VIEWQUICKKEY = "/v"
- CONST HELPSWITCH = "/?"
- CONST CLISWITCH = "/CLI"
- CONST REGMULTISZ = "REG_MULTI_SZ"
- CONST REGSZ = "REG_SZ"
- CONST REGDWORD = "REG_DWORD"
- CONST CONST_CSCRIPT = 2
-
- CONST strComputer = "."
-
- Dim bHasAccessRight
- ' Get command line arguments
- Dim objArgs, oReg
- Dim Resource, Resource2, Resource3, Resource4, LocSwitch
- Set objArgs = WScript.Arguments
- ' establish object references.
- Dim objFSO, FILEPATH, langFSO
- Set objFSO = CreateObject("Scripting.FileSystemObject")
- Set langFSO = CreateObject("Scripting.FileSystemObject")
- FILEPATH = objFSO.GetAbsolutePathName(strComputer) 'Current folder path
-
- Dim arrKeyList()
- Dim arrSwitchList()
-
-
- ' Check whether the script is run using CScript
- dim strScriptHost
-
- strScriptHost = Right((LCase(Wscript.FullName)), 11)
- If strScriptHost <> "cscript.exe" Then
-
- resource = GetLocalizedResource("L_UseCscript1_ErrorMessage")
- resource2 = GetLocalizedResource("L_UseCscript2E_ErrorMessage")
- resource3 = GetLocalizedResource("L_UseCscript3_ErrorMessage")
-
- WScript.Echo ( resource & vbCRLF & _
- ExpandEnvironmentString(resource2) & resource3 )
-
- WScript.Quit(1000)
-
- End If
-
-
- Call MainProcessingLoop
- ' ****************************************************************************************
- '* Function : MainProcessingLoop()
- '*
- '* Purpose : This function is the main processing loop for the application.
- '*
- '* Input:
- '* Output:
- '*
- ' ****************************************************************************************
- Sub MainProcessingLoop()
-
- ' Establish key values from text file to compare input.
-
- BuildKeyListArray()
-
- If objArgs.Count = 0 Then 'No arguments passed when running the script
- ShowHelpInfo(HELPSWITCH)
- ElseIf objArgs.Count = 1 Then
- ShowHelpInfo(lcase(objArgs(0)))
- elseif objArgs.count > 1 then
- if lcase(objArgs(0)) = VIEWQUICKKEY or lcase(objArgs(1)) = VIEWQUICKKEY then
- ' process view request
- if lcase(objArgs(0)) = VIEWQUICKKEY then
- ViewSwitch(lcase(objArgs(1)))
- else
- ViewSwitch(lcase(objArgs(0)))
- End If
- elseif objArgs(0) = HELPSWITCH or objArgs(1) = HELPSWITCH then
- if objArgs(0) = HELPSWITCH then
- ShowHelpInfo(lcase(objArgs(1)))
- else
- ShowHelpInfo(lcase(objArgs(0)))
- end if
- elseif objArgs(0) = CLISWITCH then
- ShowCliHelp()
- Else
- ProcessSwitch(lcase(objArgs(0)))
- End If
- End If
- End Sub
- ' ****************************************************************************************
- '* Function : ProcessSwitch
- '*
- '* Purpose : This function makes the updates to the registry based on the passed in switch
- '* and other command line arguments.
- '*
- '* Input: [in] switch The quick key for the registry entry to update
- '* Output:
- '*
- ' ****************************************************************************************
- Sub ProcessSwitch(switch)
- Dim k, arrValues, returnValue
- k = -1
-
- k = GetArrayElement(switch)
- if k <> -1 then
- If CheckArgs(switch) = True Then 'Check if number of args expected and given are same
- If SpecialCaseCheck(switch) = True Then
- 'Dim arrValues
- If arrKeyList(k)(3) = REGMULTISZ Then
- arrValues = Array(objArgs(1), objArgs(2), objArgs(3))
- Call SetMultiStringValue(strComputer,HKEY_LOCAL_MACHINE,arrKeyList(k)(2),arrKeyList(k)(1),arrValues) 'Setting the MultiString value
- ElseIf arrKeyList(k)(3) = REGSZ Then
- Call SetStringValue(strComputer, HKEY_LOCAL_MACHINE, arrKeyList(k)(2),arrKeyList(k)(1), CInt(objArgs(1))) 'Setting the MultiString value
- ElseIf arrKeyList(k)(3) = REGDWORD Then
- Call SetDWORDValue(strComputer, HKEY_LOCAL_MACHINE, arrKeyList(k)(2),arrKeyList(k)(1), Int(objArgs(1))) 'Setting the DWORD value
- End IF
- Else If SpecialCaseCheck(switch) = "AU" Then
- Call ConfigureAU(CInt(objArgs(1)))
- End If
-
- End If
- End If
- else
- resource = GetLocalizedResource("L10600")
- Wscript.Echo(resource)
- End If
-
- End Sub
- ' ****************************************************************************************
- '* Function : ViewSwitch()
- '*
- '* Purpose : This sub allows the viewing of all registry elements.
- '*
- '* Input: [in] switch the quickkey to the registry entry to view.
- '* Output:
- '*
- ' ****************************************************************************************
- Sub ViewSwitch(switch)
-
- dim k, returnValue
- returnValue = ""
- k = GetArrayElement(switch)
-
- if k <> -1 then
- select case arrKeyList(k)(3)
- case REGMULTISZ
- returnValue = ViewMultiStringValue(strComputer, HKEY_LOCAL_MACHINE, arrKeyList(k)(2), arrKeyList(k)(1))
- case REGDWORD
- returnValue = ViewDWORDValue(strComputer, HKEY_LOCAL_MACHINE, arrKeyList(k)(2), arrKeyList(k)(1))
- case REGSZ
- returnValue = ViewStringValue(strComputer, HKEY_LOCAL_MACHINE, arrKeyList(k)(2), arrKeyList(k)(1))
- end select
- Wscript.Echo(arrKeyList(k)(2) & " " & arrKeyList(k)(1))
- if isnull(returnValue) then
- resource = GetLocalizedResource("L10565")
- Wscript.Echo(resource)
- else
- resource = GetLocalizedResource("L10400")
- Wscript.Echo(resource)
- Wscript.Echo("" & returnValue)
- end if
- else
- resource = GetLocalizedResource("L10600")
- Wscript.Echo(resource)
- end if
-
- End Sub
-
- ' ****************************************************************************************
- '* Function : ShowHelpInfo()
- '*
- '* Purpose : This sub allows the viewing of help for a particular quick key.
- '*
- '* Input: [in] switch the quickkey to the registry entry to view help for.
- '* Output:
- '*
- ' ****************************************************************************************
- Sub ShowHelpInfo(switch)
- dim keyCounter, counter, count, HelpCount
- keyCounter = 0
- counter = 1
- dim helpLine
- If switch = "/?" Then
- 'au help
- Keycounter = 10
- count = 1
- For count = counter to keycounter
- helpline = "au" & count
- resource = GetLocalizedResource(helpline)
- Wscript.Echo(resource)
- If count = 4 or count = 5 or count = 7 Then
- Wscript.Echo()
- End If
- Next
- Wscript.Echo()
- Wscript.Echo()
- 'ar help
- Keycounter = 5
- count = 1
- For count = counter to keycounter
- helpline = "ar" & count
- resource = GetLocalizedResource(helpline)
- Wscript.Echo(resource)
- If count = 2 or count = 3 Then
- Wscript.Echo()
- End If
- Next
- HelpCount = 1
- For HelpCount = HelpCount to 2
- Wscript.Echo()
- Wscript.Echo()
- 'cs and im help
- Keycounter = 6
- count = 1
- For count = counter to keycounter
- If HelpCount = 1 then
- helpline = "cs" & count
- else
- helpline = "im" & count
- End If
- resource = GetLocalizedResource(helpline)
- Wscript.Echo(resource)
- If count = 3 or count = 4 Then
- Wscript.Echo()
- End If
- Next
- Next
- HelpCount = 1
- For HelpCount = HelpCount to 2
- Wscript.Echo()
- Wscript.Echo()
- 'dw and dp help
- Keycounter = 7
- count = 1
- For count = counter to keycounter
- If HelpCount = 1 then
- helpline = "dp" & count
- else
- helpline = "dw" & count
- End If
- resource = GetLocalizedResource(helpline)
- Wscript.Echo(resource)
- If count = 4 or count = 5 Then
- Wscript.Echo()
- End If
- Next
- Next
- Wscript.Echo()
- Wscript.Echo()
- 'cli help
- Keycounter = 4
- count = 1
- For count = counter to keycounter
- helpline = "cli" & count
- resource = GetLocalizedResource(helpline)
- Wscript.Echo(resource)
- If count = 3 Then
- Wscript.Echo()
- End If
- Next
- Else
- Select Case switch
- Case arrSwitchList(0)
- 'au help
- Keycounter = 10
- count = 1
- For count = counter to keycounter
- helpline = "au" & count
- resource = GetLocalizedResource(helpline)
- Wscript.Echo(resource)
- If count = 4 or count = 5 or count = 7 Then
- Wscript.Echo()
- End If
- Next
- Case arrSwitchList(1)
- 'ar help
- Keycounter = 5
- count = 1
- For count = counter to keycounter
- helpline = "ar" & count
- resource = GetLocalizedResource(helpline)
- Wscript.Echo(resource)
- If count = 2 or count = 3 Then
- Wscript.Echo()
- End If
- Next
- Case arrSwitchList(2)
- 'cs help
- Keycounter = 6
- count = 1
- For count = counter to keycounter
- helpline = "cs" & count
- resource = GetLocalizedResource(helpline)
- Wscript.Echo(resource)
- If count = 3 or count = 4 Then
- Wscript.Echo()
- End If
- Next
- Case arrSwitchList(3)
- 'im help
- Keycounter = 6
- count = 1
- For count = counter to keycounter
- helpline = "im" & count
- resource = GetLocalizedResource(helpline)
- Wscript.Echo(resource)
- If count = 3 or count = 4 Then
- Wscript.Echo()
- End If
- Next
- Case arrSwitchList(4)
- 'dp help
- Keycounter = 7
- count = 1
- For count = counter to keycounter
- helpline = "dp" & count
- resource = GetLocalizedResource(helpline)
- Wscript.Echo(resource)
- If count = 4 or count = 5 Then
- Wscript.Echo()
- End If
- Next
- Case arrSwitchList(5)
- 'dw help
- Keycounter = 7
- count = 1
- For count = counter to keycounter
- helpline = "dw" & count
- resource = GetLocalizedResource(helpline)
- Wscript.Echo(resource)
- If count = 4 or count = 5 Then
- Wscript.Echo()
- End If
- Next
- Case arrSwitchList(6)
- 'cli help
- ShowCliHelp()
- Case Else
- resource = GetLocalizedResource("L10600")
- Wscript.Echo(resource)
- End Select
- End If
- End Sub
-
- ' ****************************************************************************************
- '* Function : ShowCliHelp()
- '*
- '* Purpose : This sub displays the command line tool help.
- '*
- '* Input:
- '* Output:
- '*
- ' ****************************************************************************************
- Sub ShowCliHelp()
- dim keyCounter, counter, count, HelpCount
- keyCounter = 88
- counter = 0
- dim helpLine
- count = 1
- For count = counter to keycounter
- helpline = "L" & (10800 + count)
- resource = GetLocalizedResource(helpline)
- Wscript.Echo(resource)
- Next
- End Sub
-
- ' ****************************************************************************************
- '* Function : SpecialCaseCheck()
- '*
- '* Purpose : This sub allows the handling of special cases when editing registry entries.
- '*
- '* Input: [in] switch the quickkey to the registry entry to edit.
- '* Output: returns true if entry still needs to be updated. False if passed in values do
- '* not meet criteria or if value is already updated.
- '*
- ' ****************************************************************************************
- Function SpecialCaseCheck(switch)
- dim arrValues, k
- Select Case switch
- Case arrSwitchList(0)
- If IsNumeric(objArgs(1)) = True Then
- If objArgs(1) = 1 or objArgs(1) = 4 Then
- SpecialCaseCheck = "AU"
- Else
- resource = GetLocalizedResource("L10570")
- Wscript.Echo(resource)
- Wscript.Echo()
- ShowHelpInfo(switch)
- SpecialCaseCheck = false
- End If
- End If
- Case arrSwitchList(1)
- If IsNumeric(objArgs(1)) = True Then
- If objArgs(1) = 0 or objArgs(1) = 1 Then
- SpecialCaseCheck = True
- Else
- resource = GetLocalizedResource("L10580")
- Wscript.Echo(resource)
- Wscript.Echo()
- ShowHelpInfo(switch)
- SpecialCaseCheck = false
- End If
- End If
- Case arrSwitchList(2)
- If IsNumeric(objArgs(1)) = True Then
- If objArgs(1) = 0 or objArgs(1) = 1 Then
- SpecialCaseCheck = True
- Else
- resource = GetLocalizedResource("L10580")
- Wscript.Echo(resource)
- Wscript.Echo()
- ShowHelpInfo(switch)
- SpecialCaseCheck = false
- End If
- End If
- Case arrSwitchList(3)
- If IsNumeric(objArgs(1)) = True Then
- If objArgs(1) = 0 or objArgs(1) = 1 Then
- SpecialCaseCheck = True
- Else
- resource = GetLocalizedResource("L10580")
- Wscript.Echo(resource)
- Wscript.Echo()
- ShowHelpInfo(switch)
- SpecialCaseCheck = false
- End If
- End If
- Case arrSwitchList(4)
- If IsNumeric(objArgs(1)) = True Then
- If objArgs(1) >= 0 and objArgs(1) <= 65535 Then
- SpecialCaseCheck = True
- Else
- resource = GetLocalizedResource("L10590")
- Wscript.Echo(resource)
- Wscript.Echo()
- ShowHelpInfo(switch)
- SpecialCaseCheck = false
- End If
- End If
- Case arrSwitchList(5)
- If IsNumeric(objArgs(1)) = True Then
- If objArgs(1) >= 0 and objArgs(1) <= 65535 Then
- SpecialCaseCheck = True
- Else
- resource = GetLocalizedResource("L10590")
- Wscript.Echo(resource)
- Wscript.Echo()
- ShowHelpInfo(switch)
- SpecialCaseCheck = false
- End If
- End If
-
- Case Else
- SpecialCaseCheck = True
- End Select
- End Function
-
- ' ****************************************************************************************
- '* Function : GetArrayElement()
- '*
- '* Purpose : This function determines which array value has the passed in switch
- '*
- '* Input: [in] switch the quickkey to the registry entry to view.
- '* Output: returns the index of the array that contains the switch.
- '*
- ' ****************************************************************************************
- Function GetArrayElement(switch)
- dim k, returnValue
-
- returnValue = -1
-
- For k = 0 to Ubound(arrKeyList)
- If arrKeyList(k)(0) = switch Then 'Find the array wtih first element as the switch in the arrKeyList array
- returnValue = k
- end if
- Next
-
- GetArrayElement = returnValue
-
- End Function
- ' ****************************************************************************************
- '* Function : BuildKeyListArray()
- '*
- '* Purpose : This sub sets a global array used throughout the script
- '*
- '* Input:
- '* Output:
- '*
- ' ****************************************************************************************
- Sub BuildKeyListArray()
-
- dim count, counter, keyCounter, RegCounter
- dim regvalue
- dim inputLine
- Dim arrValues
-
- keyCounter = 0
- counter = 0
-
- 'Recounter must equal the number of registry switches supported - 1
- Regcounter = 6
- count = 0
- For count = counter to RegCounter
- regvalue = "reg" & count
- inputLine = GetLocalizedResource(regvalue)
- arrValues = split(inputLine, ",") ' If not, then put the comma seperated line into an array
- ReDim Preserve arrKeyList(keyCounter) 'Since we don't know how many switches are present in the file
- arrKeyList(keyCounter) = arrValues 'For each switch from arrValues put it into arrKeyList
- keyCounter = keyCounter + 1
- Next
-
- keyCounter = 0
- counter = 0
- count = 0
- For count = counter to RegCounter
- regvalue = "switch" & count
- inputLine = GetLocalizedResource(regvalue)
- 'arrValues = split(inputLine, ",") ' If not, then put the comma seperated line into an array
- ReDim Preserve arrSwitchList(keyCounter) 'Since we don't know how many switches are present in the file
- arrSwitchList(keyCounter) = inputLine 'For each switch from arrValues put it into arrKeyList
- keyCounter = keyCounter + 1
- Next
-
-
-
- End Sub
-
- ' ****************************************************************************************
- '* Function : SetMultiStringValue()
- '*
- '* Purpose : This sub is the generic function to set a multi string registry key.
- '*
- '* Input: [in] strComputer the name of the computer
- '* [in] root The root of the registry entry to update.
- '* [in] strKeyPath path to registry entry to update.
- '* [in] strValueName value name of registry entry to update.
- '* [in] arrValues array of values to update.
- '* Output:
- '*
- ' ****************************************************************************************
- Sub SetMultiStringValue(strComputer,root,strKeyPath, strValueName, arrValues)
-
- Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
- strComputer & "\root\default:StdRegProv")
-
-
- oReg.CheckAccess root, strKeyPath, _
- KEY_SET_VALUE, bHasAccessRight
-
- If bHasAccessRight = True Then
- oReg.SetMultiStringValue root,strKeyPath,strValueName,arrValues
- resource = GetLocalizedResource("L10440")
- Wscript.Echo(resource)
- Else
- resource = GetLocalizedResource("L10610")
- Wscript.Echo(resource)
- Wscript.Echo()
- End If
-
- End Sub
- ' ****************************************************************************************
- '* Function : ViewMultiStringValue()
- '*
- '* Purpose : This sub is the generic function to view a multi string registry key.
- '*
- '* Input: [in] strComputer the name of the computer
- '* [in] root The root of the registry entry to update.
- '* [in] strKeyPath path to registry entry to update.
- '* [in] strValueName value name of registry entry to update.
- '* Output:
- '*
- ' ****************************************************************************************
- Function ViewMultiStringValue(strComputer, root, strKeyPath, strValueName)
-
- dim i, arrValues, strValue, returnValue
-
- Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
- strComputer & "\root\default:StdRegProv")
-
- oReg.GetMultiStringValue root ,strKeyPath, _
- strValueName,arrValues
-
- For Each strValue In arrValues
- returnValue = returnValue & strValue & " "
- Next
-
- ViewMultiStringValue = returnValue
-
- End Function
- ' ****************************************************************************************
- '* Function : SetStringValue()
- '*
- '* Purpose : This sub is the generic function to set a string registry key.
- '*
- '* Input: [in] strComputer the name of the computer
- '* [in] root The root of the registry entry to update.
- '* [in] strKeyPath path to registry entry to update.
- '* [in] strValueName value name of registry entry to update.
- '* [in] strValue value to update.
- '* Output:
- '*
- ' ****************************************************************************************
- Sub SetStringValue(strComputer, root, strKeyPath, strValueName, strValue)
-
- Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
- strComputer & "\root\default:StdRegProv")
-
-
- oReg.CheckAccess root, strKeyPath, _
- KEY_SET_VALUE, bHasAccessRight
-
- If bHasAccessRight = True Then
- oReg.SetStringValue root ,strKeyPath, strValueName, strValue
- resource = GetLocalizedResource("L10440")
- Wscript.Echo(resource)
- Else
- resource = GetLocalizedResource("L10610")
- Wscript.Echo(resource)
- Wscript.Echo()
- End If
-
-
-
- End Sub
- ' ****************************************************************************************
- '* Function : ViewStringValue()
- '*
- '* Purpose : This sub is the generic function to view a string registry key.
- '*
- '* Input: [in] strComputer the name of the computer
- '* [in] root The root of the registry entry to update.
- '* [in] strKeyPath path to registry entry to update.
- '* [in] strValueName value name of registry entry to update.
- '* Output:
- '*
- ' ****************************************************************************************
- Function ViewStringValue(strComputer, root, strKeyPath, strValueName)
-
- dim strValue
-
- Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
- strComputer & "\root\default:StdRegProv")
-
- oReg.GetStringValue root,strKeyPath,strValueName,strValue
-
- ViewStringValue = strValue
-
- End Function
- ' ****************************************************************************************
- '* Function : SetDWORDValue()
- '*
- '* Purpose : This sub is the generic function to set a dword registry key.
- '*
- '* Input: [in] strComputer the name of the computer
- '* [in] root The root of the registry entry to update.
- '* [in] strKeyPath path to registry entry to update.
- '* [in] strValueName value name of registry entry to update.
- '* [in] dwValue value to update.
- '* Output:
- '*
- ' ****************************************************************************************
- Sub SetDWORDValue(strComputer, root, strKeyPath, strValueName, dwValue)
-
- dim NewKeyValue, resource, resource2, service, obj, objset
-
- Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
- strComputer & "\root\default:StdRegProv")
-
- oReg.CheckAccess root, strKeyPath, KEY_SET_VALUE, bHasAccessRight
-
- resource2 = GetLocalizedResource("L10780")
-
-
- If bHasAccessRight = True Then
- If resource2 = strValueName then
- ' oReg.SetDWORDValue root ,strKeyPath, strValueName, CLng(dwValue)
- Set Service = GetObject("winmgmts:{authenticationLevel=PktPrivacy}!root\cimv2\TerminalServices")
- set objSet=Service.ExecQuery("select * from Win32_TerminalServiceSetting")
- for each obj in objSet
- If dwValue = 1 then
- If obj.AllowTSConnections = 0 Then
- 'already disabled
- else
- obj.SetAllowTSConnections 0,0
- end if
- else
- If obj.AllowTSConnections = 1 Then
- 'already enabled
- else
- obj.SetAllowTSConnections 1,1
- end if
- end if
- obj.refresh_
- next
- resource = GetLocalizedResource("L10440")
- Wscript.Echo(resource)
- else
- oReg.SetDWORDValue root ,strKeyPath, strValueName, CLng(dwValue)
- resource = GetLocalizedResource("L10440")
- Wscript.Echo(resource)
- end if
- Else
- resource = GetLocalizedResource("L10610")
- Wscript.Echo(resource)
- Wscript.Echo()
- End If
-
-
- End Sub
- ' ****************************************************************************************
- '* Function : ViewDWORDValue()
- '*
- '* Purpose : This sub is the generic function to view a dword registry key.
- '*
- '* Input: [in] strComputer the name of the computer
- '* [in] root The root of the registry entry to update.
- '* [in] strKeyPath path to registry entry to update.
- '* [in] strValueName value name of registry entry to update.
- '* Output:
- '*
- ' ****************************************************************************************
- Function ViewDWordValue(strComputer, root, strKeyPath, strValueName)
-
- dim dwValue
-
- Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
- strComputer & "\root\default:StdRegProv")
-
- oReg.GetDWORDValue root,strKeyPath,strValueName,dwValue
-
- ViewDWordValue = dwValue
-
- End Function
- ' ****************************************************************************************
- '* Function : ConfigureAU()
- '*
- '* Purpose : This sub is the function to set AutoUpdate.
- '*
- '* Input: [in] strComputer the name of the computer
- '* [in] root The root of the registry entry to update.
- '* [in] strKeyPath path to registry entry to update.
- '* [in] strValueName value name of registry entry to update.
- '* Output:
- '*
- ' ****************************************************************************************
- Function ConfigureAU(strValueName)
-
- dim settingChanged, AU, AUSettings
-
- set AU = CreateObject("Microsoft.Update.AutoUpdate")
- set AUSettings = AU.Settings
-
- AUSettings.NotificationLevel=strValueName
- settingChanged = TRUE
- AUSettings.Save
- resource = GetLocalizedResource("L10440")
- Wscript.Echo(resource)
-
- End Function
- ' ****************************************************************************************
- '* Function : CheckArgs()
- '*
- '* Purpose : This function checks validity of command line parameters.
- '*
- '* Input: [in] key passed in quick key
- '* Output:
- '*
- ' ****************************************************************************************
- Function CheckArgs(key)
- Dim p,v, status
- status = true
- For p = 0 to Ubound(arrKeyList)
- If arrKeyList(p)(0) = key Then
- If arrKeyList(p)(3) = "REG_MULTI_SZ" Then
- If(Ubound(arrKeyList(p)) - 3) = (objArgs.Count - 1) Then
- For v = 4 To Ubound(arrKeyList(p))
- If arrKeyList(p)(v) = "REG_SZ" Then
- If TypeName(objArgs(v - 3)) = "String" Then
- 'do nothing
- Else
- resource = GetLocalizedResource("L10500")
- resource2 = GetLocalizedResource("L10540")
- Wscript.Echo(resource & v-3 & ": " & resource2)
- status = false
- CheckArgs = false
- End If
- ElseIf arrKeyList(p)(v) = "REG_DWORD" Then
- If IsNumeric(objArgs(v - 3)) = True Then
- 'do nothing
- Else
- resource = GetLocalizedResource("L10500")
- resource2 = GetLocalizedResource("L10530")
- Wscript.Echo(resource & v-3 & ": " & resource2)
- status = false
- CheckArgs = false
- End If
- End If
- Next
- Else
- resource = GetLocalizedResource("L10510")
- Wscript.Echo(resource)
- status = false
- CheckArgs = false
- End If
- ElseIf arrKeyList(p)(3) = "REG_SZ" Then
- If TypeName(objArgs(1)) = "String" Then
- 'do nothing
- Else
- resource = GetLocalizedResource("L10500")
- resource2 = GetLocalizedResource("L10540")
- Wscript.Echo(resource & " 1 : " & resource2)
- status = false
- CheckArgs = false
- End If
- ElseIf arrKeyList(p)(3) = "REG_DWORD" Then
- If IsNumeric(objArgs(1)) = True Then
- 'do nothing
- Else
- resource = GetLocalizedResource("L10500")
- resource2 = GetLocalizedResource("L10530")
- Wscript.Echo(resource & " 1 : " & resource2)
- status = false
- CheckArgs = false
- End If
- End If
- End If
- Next
-
- If status = false Then
- CheckArgs = false
- Else
- CheckArgs = True
- End If
- End Function
- ' ****************************************************************************************
- '* Function : ExpandEnvironmentString()
- '*
- '* Purpose:This function Expands the Environment Variables
- '*
- '* Input: [in] strOriginalString the string need to expand for EnvironmentsettingValue
- '* Output: Returns ExpandedEnvironmentString
- '*
- ' ****************************************************************************************
- Private Function ExpandEnvironmentString( ByVal strOriginalString)
-
- ON ERROR RESUME NEXT
- Err.Clear
-
- Dim ObjWshShell ' Object to hold Shell
-
- Set ObjWshShell = CreateObject("WScript.Shell")
- ExpandEnvironmentString= ObjWshShell.ExpandEnvironmentStrings(strOriginalString)
-
- End Function
-
-
-
- ' ****************************************************************************************
- '* Function :
- '*
- '* Purpose: The following functions find the language appropriate strings
- '*
- '* Input:
- '* Output:
- '*
- ' ****************************************************************************************
- ' Get a localized resources for 'resourceID' if available; otherwise, get the neutral resource.
- Function GetLocalizedResource(resourceID)
- Const ForReading = 1, TristateUseDefault = -2
-
- Dim lang, value, ini
-
-
- lang = GetUILanguage()
-
- ini = langFSO.GetParentFolderName(WScript.ScriptFullName) & "\" _
- & ToHex(lang) & "\" & langFSO.GetBaseName(WScript.ScriptName) & ".ini"
-
- If langFSO.FileExists(ini) Then
- Dim stream, file
-
- Debug.WriteLine "Using resource file " & ini
-
- Set file = langFSO.GetFile(ini)
- Set stream = file.OpenAsTextStream(ForReading, TristateUseDefault)
- value = ReadResource(stream, resourceID)
- End If
-
- If Not IsEmpty(value) Then
- GetLocalizedResource = value
- Else
- Debug.WriteLine "Falling back to neutral resource in script file"
- GetLocalizedResource = getResource(resourceID)
- End If
- End Function
-
- ' Read a resource ID from the TextStream
- Function ReadResource(stream, resourceID)
- Const ERROR_FILE_NOT_FOUND = 2
- Dim ln, arr, key, value
-
- If Not IsObject(stream) Then Err.Raise ERROR_FILE_NOT_FOUND
-
- Do Until stream.AtEndOfStream
- ln = stream.ReadLine
-
- arr = Split(ln, "=", 2, 0)
- If UBound(arr, 1) = 1 Then
- ' Trim the key and the value first before trimming quotes
- key = Trim(arr(0))
-
- If resourceID = key Then
- Debug.WriteLine "Found key " & key
- value = TrimChar(Trim(arr(1)), """")
- ReadResource = value
- Exit Do
- End If
- End If
- Loop
-
- stream.Close
- End Function
-
- ' Trim a character from the text string
- Function TrimChar(s, c)
- Const vbTextCompare = 1
-
- ' Trim character from the start
- If Left( s, 1 ) = c Then
- s = Mid(s, 2)
- End If
-
- ' Trim character from the end
- If Right(s, 1) = c Then
- s = Mid(s, 1, Len(s) - 1)
- End If
-
- TrimChar = s
- End Function
-
- ' Get a 4-digit hexadecimal number
- Function ToHex(n)
- Dim s : s = Hex(n)
- ToHex = String(4 - Len(s), "0") & s
- End Function
-
-
- ' If the localized ini file isn't found, read the resources from the script.
- Function getResource(resourceID)
- Const ForReading = 1, TristateUseDefault = -2
-
- Dim lang, value, script
-
- script = langFSO.GetParentFolderName(WScript.ScriptFullName) & "\" & langFSO.GetBaseName(WScript.ScriptName) & ".wsf"
-
- If langFSO.FileExists(script) Then
- Dim stream, file
-
- Debug.WriteLine "Using resource file " & script
-
- Set file = langFSO.GetFile(script)
- Set stream = file.OpenAsTextStream(ForReading, TristateUseDefault)
- value = ReadResource(stream, resourceID)
- End If
-
- getResource = value
- End Function
-
-
- </script>
-
- <!-- Neutral language resources -->
-
- L_UseCscript1_ErrorMessage="This script should be executed from the command prompt using CSCRIPT.EXE. For example:"
- L_UseCscript2E_ErrorMessage=" CSCRIPT %systemroot%\system32\SCREGEDIT.WSF "
- L_UseCscript3_ErrorMessage="arguments"
-
- L10400="View registry setting."
- L10440="Registry has been updated."
- L10450="You must restart the "IPSec Policy Agent" before the change will take effect."
- L10500="Parameter"
- L10510="Expected 3 parameters."
- L10520="Parameter type mismatch"
- L10530="Parameter type mismatch expected DWord."
- L10540="Parameter type mismatch expected string."
- L10565="Value not set."
- L10570="Value should be either 1 or 4"
- L10575="Value should be either 1, 2, or 3"
- L10580="Value should be either 0 or 1"
- L10590="Value should be from 0 through 65535"
- L10600="Invalid switch - run scregedit.wsf /? For the list of supported switches."
- L10610="You do not have permission to modify the registry."
- L10780="fDenyTSConnections"
- L10800="To activate:"
- L10801=" Cscript slmgr.vbs -ato"
- L10802=" "
- L10803="To use KMS volume licensing for activation:"
- L10804=" Configure KMS volume licensing:"
- L10805=" cscript slmgr.vbs -ipk [volume license key]"
- L10806=" Activate KMS licensing"
- L10807=" cscript slmgr.vbs -ato"
- L10808=" Set KMS DNS SRV record"
- L10809=" cscript slmgr.vbs -skma [KMS FQDN]"
- L10810=" "
- L10811="Determine the computer name, any of the following:"
- L10812=" Set c"
- L10813=" Ipconfig /all"
- L10814=" Systeminfo.exe or Hostname.exe"
- L10815=" "
- L10816="Rename the Server Core computer:"
- L10817=" Domain joined:"
- L10818=" Netdom renamecomputer %computername% /NewName:new-name /UserD:domain-username /PasswordD:*"
- L10819=" Not domain joined:"
- L10820=" Netdom renamecomputer %computername% /NewName:new-name"
- L10821=" "
- L10822="Changing workgroups:"
- L10823=" Wmic computersystem where name="%computername%" call joindomainorworkgroup name="[new workgroup name]" "
- L10824=" "
- L10825="Install a role or optional feature:"
- L10826=" Start /w Ocsetup [packagename]"
- L10827=" Note: For Active Directory, run Dcpromo with an answer file."
- L10828=" "
- L10829="View role and optional feature package names and current installation state:"
- L10830=" oclist"
- L10831=" "
- L10832="Start task manager hot-key: "
- L10833=" ctrl-shift-esc"
- L10834=" "
- L10835="Logoff of a Terminal Services session:"
- L10836=" Logoff"
- L10837=" "
- L10838="To set the pagefile size:"
- L10839=" Disable system pagefile management: "
- L10840=" wmic computersystem where name="%computername%" set AutomaticManagedPagefile=False"
- L10841=" Configure the pagefile:"
- L10842=" wmic pagefileset where name="C:\\pagefile.sys" set InitialSize=500,MaximumSize=1000"
- L10843=" "
- L10844="Configure the timezone, date, or time:"
- L10845=" control timedate.cpl"
- L10846=" "
- L10847="Configure regional and language options:"
- L10848=" control intl.cpl"
- L10849=" "
- L10850="Manually install a management tool or agent:"
- L10851=" Msiexec.exe /i [msipackage]"
- L10852=" "
- L10853="List installed msi applications:"
- L10854=" Wmic product"
- L10855=" "
- L10856="Uninstall msi applications:"
- L10857=" Wmic product get name /value "
- L10858=" Wmic product where name="[name]" call uninstall"
- L10859=" "
- L10860="To list installed drivers:"
- L10861=" Sc query type= driver"
- L10862=" "
- L10863="Install a driver that is not included:"
- L10864=" Copy the driver files to Server Core"
- L10865=" Pnputil ûi ûa [path]\[driver].inf"
- L10866=" "
- L10867="Rename a Network Adapter:"
- L10868=" netsh interface set interface name="Local Area Connection" newname="PrivateNetwork""
- L10869=" "
- L10870="Disable a Network Adapter:"
- L10871=" netsh interface set interface name="Local Area Connection 2" admin=DISABLED"
- L10872=" "
- L10873="Determine a fileÆs version:"
- L10874=" wmic datafile where name="c:\\windows\\system32\\ntdll.dll" get version"
- L10875=" "
- L10876="List of installed patches:"
- L10877=" wmic qfe list"
- L10878=" "
- L10879="Install a patch:"
- L10880=" Wusa.exe [patchame].msu /quiet"
- L10881=" "
- L10882="Configure a proxy:"
- L10883=" Netsh winhttp set proxy [proxy_name]:[port]"
- L10884=" "
- L10885="Add, delete, query a Registry value:"
- L10886=" reg.exe add /?"
- L10887=" reg.exe delete /?"
- L10888=" reg.exe query /?"
-
- au1="Automatic Updates - Manage Automatic Windows Updates "
- au2="These settings can be used to configure how Automatic Updates are applied to "
- au3="the Windows system. It includes the ability to disable automatic updates and "
- au4="to set the installation schedule."
- au5="/AU [/v][value]"
- au6=" /v View the current Automatic Update settings"
- au7=" value value you want to set to."
- au8=" Options:"
- au9=" 4 - Enable Automatic Updates "
- au10=" 1 - Disable Automatic Updates "
-
- ar1="Terminal Service - Allow Remote Administration Connections"
- ar2="This allows administrators to connect remotely for administration purposes."
- ar3="/AR [/v][value]"
- ar4=" /v View the Remote Terminal Service Connection setting"
- ar5=" value (0 = enabled, 1 = disabled)"
-
- cs1="Terminal Service - Allow connections from previous versions of Windows"
- cs2="This setting configures CredSSP based user authentication for"
- cs3="Terminal Service connections"
- cs4="/CS [/v][value]"
- cs5=" /v View the Terminal Service CredSSP setting"
- cs6=" value (0 = allow previous versions, 1 = require CredSSP)"
-
- im1="IP Security (IPSEC) Monitor - allow remote management"
- im2="This setting configures the server to allow the IP Security (IPSEC) Monitor to "
- im3="be able to remotely manage IPSEC."
- im4="/IM [/v][value]"
- im5=" /v View the IPSEC Monitor setting"
- im6=" value (0 = do not allow, 1 = allow remote management)"
-
- dp1="DNS SRV priority - changes the priority for DNS SRV records"
- dp2="This setting configures the priority for DNS SRV records and is only useful "
- dp3="on Domain Controllers."
- dp4="For more information on this setting, search TechNet for LdapSrvPriority"
- dp5="/DP [/v][value]"
- dp6=" /v View the DNS SRV priority setting"
- dp7=" value (value from 0 through 65535. The recommended value is 200.)"
-
- dw1="DNS SRV weight - changes the weight for DNS SRV records"
- dw2="This setting configures the weight for DNS SRV records and is only useful "
- dw3="on Domain Controllers."
- dw4="For more information on this setting, search TechNet for LdapSrvWeight"
- dw5="/DW [/v][value]"
- dw6=" /v View the DNS SRV weight setting"
- dw7=" value (value from 0 through 65535. The recommended value is 50.)"
-
- cli1="Command Line Reference"
- cli2="This setting displays a list of common tasks and how to perform them from"
- cli3="the command line."
- cli4="/CLI"
-
- reg0="/au,AUOptions,SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update,REG_DWORD,REG_DWORD"
- reg1="/ar,fDenyTSConnections,System\CurrentControlSet\Control\Terminal Server,REG_DWORD,REG_DWORD"
- reg2="/cs,UserAuthentication,System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp,REG_DWORD,REG_DWORD"
- reg3="/im,EnableRemoteMgmt,SYSTEM\CurrentControlSet\Services\PolicyAgent,REG_DWORD,REG_DWORD"
- reg4="/dp,LdapSrvPriority,SYSTEM\CurrentControlSet\Services\Netlogon\Parameters,REG_DWORD,REG_DWORD"
- reg5="/dw,LdapSrvWeight,SYSTEM\CurrentControlSet\Services\Netlogon\Parameters,REG_DWORD,REG_DWORD"
- reg6="/cli,none,none,none,none"
-
- switch0="/au"
- switch1="/ar"
- switch2="/cs"
- switch3="/im"
- switch4="/dp"
- switch5="/dw"
- switch6="/cli"
-
- </job>