
Originally Posted by
mac_shinobi
You can do but if you rely on user input the computer may get renamed wrongly, how are you planning or wanting the computers to get renamed?
It would be me that renames it, Its only part of a Unattended Server Build Disk I am making, It sets it to something random during instalation and then during a series of RunOnce Commands it propmts you to rename it, It would only be me or someone trusted to rename it really.
Code:
QOne =InputBox("Enter the new Server name e.g. MYSERVER or TST-SVR-001")
Set oShell = CreateObject ("WSCript.shell")
sCCS = "HKLM\SYSTEM\CurrentControlSet\"
sTcpipParamsRegPath = sCCS & "Services\Tcpip\Parameters\"
sCompNameRegPath = sCCS & "Control\ComputerName\"
With oShell
.RegDelete sTcpipParamsRegPath & "Hostname"
.RegDelete sTcpipParamsRegPath & "NV Hostname"
.RegWrite sCompNameRegPath & "ComputerName\ComputerName", QOne
.RegWrite sCompNameRegPath & "ActiveComputerName\ComputerName", QOne
.RegWrite sTcpipParamsRegPath & "Hostname", QOne
.RegWrite sTcpipParamsRegPath & "NV Hostname", QOne
End With ' oShell That is my current Rename PC Script, Below id my create DCPromo Script.
Code:
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''' DO NOT CHANGE ANYTHING BELOW '''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''' SCRIPT TO CREATE IE CONFIG AND DCPROMO UNATTENDED FILE BASED ON USER INPUT '''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''' CREATED BY TIMETHR0W '''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim QOne, QThree
'Asks the questions and uses the information given to generate the scripts
QOne =InputBox("Please enter the name for you domain e.g. *DOMAIN* (It will then become DOMAIN.INTERNAL)")
QThree = InputBox("What is the AD Site Name you want to use e.g. My AD Site")
'Gets the current Computer Name and uses it in the scripts below
Set wshNetwork = WScript.CreateObject( "WScript.Network" )
strComputer = wshNetwork.ComputerName
'Creates the DCPromo.txt file based on the user input above
Set fso = CreateObject("Scripting.FileSystemObject")
Set NewsFile = fso.CreateTextFile("C:\SCRIPTS\DCPromo.txt", True)
NewsFile.WriteLine "[DCInstall]"
NewsFile.WriteLine "NewDomainDNSName=" & QOne & ".INTERNAL"
NewsFile.WriteLine "DomainNetBiosName=" & QOne
NewsFile.WriteLine ""
Newsfile.WriteLine "ReplicaOrNewDomain=Domain"
NewsFile.WriteLine "NewDomain=Forest"
NewsFile.WriteLine "CreateOrJoin = Create"
NewsFile.WriteLine "TreeOrChild = Tree"
NewsFile.WriteLine "SetForestVersion = Yes"
NewsFile.WriteLine "ConfirmGc = Yes"
NewsFile.WriteLine ""
NewsFile.WriteLine "DatabasePath=C:\WINNT\NTDS"
NewsFile.WriteLine "LogPath=C:\WINNT\NTDS"
NewsFile.WriteLine "SysvolPath=C:\WINNT\SYSVOL"
NewsFile.WriteLine ""
NewsFile.WriteLine "DNSOnNetwork=Yes"
NewsFile.WriteLine "AutoConfigDNS=YES"
NewsFile.WriteLine "SiteName=" & QThree
NewsFile.WriteLine "DisableCancelForDnsInstall = Yes"
NewsFile.WriteLine "CriticalReplicationOnly = Yes"
NewsFile.WriteLine "RebootOnSuccess=NoAndNoPromptEither"
NewsFile.Close
'Generates the Unattended Internet Explorer Enhanced Configuration File using the Server's Name as a basis.
Set fso = CreateObject("Scripting.FileSystemObject")
Set NewsFile = fso.CreateTextFile("C:\SCRIPTS\IEConfig.txt", True)
NewsFile.WriteLine "[Components]"
NewsFile.WriteLine "IEHardenAdmin = Off"
NewsFile.WriteLine "IEHardenUser = Off"
NewsFile.WriteLine ""
NewsFile.WriteLine "[IEHardening]"
NewsFile.WriteLine "LocalIntranetSites = http://localhost;https://localhost;http://" & strComputer & ";https://" & strComputer
NewsFile.WriteLine "TrustedSites = http://localhost;https://localhost;http://" & strComputer & ";https://" & strComputer
NewsFile.WriteLine ""
NewsFile.WriteLine "[IEPopupBlocker]"
NewsFile.WriteLine "BlockPopups = No"
NewsFile.WriteLine "FilterLevel = Low"
NewsFile.WriteLine "ShowInformationBar = No"
NewsFile.Close
'''
''' SCRIPT END, PLEASE REPORT ANY BUGS TO TIMETHROW
''' The Generate Files Script works very well and generates everything correctly and is tested on Windows Server 2003
The Rename PC Script was knocked up at 11 last night so is currently unteseted as of yet but it should work.
I am open to any chnages you may have !!
Thanks