VB Script to change workgroup name - Windows 7

I call from within a setup cmd file a vbs file which prompts to enter the new machine name of the PC. i would like to add within this same vbs file a prompt to change the PCs workgroup name.
The PC will not be joining a Domain.

Many thanks

Who is Participating?
From what you're saying you have a good grasp of VB script and using pop up boxes etc,

I think you just need to make another input box which links to a hostname string which will write into the registry. These registry locations and setup may help you

strCCS = "HKLM\SYSTEM\CurrentControlSet\"
strTcpipParamsRegPath = strCCS & "Services\Tcpip\Parameters\"
strCompNameRegPath = strCCS & "Control\Computername\"

'Delete current settings in registry and write new ones
With WSH  
.RegDelete strTcpipParamsRegPath & "Hostname"  
.RegDelete strTcpipParamsRegPath & "NV Hostname"  
.RegWrite strCompNameRegPath & "Computername\Computername", strComputername  
.RegWrite strCompNameRegPath & "ActiveComputername\Computername", strComputername  
.RegWrite strTcpipParamsRegPath & "Hostname", strComputername  
.RegWrite strTcpipParamsRegPath & "NV Hostname", strComputername
End With   ' WSH
WSH.RegWrite "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\AltDefaultDomainName", strComputername
WSH.RegWrite "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultDomainName", strComputername
WSH.RegWrite "HKCU\Software\Microsoft\Windows\ShellNoRoam\", strComputername

This should give you all the little scriptlets that you need to write the workgroup in from the input box, as long as you add your own script in for the input box etc. modify the StrComputername to whatever you need it to be obviously.
oh, wait.

you'll need to use Netdom to finish off from what i'm seeing.

'Get user input
strWorkgroup = InputBox("Enter the name to use as the Workgroup, e.g SS38COL")
strWorkgroup = UCase(strWorkgroup) 'Force capitalization
WSH.Popup "Please wait.",2, strTitle 'Inform user
'Use Win2k resource kit utility to make change
WSH.Run "NETDOM.EXE  MEMBER \\" & strComputername & " /JOINWorkgroup " & strWorkgroup, 0, True
WSH.Popup "OK... Done!",2, strTitle 'Inform user
Rick_PenneyAuthor Commented:
Wow, that was quick
Nice one, many thanks for your help
Kind Regards
Rick_PenneyAuthor Commented:
thanks for the additional info
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.