Automating Windows 10 Installs

I hate repetitive tasks, but I love automating them. One of the most common tasks for me is installing Windows, so I sought to automate as much of that as I could. I just wanted to write about a custom command I made for my Windows 10 Answer File.

If you haven’t heard of Windows 10 Answer Files, you can read about them here. Long story short, they automate installs for things like Windows and Office. If you want to get make your own, you can easily get started by using a template from the unofficial Windows 10 Answer File Generator.

In my Answer File (I will now call it autounattend.xml) I automatically wipe the hard drive of the target computer, reformat it, add my company as the organization, name the initial user, set the language and time zone, enter the product key for Windows, add a basic password-less admin account, enable the Local Administrator account, set the Local Administrator password, and disables the temporary admin account.

After that things get fun.

I wanted to launch a prompt asking for the user to input a computer name, then name the computer and restart. Unfortunately documentation on this subject is incredibly scarce so I had to figure out a solution myself. Thankfully, I’m a stubborn person.

A couple limitations to autounattent.xml command capabilities:

  • Each command must be on a single line of code.
  • Each line of code can be no greater than 260 characters.
  • Local variables can not be set and used on the same line of code.

Ouch. Long story short, I found a solution: create a temporary container and set environment variables within that container, then close it. That way I can set a variable and use it on a single line of code.

<SynchronousCommand wcm:action="add">
          <Order>7</Order>
          <RequiresUserInput>true</RequiresUserInput>
          <CommandLine>cmd /V /C echo Computer name:&setlocal&set /p NewName=&powershell -Command "Add-Computer -domainname *********.com -ComputerName $env:computername -NewName $env:NewName -OUPath 'OU=Newly Configured Computers,OU=I. T.,DC=**********,DC=com'"&endlocal</CommandLine>
          <Description>Rename PC and Join Domain</Description>
</SynchronousCommand>

From there, Group Policy installs Chrome and UltraVNC with the desired configuration, customizes firewall settings and allows RDP. All that to say, deploying new computers is now a very simple process. An hour saved is an hour earned, right?

KB5000802 🤦🏼‍♂️

Anyone else have issues with Microsoft’s KB5000802 hotfix? It broke a lot of our printers. Fastest way to resolve this issue is to uninstall the hotfix. Since we needed to do it on hundreds of computers, I made a script for that. I hope this helps someone!

Instead of hosting this code on WordPress, I published it on my GitHub.

Remote Check Config

Ever want to quickly check the configuration of a computer on your network? With this script, you can get a ton of info in seconds! Hostname, OS name, original install date, boot time, domain, RAM info, Windows hotfix application, network card status, system uptime, processor info, and even hard drive space!

CheckConfig(remote).bat

cls
@pushd %~dp0
@echo off
ECHO ============================
ECHO REMOTE CONFIGURATION CHECK
ECHO ============================
ECHO ____________________________
color 0A
set /p "id=Enter IP of computer you want to check: "
ECHO Please wait... Checking system information.
:: Section 1: OS information.
ECHO ============================
ECHO OS INFO
ECHO ============================
systeminfo /s %id%
PSTools\PsInfo -d \\%id%
@popd
pause

:: Love, CJ Pollock

This script DOES require PSTools. The PSTools folder should be in the same directory as this Batch file in order to work properly. Here’s a download for everything you need in one place:

Download: Remote Check Config.zip
(right-click and Save Link As)

Who’s Logged In?

Ever want a quick and easy way to check which user is currently logged into a computer on your network? Look no further! Simply input the IP address or hostname of the device on your network, and off you go!

LoggedInUserQuery.bat

cls
@echo off
ECHO ============================
ECHO WHO'S LOGGED IN?
ECHO ============================
ECHO ____________________________
color 0A
set /p "id=Enter IP or name of computer you want to check: "
query user /server:%id%
PAUSE
:: Love, CJ Pollock

Remote Pair Shared Drive

We’ve had an issue where users in our company would request access to a shared drive, but they weren’t at their computer when our IT department was available to log in and map it. To solve this, I made a script that will create a Batch file in a specified users’ Startup Folder. After the Batch file runs, it deletes itself.

remotePairNetworkDrive.bat

