2

I wish to populate the local machine description (overwrite if already present) with the Model of the computer. Is there some sort of script that can perform this task for me? I have found a site that has some code but they dont have a solution. i have very little knowledge of vb script. but if there is anyway of doing this that would be great.

Thanks

2 Answers 2

1

Assuming your looking to change the computer description on the local machine itself, and not in Active Directory - you could do the following with Powershell (note: you'll need powershell on your XP clients).

$computer=get-wmiobject win32_computersystem
Set-ItemProperty -path "HKLM:\SYSTEM\CurrentControlSet\Services\LanManServer\Parameters" -name "srvcomment" -value $computer.model

I looked for more elegant methods to update the computer description, but none of them actually worked. Updating the registry entry appeared to be the easiest method.

Assuming powershell doesn't work, you may want to look into a scripting language called AutoIT. AutoIt can compile everything into a self contained executable and eliminate client dependancies.

1
  • It's set programatically using net config server /srvcomment:"Testing". I'd love a way to read it from code though without having to poke at the registry. Commented Aug 21, 2013 at 14:36
1

Standing on the shoulders of the excellent answer by CurtM, I have a non-powershell approach. Call this script from a logon script:

setmodel.cmd

@for /f " skip=1 tokens=1 delims=^|" %%a in ('wmic.exe path win32_computersystem get model' ) do set model=%%a @reg add HKLM\SYSTEM\CurrentControlSet\Services\lanmanserver\parameters /v srvcomment /t reg_sz /d "%model%" /f 

With minor modifications, you can process a list of machines in the domain:

setmodel_r.cmd

@for /f " skip=1 tokens=1 delims=^|" %%i in ('wmic.exe /node:%1 path win32_computersystem get model' ) do set model=%%i @reg add \\%1\HKLM\SYSTEM\CurrentControlSet\Services\lanmanserver\parameters /v srvcomment /t reg_sz /d "%model%" /f 

Get a list of machines in the domain using dsquery.exe. Pipe the output to setmodel_r.cmd and you should have your model set as the description. From a command prompt, issue the command:

for /f %b in ('dsquery * domainroot -filter "(objectCategory=computer)" -attr name') do call setmodel_r.cmd %b 

But, you may want to test the setmodel_r.cmd before running it against your entire domain-

for /f %b in (testcomputers.txt) do call setmodel_r.cmd %b 

where testcomputers.txt contains several machine names, each on a new line.

You should play with these until you become comfortable with what they do.

Rob

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.