PowerShell

Extract various archives with PowerShell

Nowadays, instead of using .zip, .rar or .7z files, I find myself using virtual harddrives (.vhdx) more and more as it’s so much more convenient. However, extracting large amounts of compressed files, can be a very time consuming endeavor. Here a quick and dirty PowerShell script to do this. I’ve added a check for determining if the archive one folder in the root of the archive or if it contains multiple files and folders. If it contains just the one folder, the script won’t create a new folder and extract that one folder into the new folder. Instead it will “extract here”. If multiple files and/or folders are found, it will create a new folder based on the archive name. The script assumes you have 7zip installed on the default location.

Abandonware

Command & Conquer – Play in Dosbox

When Command & Conquer was released in 1995 and its companion with a different tone Command & Conquer: Red Alert in 1996, it was something of a revolution in the RTS game play. Of course Dune II had been released a few years before, also developed by Westwood studios, setting the tone for many RTS games that followed in the years to come. (This includes Warcraft, which eventually let to World of Warcraft, DOTA and many others that a lot of people still play daily nowadays)

Now that the remastered edition is announced for 2020, the 25th anniversary of the game, I got interested again in the original Dos game. Since the original is 2CD’s (GDI and NOD) and later an expansion was added named: Command & Conquer: The Covert Operations, I thought it was time to create a quick batch file to load which ever disk instead of having to type the commands in Dosbox every single time.
Batch files are the reason that I’m using non-standard commands and add-ons to Dosbox, so here the bat-file that I’ve written for C&C:

:menu
echo 1) C&C: GDI
echo 2) C&C: NOD
echo 3) C&C: Covert Operations
echo 4) Exit to Dos
choice /C:1234 /N Option:

if errorlevel = 1 goto GDI
if errorlevel = 2 goto NOD
if errorlevel = 3 goto COVERT
if errorlevel = 4 goto EXIT

:GDI
imgmount d “c:\temp\dosbox\e\cd\C&C\C&C-CD1.iso” “c:\temp\dosbox\e\cd\C&C\C&C-CD2.iso” “c:\temp\dosbox\e\cd\C&C\C&C-Cov.iso” -t cdrom
d:\C&C
goto menu

:NOD
imgmount d “c:\temp\dosbox\e\cd\C&C\C&C-CD2.iso” “c:\temp\dosbox\e\cd\C&C\C&C-CD1.iso” “c:\temp\dosbox\e\cd\C&C\C&C-Cov.iso” -t cdrom
d:\C&C
goto menu

:COVERT
imgmount d “c:\temp\dosbox\e\cd\C&C\C&C-Cov.iso” “c:\temp\dosbox\e\cd\C&C\C&C-CD1.iso” “c:\temp\dosbox\e\cd\C&C\C&C-CD2.iso” -t cdrom
d:\C&C
goto menu

:EXIT
exit

The CD’s can be cycled with CTRL-F4 if C&C asks for it.

Linux

Ubuntu displays print_req_error: I/O error, dev fd0, sector 0

With a new install as a virtual server, Ubuntu repeatedly displays the error:

print_req_error: I/O error, dev fd0, sector 0

The reason is the virtual server does not have a floppy drive. To resolve:

# sudo rmmod floppy
# echo “blacklist floppy” | tee /etc/modprobe.d/blacklist-floppy.conf
# sudo dpkg-reconfigure initramfs-tools

The message should now be gone for good.

Microsoft Server

Report on BlueScreen (BSOD) events and stop codes with PowerShell

A PowerShell script to report on all BlueScreen events and stop codes from the Windows Event Log on a specific server can be a useful tool for system administrators to troubleshoot and prevent future system crashes. This script will query the System Event log for events related to bug checks (BlueScreens) on a local server or a remote server.
Note: I wrote this to check for one server at a time. If requested, or if I have a future need, I may adapt it to query a list of servers and have the output written to a log file.

Windows 10

Windows 10: Set search results default to detail view

For some reason Microsoft seems to think that “Content” view for search results is the best view. This goes for “generic” folders in general, but me for content view is a view that I’d rather see go completely from Windows. Unfortunately I for me there is no easy setting to change this. This means it’s time to dive into the Windows Registry a little and set everything to use Details view as default.

Folder views are user specific, local and are controlled by the Windows Shell. This means the registry keys can be found under:

HKCU\SOFTWARE\Classes\Local Setting\Software\Microsoft\Windows\Shell

Here you should remove the keys BagMRU and Bags. Once these two are removed, add the following key:

HKEY_CURRENT_USER\SOFTWARE\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags\AllFolders\Shell{7fde1a1e-8b31-49a5-93b8-6be14cfa4943}

Create 2 DWORD values with:

“LogicalViewMode”=dword:00000001
“Mode”=dword:00000004

Now log off and log back on and every window should be set to Detail view.

Dosbox

My Dosbox setup

I’ve been a big fan of Dosbox ever since I found out about it in 2004. Dosbox has been around since 2002, I just didn’t find out about it until later. At the time virtualisation was still in its infancy and virtualising MS-Dos to play old games on was not that easy and fairly memory intensive. Also Windows XP did not run most of the MS-Dos games I wanted to play. For a few years now I’m mainly using Dosbox-X or Dosbox-ECE as these bring more features than the standard Dosbox. My base configuration has not changed significantly over the last 10 years.

For my normal utilities I’ve added a line to the dosbox.conf which mounts a normal folder located on my physical machine. The path I use is normally c:\temp\dosbox\e and I’m mounting this with:

@mount e "C:\Temp\Dosbox\E"

The reason I’m mounting a folder instead of an image is that this way I can very easily add and remove software and have this available with just a quick reboot (CTRL-ALT-Home) of Dosbox. The standard folder structure within the mounted e-drive is:

The directories cd, floppy and hdd keep .img files for the respective formats. The dos directory keeps a full copy of MS-Dos 5.0 with various additional little utilities added from FreeDos. The reason it’s MS-Dos 5.0 is that Dosbox reports its version as being 5.0.
One of the extra little utilities that is not included in Dos version 5.0 is “choice.com”. This handy little utility wasn’t included until Dos version 6 and is still available in Windows 95/98. Choice.com is basically indispensable for creating interactive batch files. I’m using the FreeDos version which is called “choice.exe”.

The full autoexec part of the dosbox.conf is:

[autoexec]
@echo off
@mount e “C:\temp\Dosbox\E”
@e:
@path=z:\;e:\;e:\dos;e:\cd;e:\floppy;e:\hdd;

The reason I’m putting all these folders in the path is that I keep my batch-files with the images.