batch-scripting

Parse GUID on BCDEdit command line when creating new entry

Creating an entry and setting parameters with BCDEdit on command line in a batch process can be difficult because of the random GUID generated that must be specified when changing parameters to the new entry.

With a CMD file like this:
for /f "tokens=2 delims={}" %%g in ('bcdedit.exe -store c:\boot\bcd /create /d "New Entry" /application osloader') do (set guid={%%g})
echo %guid%

The generated GUID is stored as variable and can be used, within the same batch file with variable %guid%.

Attached to the post is an example of CMD Batch file that creates and entry and sets a few parameters.

Auto Rename computer with Serial Number on boot

Script File

When managing a large clients computers sometimes the best name convention for every client computer is a unique number so it is easy to locate and manage. One unique number available in most, if not every computer, is its serial number, with DELL computers it is known as Service Tag.

When needed it is easy to change one single computer name, but when doing a big deployment, like new computers, new operating system revision, and more it can be complicated.

With this script, in that case 2 files, the computer will be renamed with its own serial number (Service Tag) on next reboot, the purpose of the 2 files are:

* RunOnce.reg: Registry file to add the path to the script (note the double bar for the path to work), it uses the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce. When the script is run the entry on the regsitry gets deleted.

* ChangeName.vbs: The script itself, needs to be adjusted with a valid local administrator account, with username and password on line 22 and 23. In case of storing the file in a different path than C:\Windows the script have to be adjusted on line 44.

After running the script the file gets deleted, so not to worry, so much, with security regarding local administrator username and password in plain text.

Enable Wake On Lan (WOL) on Windows

green_switch-128.png

When deploying, with SCCM or any other software, one of the most important thing is to not disturb users on their job, so the best way to do it is out of work time, like nights, when there is no users working, at least not the majority, counterside the computers are offline so no way to install anything.

The solution is to enable and use the network standard Wake On Lan (known as WOL), but it is not a common configuration so you have to enable in every computer.

The solution is to use a script that enables it on Windows, take into consideration that must be enabled at BIOS level (covered in a next article), this script enables it silently the Wake On Lan. It can be deployed through SCCM when the computers are awake because it’s only an script with no other consequences.