cls
@pushd %~dp0
@echo off
ECHO ============================
ECHO REM MAPPING TOOL
ECHO ============================
ECHO ____________________________
color 0A
:top
cls
ECHO ============================
ECHO REM MAPPING TOOL
ECHO ============================
ECHO ____________________________
color 0A
echo What computer (name or IP) do you want to run this on?
set /p address=
ping -n 1 "%address%" | findstr /r /c:"[0-9] *ms"
if %errorlevel% == 0 (
    GOTO:one ) else (
    echo [41mUnable to find %address%. Device may be offline. Try again?[0m
    pause
    GOTO:top
    )
:one
cls
ECHO ============================
ECHO REM MAPPING TOOL
ECHO ============================
ECHO ____________________________
color 0A
echo What computer (name or IP) do you want to run this on? %address%
echo What user do you want this installed for?
set /p user=
echo What is the address for the drive you'd like to pair?
set /p drive=
echo What letter would you like to map the drive to? Leave blank if any.
set /p letter=
if not defined letter (
    GOTO any
) ELSE (
    goto specified
)
:any
set command=net use * "%drive%" /YES
set /a r = %random%
echo @echo off > "\\%address%\c$\Users\%user%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\pairNetworkDrive%r%.bat"
echo %command% >> "\\%address%\c$\Users\%user%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\pairNetworkDrive%r%.bat"
TYPE "deleteScript.txt" >> "\\%address%\c$\Users\%user%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\pairNetworkDrive%r%.bat"
GOTO two
:specified
set command=net use "%letter%:" /YES
GOTO two
echo @echo off > "\\%address%\c$\Users\%user%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\pairNetworkDrive%address%.bat"
echo %command% >> "\\%address%\c$\Users\%user%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\pairNetworkDrive%address%.bat"
TYPE "deleteScript.txt" >> "\\%address%\c$\Users\%user%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\pairNetworkDrive%letter%.bat"
:two
popd
cls
:three
ECHO ============================
ECHO REM MAPPING TOOL
ECHO ============================
ECHO ____________________________
echo %drive% has been mapped on %address% for %user%.
echo Please have %user% restart %address% to see changes.
pause

:: Love, CJ Pollock

IMPORTANT: You need to use this next bit to make sure the target computer’s startup script deletes itself after execution. Simply name it deleteScript.txt and put it in the same directory as the previous Batch file:

deleteScript.txt

(goto) 2>nul & del "%~f0"

Download: remotePairNetworkDrive.zip
(right-click and Save Link As)

Narrowed for iSlayer

Back in 2007 I helped work on a game called Solitude, which won ModDB’s Top 100 Mods of the Year in 2008 and Top 100 Indie Games of the Year in 2009. It was basically Halo for the PSP.

A few fans of Solitude are now part of our community for iSlayer, and have requested that I remake my most popular Solitude map for iSlayer. I threw together a little something, and it ended up being way better than the original, if I do say so myself.

Here is a 360 degree tour of the new Narrowed with the original ambient music and sounds that I composed/created for the game. Enjoy!

Challenges in Virtual Reality

As I delve deeper into the world of virtual reality, the more challenges I find, and the more I fall in love with it. For starters, (as I’ve already blogged previously) motion sickness is a serious problem, and there are certain things you can do in your level design to avoid getting sick.

For one, you can have a wide variety of colors. I know that the artistic style of the mid 2010’s was greyscale/monochrome art with a dark finish, but that is going to confuse the player when teller have to try adjusting their eyes to an object. Not only does the player have to have accurate depth perception in the game, but also the player has to focus on the pixels instead of the screen (and sometimes particles on the screen if not cleaned properly).

Also, reflective surfaces are super tricky. Not only does the game have to render calculations for accurate reflections for TWO cameras, but sometimes the reflections (and motion in the reflection of you have ripple effects) are a little too much for the player to handle and leads to motion sickness very quickly.

Unfortunately, it seems like good level design for VR includes making large landscapes instead of small rooms. If the player has to adjust their focus from an object that’s up close to an object that is very far away, it not only takes them longer to adjust (which takes them away from their immersion), but it also triggers a little bit of motion sickness. I’ve noticed this more going from long-distance sight to looking at something close by.

Another thing that I just recently learned is to really try to nail down the dimensions and pavements of your cameras. Do your best to measure the size of your character in relation to the player, and guesstimate the distance between cameras to match the actual eyes of the player. Doing this will hopefully make it so the player isn’t playing cross-eyed.

The last and biggest problem that I’ve yet to overcome is motion in virtual reality. What is the best way to control a character in-game? Eventually I’d like to get rid of the controller and just use my hands/body. Is there an efficient way to do that? Not that I can tell yet. More on that after Mark and I finish our next project– I think we’ve come up with a super solid solution.