Jump to content

Set your Computer Name unattended...


Recommended Posts


When you run compname from the command line, does it display the mac ?

For the variable %MAC%, just put a few lines between your for... and If.... Something like

echo %MAC%
pause

so you can see if it has a value or not.

Link to comment
Share on other sites

  • 11 months later...
Well i don't know how to set the description of the Computer but I took the above VBS file and edited it to return only one dialog. In my limited experience, the three items are either null or return the same value. (The three items i am talking about is: objSMBIOS.PartNumber, objSMBIOS.SerialNumber, objSMBIOS.SMBIOSAssetTag) So I basicly added some if tests to see if they had anything in them and if so, I set strSerial to whatever is in it.

This is all great and all, but now that I have this vbs script, how do i use it to make the mostly automated install set what ever strSerial is to the computer name? Details are great and much appreciated.

BETTER YET, I used compname.exe (do Google search) to accomplished this.

in CMDLINES.TXT

[COMMANDS]

".\INSTALLS.CMD"

in INSTALLS.CMD

Echo Changing computer name to the Dell Service Tag

START "" /WAIT "compname.exe" /c ?s

Link to comment
Share on other sites

  • 2 weeks later...

@Swerver:

Yes! You can assign different CD-keys using the MAC-address as the identifier.

You could change the script for assigning the computername to call the ChangeVLKeySP1.vbs from Microsoft.

cmdow @ /HID
ECHO.
ECHO Setting correct Windows CD-key
ECHO Please wait...
for /f "tokens=1" %i IN ("compname /d ?m") do set MAC=%i
IF %MAC% == 00D56A632145 WScript.exe //B ChangeVLKeySP1.vbs PUT-CD-KEY-HERE-IN-VALID-FORMAT
EXIT

I think a good time to run this would be during GuiRunOnce.

Of course this requires you put in some random cdkey that the installation allows you to use for the purpose of getting trough the installation to the point where you can change it (using the above script) to the correct one.

Link to comment
Share on other sites

Don't know if this is any use to anybody, but this is a tool I have used:

WSName

Very useful for PC Name = MAC address

Also same tool can be used on more than just XP.

He add a VB script for serial numbers:

' 
' Example VB Script for passing serial number from BIOS to WSName
'
' Edit Const's as required
'
' Note that some BIOS's may be require the serial number to be trimmed to
' fit within the allows 15 characters, my Toshiba Tecra 8100 for example
' returns : 70013268,PT810A-12C52,PMAT2A12C522/S3A0305D001
' The sticker on the back just says : 70013268J, as I can determine the
' manufacturer and model I can trim this down easily enough
'
' Some BIOS offer the ability to store asset information, I don't have access
' to one of these for testing but I assume the process will be very similar
'
' WMI support was introduced with Windows 2000 (?check this) so you'll need to
' use another mechanism to retrieve the serial number on older Windows machines
'

Option Explicit

Const PATH_TO_WSNAME = "C:\WSNAME.EXE"
Const WSNAME_PARAMETERS = "/REBOOT"

Dim strSerialNumber, strTEMP, strCommandLine, fso, WshShell

set fso = CreateObject("Scripting.FileSystemObject")
set WshShell = WScript.CreateObject("WScript.Shell")

'Check WSName exists
if not fso.FileExists(PATH_TO_WSNAME) then
WScript.Echo "ERROR, Could not find WSNAME in " & fso.GetParentFolderName(PATH_TO_WSNAME)
WScript.Quit(1)
end if


' --- Get the serial number, abort script on error
if Not GetWMIStuff("Win32_BIOS","SerialNumber",strSerialNumber) then
WScript.Echo "ERROR, Could not retrieve serial number"
WScript.Quit(1)
end if

' --- If we got this far then we have the serial number, if you want to see it
' --- uncomment the next line
'WScript.Echo "The raw serial number is " & strSerialNumber

' --- Tidy up the serial number, if required
strSerialNumber = TidySerialNumber(strSerialNumber)

' --- Uncomment the next line if you want to see it the result
'WScript.Echo "The tidied serial number is " & strSerialNumber

' --- Add leading Alpha characters to avoid DNS confusion
strSerialNumber="WKS-" & strSerialNumber
'WScript.Echo "The tidied serial number is " & strSerialNumber

' --- Build Command Line, to check out the command line uncomment
strCommandLine = PATH_TO_WSNAME & " /N:" & strSerialNumber & " " & WSNAME_PARAMETERS
WScript.Echo "About to run the following command:" & vbCRLF & vbCRLF & strCommandLine

' --- Now call WSName with the serial number
Call WshShell.Run(strCommandLine,1,FALSE)

' --- Game Over!

' ---------------------- Helper Functions ----------------------

Function GetWMIStuff(strInstance,strProperty,strResult)
Dim colWMIStuff, objWMI, propWMI
GetWMIStuff=False
Set colWMIStuff= GetObject("winmgmts:").InstancesOf(strInstance)
For Each objWMI In colWMIStuff
For each propWMI in objWMI.Properties_
If (Not IsNull(propWMI.Value) AND UCase(propWMI.Name) = UCase(strProperty)) Then
strResult=propWMI.Value
GetWMIStuff=True
Exit Function
End If
Next
Next
End Function

' --------------------------------------------------------------

Function TidySerialNumber(strSerialNumber)
Dim strModel
On Error Resume Next ' Turn off error checking
TidySerialNumber=strSerialNumber
Call GetWMIStuff("Win32_BIOS","Description",strModel)
if Instr(UCase(strModel),"TECRA8100") then ' This will a Tecra8100. I know how to tidy up.
TidySerialNumber=Left(strSerialNumber,Instr(strSerialNumber,",")-1) ' Trim at the first comma
end if
On Error Goto 0 ' Turn error checking back on
End Function

Regards

Edited by Shamwari
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...