Windows 2003 to set Password in Domain Security Policy

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: IC (IC_at_discussions.microsoft.com)
Date: 03/01/05


Date: Mon, 28 Feb 2005 22:17:01 -0800

I had written a script where it set the Local Security Policy for Password
retention in Windows XP. I am having trouble trying to change the script to
function in Windows Server 2003 Active Directory Domain Security Policy.
Below is my script and I need help. Can someone assist me on how to modify my
script to work in Windows Server 2003? I need to update the Domain Security
Policy and not Domain Controller Security Policy.

Thank you in advance,

IC

'update the local policy
'Minimum Password Age = 0
'Maximum Password Age = 30
'Minimum Password Length = 10

<JOB>
<SCRIPT language="VBScript.Encode">
'**Start Encode**
Set wshShell = CreateObject("WScript.Shell")
Set fs = CreateObject("Scripting.FileSystemObject")
temp = fs.GetSpecialFolder(0) & "\temp"

Dim INFFilename
INFFilename = temp & "\passwd30_10.inf"
WriteInfFile
If getos = true Then
  ConfigurePolicyXP
Else
  ConfigurePolicyW2k
End If

Function getos
    set OSSet =
GetObject("winmgmts:{impersonationLevel=impersonate}!//./root/cimv2").ExecQuery("select * from Win32_OperatingSystem")
    For each OS in OSSet
        strOS = OS.Caption
    Next
    If InStr(stros,"XP") > 0 Then
            getos = true
    Else
      getos = false
    End If
End Function

Sub WriteInfFile
  Set output = fs.CreateTextFile(INFFilename, True)
  output.writeline("[Unicode]")
  output.writeline("Unicode=yes")
  output.writeline("[Version]")
  output.writeline("signature=""$CHICAGO$""")
  output.writeline("Revision=1")
  output.writeline("[Profile Description]")
  output.writeline("Description=Password Policy change / Maximum password
age 30 / Minimum password length 10")
  output.writeline("[System Access]")
  output.writeline("MinimumPasswordAge = 0")
  output.writeline("MaximumPasswordAge = 30")
  output.writeline("MinimumPasswordLength = 10")
  output.writeline("[Registry Values]")
  output.close
End Sub

Sub ConfigurePolicyXP
   Command = fs.GetSpecialFolder(1) & "\secedit /db " & temp & "\inport.db
/configure /cfg " & temp & "\passwd30_10.inf /overwrite /quiet "
   result = wshshell.Run(Command,0,false)
End Sub

Sub ConfigurePolicyW2k
   Command = fs.GetSpecialFolder(1) & "\secedit /db " & temp & "\inport.db
/configure /cfg " & temp & "\passwd30_10.inf /overwrite /quiet "
   result = wshshell.Run("cmd",2,false)
   wscript.sleep 500
   wshshell.sendkeys Command
   wscript.sleep 500
   wshshell.sendkeys "{ENTER}"
   wscript.sleep 2000
   wshshell.sendkeys "y {ENTER}"
   wscript.sleep 500
   wshshell.sendkeys "exit {ENTER}"
End Sub

</SCRIPT>
</JOB>



Relevant Pages

  • Re: wshController CreateScript errors
    ... Windows Explorer can browse each other's shared files OK. ... What seems ridiculous to me is that when I vary the Windows Firewall ... WScript.Echo "Deployment script complete." ... Sub remote_Start ...
    (microsoft.public.scripting.wsh)
  • Re: ADO in HTA script fails in Windows PE
    ... regarding compiling support for the ADO (SQL only) component... ... In short, you'll need an updated buildoptionalcomponent.vbs script, ... Windows User Group - Nordic ... >Sub Window_Onload ...
    (microsoft.public.windowsxp.setup_deployment)
  • Win32 Perl slowdown
    ... I'm running ActivePerl on Windows XP SP2. ... point my script suddenly took a lot longer to run, ... $string = stripTags; ... # This splicing sub is *really* inefficient, so feel free to omit it. ...
    (comp.lang.perl.misc)
  • Purge Old Files
    ... it does not work on XP or windows 2003 server. ... here a copy of the script file in .vbs ... Sub Main ...
    (microsoft.public.windows.server.scripting)
  • Windows 2003 to set Password in Domain Security Policy
    ... I had written a script where it set the Local Security Policy for Password ... function in Windows Server 2003 Active Directory Domain Security Policy. ... Sub WriteInfFile ...
    (microsoft.public.scripting.vbscript)