Here is the complete script. I have't added the 'case' to it. I'm having a couple of problems:
1) It seems to be looping through some of the routines.
2) If the user has to be created then the HKCU registry settings that are being created won't apply for the newly created user
There might be better ways to code some of the routines
All I can do with this type of code is hack at it.
Code:
On Error Resume Next
Dim objWShell
Set objWShell = WScript.CreateObject("WScript.Shell")
getVersionNumber = objWShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\CurrentVersion")
getOsType = objWShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE")
getProductName = objWShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductName")
ComputerName = "WinIDS"
accUserName = "Cracker"
accUserPass = "p@ss"
'This tests for x86 processor architecture, and exits if not. Install is not 64bit capable.
If getOsType = "x86" Then
'This tests for Windows Windows 7 (6.1), and continues script if not.
If getVersionNumber = "6.1" Then
msgbox "Version detected is : " & getVersionNumber
'This forces UAC to be disabled during script execution.
If WScript.Arguments.length =0 Then
Set objShell = CreateObject("Shell.Application")
objShell.ShellExecute "wscript.exe", Chr(34) & _
WScript.ScriptFullName & Chr(34) & " uac", "", "runas", 1
Else
'Sets registry to disable ELUA, Show Hidden files and folders, and display file extensions.
objWShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\EnableLUA", "0", "REG_DWORD"
'The below two can not be created for user Operator if that account has to be created.
objWShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Hidden", "1", "REG_DWORD"
objWShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\HideFileExt", "0", "REG_DWORD"
'This changes the computer name for Windows 7.
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colComputers = objWMIService.ExecQuery ("Select * from Win32_ComputerSystem")
objComputer = "."
For Each objComputer In colComputers
err = objComputer.Rename(ComputerName)
Next
Set objWMIService = Nothing
Set colComputera = Nothing
End if
ElseIf getVersionNumber = "5.1" or getVersionNumber = "5.2" Then
msgbox "Version detected is : " & getVersionNumber
'This sets registry to Show Hidden files and folders, and display file extensions.
'The below two can not be created for user Operator if that account has to be created.
objWShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Hidden", "1", "REG_DWORD"
objWShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\HideFileExt", "0", "REG_DWORD"
'This changes the computer name for Windows XP or Windows Server 2003.
objWShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName\ComputerName", computerName
objWShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\ParameterS\NV Hostname", computerName
Else
Msgbox "The OS Product Name is " & getProductName & ", and is not supported!" & VbCrLf & VbCrLf & "Supported Product Names: XP SP3, Server 2003 SP2, and Windows 7",vbokonly,"Detecting Product Name..."
WScript.Quit
End If
Else
Msgbox "The detected processor architecture is: " & getOsType & VbCrLf & VbCrLf & "The WinIDS install only supports 32bit architecture at this time!",vbokonly,"Detecting Processor Architecture..."
WScript.Quit
End If
'This tests for a specific username and creates a user account if it does not exist.
msgbox "Checking for " & accUserName & " , and creating if not found."
QueryForUser(accUserName)
'This reates the new username if it doesn't exist
Set objNetwork = CreateObject("Wscript.Network")
strComputer = objNetwork.ComputerName
Set objComputer = GetObject("WinNT://" &strComputer)
Set colAccounts = GetObject("WinNT://" & strComputer & "")
Set objUser = colAccounts.Create("user", accUserName)
objUser.SetPassword accUserPass
objUser.Put "UserFlags", 65600
objUser.SetInfo
'This adds user to Administrators group
msgbox "Creating new user " & accUserName & " , and adding to Administrators group!"
Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators,group")
Set objUser = GetObject("WinNT://" & strComputer & "/" & accUserName & ",user")
objGroup.Add(objUser.ADsPath)
'This changes the password if the user exists
Sub QueryForUser(accUserName)
Set objlocal = GetObject("WinNT://.")
objlocal.Filter = Array("user")
For Each User In objlocal
If lcase(User.Name) = lcase(accUserName) Then
strComputer = "."
Set objUser = GetObject("WinNT://" & strComputer & "/" & accUserName & ", user")
msgbox "User " & accUserName & "exists and adding password."
objUser.SetPassword accUserPass
objUser.SetInfo
'This checks to see if the user needs added to the Administrators Group
Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators")
For Each objUser in objGroup.Members
If objUser.Name = accUserName Then
IsAdmin = "1"
End If
Next
if IsAdmin <> "1" Then
msgbox "Adding existing user " & accUserName & " to Administrator group."
Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators,group")
Set objUser = GetObject("WinNT://" & strComputer & "/" & accUserName & ",user")
objGroup.Add(objUser.ADsPath)
End If
End If
Next
End Sub
'This restarts OS in 10 seconds to apply changes.
msgbox "End of script!"
'objWShell.Run "shutdown /r /t 10 /f /d P:4:2"
Set objWShell = Nothing I do really appreciate the expert help.