Custom tool - Add computer description
Hi,
If you would like to set Computer Descriptions remotely here is a VBS script that you can use set as a custom tool.
To install:
- Save VBS file called CustomDescription.vbs somewhere accessible on the computer running PDQ Inventory
- Go to PDQ Inventory -> Preferences-> Custom Tools ->New Tool
- Make the title "Change Computer Description" or whatever you want to appear on the menu
- Set the command line to wscript "C:\...<Path to VBS file>...\ChangeDescription.vbs" %Target%
Download the file or recreate it from the VBS Script contents:
'Prompts for computer name, then retrieves current computer description
' Populates inputbox with description, allowing you to overwrite the current
' setting. XP, 2003 and below require a restart of the computer or server
' service to be restarted in order for the new name to take.
'
'Windows Vista/7 seems to take the change immediately.
'
'You must have remote registry and WMI permissions to make changes.
'
'The script will truncate to the first 48 characters of the description
' given in the inputbox.
'
'Author: Rob.Dunn (spiceworks ID)
'www.theitoolbox.com
'
'Modified for PDQ-Inventory by Bill Hart
'Argument %TARGET% can be passed
'Modify Custom Tools Preferences in PDQ Inventory to launch using
' wscript "c:\...\ChangeDescription.vbs" %TARGET%
'Now you can set descriptions by right clicking on computer, go to tools and Change Description
Dim strDescription, strComputer, reg, objRegistry
Dim ret, msg, ValueName
strComputer = WScript.Arguments(0)
if WScript.Arguments.Count = 0 then
strComputer = inputbox("Input a computer name.")
end if
Const HKLM = &H80000002
if strComputer = "" then wscript.quit
on error resume next
Set reg = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
if err.number <> 0 then
msgbox "There was an error while attempting to connect to " & strComputer & "'s WMI database. Is the computer powered on? If so,
there may be an issue with your permissions.",16,"Error connecting to '" & strComputer & "'"
wscript.quit
end if
on error goto 0
Set objRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2").ExecQuery("Select
Description FROM Win32_OperatingSystem")
For Each object In objRegistry
strDescription = object.Description
Next
value = inputbox("Input a computer description for '" & strComputer & "':","Enter a new description",strDescription)
If value = strDescription then wscript.quit
key = "SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters"
ValueName = "srvcomment"
If Len(Value) > 48 Then Value = Left(Value, 48)
ret = reg.SetStringValue(HKLM, key, ValueName, value)
if ret <> 0 then msgbox "Remote update failed."
'Prompts for computer name, then retrieves current computer description
' Populates inputbox with description, allowing you to overwrite the current
' setting. XP, 2003 and below require a restart of the computer or server
' service to be restarted in order for the new name to take.
'
'Windows Vista/7 seems to take the change immediately.
'
'You must have remote registry and WMI permissions to make changes.
'
'The script will truncate to the first 48 characters of the description
' given in the inputbox.
'
'Author: Rob.Dunn (spiceworks ID)
'www.theitoolbox.com
'
'Modified for PDQ-Inventory by Bill Hart
'Argument %TARGET% can be passed
'Modify Custom Tools Preferences in PDQ Inventory to launch using
' wscript "c:\...\ChangeDescription.vbs" %TARGET%
'Now you can set descriptions by right clicking on computer, go to tools and Change Description
Dim strDescription, strComputer, reg, objRegistry
Dim ret, msg, ValueName
strComputer = WScript.Arguments(0)
if WScript.Arguments.Count = 0 then
strComputer = inputbox("Input a computer name.")
end if
Const HKLM = &H80000002
if strComputer = "" then wscript.quit
on error resume next
Set reg = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
if err.number <> 0 then
msgbox "There was an error while attempting to connect to " & strComputer & "'s WMI database. Is the computer powered on? If so,
there may be an issue with your permissions.",16,"Error connecting to '" & strComputer & "'"
wscript.quit
end if
on error goto 0
Set objRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2").ExecQuery("Select
Description FROM Win32_OperatingSystem")
For Each object In objRegistry
strDescription = object.Description
Next
value = inputbox("Input a computer description for '" & strComputer & "':","Enter a new description",strDescription)
If value = strDescription then wscript.quit
key = "SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters"
ValueName = "srvcomment"
If Len(Value) > 48 Then Value = Left(Value, 48)
ret = reg.SetStringValue(HKLM, key, ValueName, value)
if ret <> 0 then msgbox "Remote update failed."
ChangeDescription.vbs
Comments