Jump to content

Someone Take A Look At This Code Please?


Recommended Posts

I have a vbs script which I call from the main_batch.cmd to try to prevent the automatically created user (from cmdlines.txt) from having to change his password after a few weeks.

The vbs is called using

ECHO.
ECHO turning password expiry off
%SystemDrive%\install\cscript //B passexpoff.vbs
ECHO.

and the script is called passexpoff.vbs

'
' Prevent password expiry on user %_USER% (environment variable)
'
' Run with:
'    cscript //B passexpoff.vbs
'
' Requires these environment variables:
'    COMPUTERNAME (the computer name according to the OS)
'    _USER (the user name to prevent password expiry on)
'
Option Explicit
Dim oWshShell, oWshEnvironment, userName, compName, usr, flag

Set oWshShell = CreateObject("WScript.Shell")
Set oWshEnvironment = oWshShell.Environment("Process")
userName = oWshEnvironment("_USER")
compName = oWshEnvironment("COMPUTERNAME")
Set usr = GetObject("WinNT://" & compName & "/" & userName)
flag = usr.Get("UserFlags")
if (flag AND &H10000 = 0) then
usr.Put "UserFlags", flag XOR &H10000
end if
usr.SetInfo

both are located in the %oem%\$1\install folder along with a copy of cscript

It doesn't appear to be doing the trick though. Any help is appreciated :)

By the way this is how I create a user that autologs in rather than the administrator on first boot. Perhaps there are switches for the "DefaultUserPassword" line that might disable password expires?

install.cmd

set _USER=Dood
net user %_USER% "" /add >nul
net localgroup administrators "%_USER%" /add>nul
%SystemRoot%\system32\reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v "DefaultUserName" /d "%_USER%" /f
%SystemRoot%\system32\reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v "DefaultUserPassword" /d "" /f
%SystemRoot%\system32\reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v "AutoAdminLogon" /d "1" /f

cmdlines.txt

[COMMANDS]
".\installs.cmd"

Link to comment
Share on other sites


just changed it to this and it works

Const ADS_UF_DONT_EXPIRE_PASSWD = &h10000

strDomainOrWorkgroup = "MSHOME"
strComputer = "OEM999"
strUser = "Dood"

Set objUser = GetObject("WinNT://" & strDomainOrWorkgroup & "/" & _
                       strComputer & "/" & strUser & ",User")

objUserFlags = objUser.Get("UserFlags")
objPasswordExpirationFlag = objUserFlags OR ADS_UF_DONT_EXPIRE_PASSWD
objUser.Put "userFlags", objPasswordExpirationFlag
objUser.SetInfo

Link to comment
Share on other sites

  • 4 weeks later...

I'm wondering if someone could help me on this...

When I call the vbs

ECHO turning password expiry off

%SystemDrive%\install\CScript //B passexpoff.vbs

ECHO.

I get an error saying "'C:\Documents and Settings\Alison\passexpoff.vbs was not found"

I'm not sure what "//B" is for....but I have cscript and passexpoff both in the install folder....

Can anyone tell me what I'm doing wrong? Thanks :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...