Rename a computer to based on Asset Tag or Serial number

To rename a computer based on its Asset Tag/Serial number using a script, you can put the following text in a vbs file. I use NL-AMS-WS- preceding the Asset tag to indicate the country (netherlands), city (Amsterdam) and type (Workstation):

'***********************************************************************
'
' Changes the computer name to the computer's serial number/asset tag.
'
'***********************************************************************

strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

'Part 1 - Acquire serial/service tag number
Set colSMBIOS = objWMIService.ExecQuery ("Select * from Win32_SystemEnclosure")
For Each objSMBIOS in colSMBIOS
  strSN = objSMBIOS.SerialNumber
  If strSN <> "" Then exit For
Next

'Part 2 - Assign computer name to serial/service tag number
Name = "NL-AMS-WS" & strSN

Set colComputers = objWMIService.ExecQuery ("Select * from Win32_ComputerSystem")

For Each objComputer in colComputers
    err = objComputer.Rename(name)

if err <> 0 then
wscript.echo "There was an error renaming the machine. Please restart, and try again."
else
wscript.echo "Machine successfully renamed: " & Name
end if

Next

To use this during deployment you can use the following command:

cscript scriptname.vbs

Delete a folder with too many characters in its name.

If you want to delete a folder and it gives you the error message: ‘Path is too long’, you can simply keep digging into the folder untill you find a point where it doesn’t give you the error anymore, or you can create a batch file containing the following text:

@echo off
if {%1}=={} @echo Syntax: DelFolder FolderPath&amp;goto :EOF
if not exist %1 @echo Syntax: DelFolder FolderPath - %1 NOT found.&amp;goto :EOF
setlocal
set folder=%1
set MT="%TEMP%\DelFolder_%RANDOM%"
MD %MT%
RoboCopy %MT% %folder% /MIR
RD /S /Q %MT%
RD /S /Q %folder%
endlocal

This script uses RoboCopy, which is included in the Microsoft Windows Server 2003 Resource Kit and can be downloaded here. It is included in Windows 7.

Rename the Administrator account using the command line

To rename the Administrator account (or any existing account) in Windows 7 using the command line, execute the following command:

wmic useraccount where name='Administrator' call rename name='newname'

Install AD-DS Tools

To install AD-DS Tools in Windows 7, execute the following command:

cmd.exe /c dism /Online /Enable-Feature /FeatureName:RemoteServerAdministrationTools /FeatureName:RemoteServerAdministrationTools-Roles /FeatureName:RemoteServerAdministrationTools-Roles-AD /FeatureName:RemoteServerAdministrationTools-Roles-AD-DS /FeatureName:RemoteServerAdministrationTools-Roles-AD-DS-SnapIns /NoRestart

Disable Windows Firewall

To disable the Windows Firewall in Windows 7 execute the following command:

cmd.exe /c netsh firewall set opmode mode=DISABLE profile=DOMAIN

Disable IPv6

To disable IPv6 in Windows 7 execute the following command:

cmd.exe /c reg add HKLM\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters /v DisabledComponents /t REG_DWORD /d 0xffffffff /f

Configure Subsystem for UNIX-based Application

To configure Subsystem for UNIX-based Application in Windows 7 enter the following command:

cmd.exe /c start /w pkgmgr /iu:SUA

Enable Remote Registry

To enable the Remote Registry enter the following command:

cmd.exe /c sc config RemoteRegistry start= auto