ScriptLogic.com: Windows Management…Point, Click, Done


Desktop Management

Windows Servers & Security

Other Products




Custom Script: C0004

Overview:

So you've setup all your new computers using a drive imaging program like Ghost and now they all have the same DNS Host name under TCP/IP properties. The following script will change the DNS Host Name to match the UserID of the person logging on.


Add these line(s) to a custom script:

$NewName='$UserID' ; could use $WKsta (NetBIOS name) instead...
;--------------------------------------------------------------
if $NTtype<>'Server'
  if $OStype='NT'
    $Key='$HKLM\System\CurrentControlSet\Services\TCPIP\Parameters'
  else
    $Key='$HKLM\System\CurrentControlSet\Services\VxD\MSTCP'
  endif
  $cHostName = readvalue('$Key', 'Hostname')
  if $cHostName<>$NewName
     $err = writevalue('$Key', 'Hostname', '$NewName', 'REG_SZ')
     if $Err and $OStype='NT'
       $CmdLine='$SLrpcc /REGWRITE "$SLserve" "$Key" "HostName" "REG_SZ" "$NewName"'
       shell $CmdLine
     endif
    if $OStype='NT' and $NtOsVerVal>50
      $cmdline='IPCONFIG /registerdns'
      shell $cmdline
    endif
  endif
endif
RETURN ; only one return per custom script (as the last line)!

Created: 02 March, 1999
Last Revised: 22 July, 2004