Enumerating the If... Then: Scripts

Friday, April 18, 2008

RealQuickScripts: Getting or Setting Computer Description

Tested.
In use at work.



Const HKEY_LOCAL_MACHINE = &H80000002

strComputer = WScript.Arguments.Item(0)

Set objRegistry = GetObject ("winmgmts:\\" & strComputer & "\root\default:StdRegProv")

strKeyPath = "System\CurrentControlSet\Services\lanmanserver\parameters"
strValueName = "srvcomment"


if WScript.Arguments.Count = 1 then 'display current description

wscript.echo GetValue()

else

wscript.echo "Description of " & WScript.Arguments.Item(0) & " has been set to " & vbnewline & vbnewline & " " & SetValue(WScript.Arguments.Item(1))

end if

wscript.quit

function GetValue()

objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strDescription
GetValue = strDescription

end function

function SetValue(strDescription)

objRegistry.SetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strDescription
SetValue = strDescription

end function


source

0 Comments:

Post a Comment

<< Home