Whoops! Performed a CLEAN on my 2tb External USB

By | July 27, 2016
Share

2016-07-27_15-57-27

By mistake I performed a CLEAN diskpart operation on my 2tb external usb hdd.  After a couple of minutes of panic, I was able to rebuild the partition table with an excellent opensource tool TestDisk (http://www.cgsecurity.org/wiki/TestDisk).  It was simple to use and located and re-built my partition table within seconds.

 

/BG

Hung at “Checking for updates…” on Windows 7 x64

By | July 16, 2016
Share

* 2016-7-27 Updated with 7 x86 download links

Checking for updates...

Scenario: Installed Windows 7 x64 Professional using ISO from MSDN. Windows Update hung indefinitely “Searching for Updates”.

Solution: Applied the following 3x patches:
9,575,735 Windows6.1-KB3020369-x64.msu
11,313,360 WindowsUpdateAgent-7.6-x64.exe
500,046,015 AMD64-all-windows6.1-kb3125574-v4-x64_2dafb1d203c8964239af3048b5dd4b1264cd93b9.msu

Download: https://drive.google.com/open?id=0BwHI1r8k8A75SHl3Q01zSFktYkk

Download for x86 patches: https://drive.google.com/open?id=0BwHI1r8k8A75RjAzTHhJejlQRkU

Lastly, If running 7 Pro run Never10 to ensure Windows 10 is not cached or prompted to install: https://www.grc.com/never10.htm

No important updates available

/BrianG

 

“FAILURE ( 5624 ): -2147467259 0x80004005: Run DISM..” error when applying WIM

By | July 16, 2016
Share

SplittingWIMandDeployingError

Scenario: Deploying Windows 10 x64 with MDT2013U2 to CF-20A via LAN.

Solution: This issue occurred, because an Update of the Media share was initiated at the same time of a deployment and the update was set to split the OS WIM to support UEFI.  Once Media update was complete, the deployment ran with no issue.

Force a GPS port to a desired Port in Windows 7/8/10.

By | July 15, 2016
Share

Force a GPS port to a desired Port in Windows.

In a recent scenario, I needed to force to the Gobi 5000’s (WWAN) GPS to use COM3 in Windows 7 x64.  Here are the steps I took to accomplish this.  This process was also tested and worked on moving a “u-blox virtual..” to COM, and moving a COM2 device to use COM3.

1. BEFORE your drivers are installed, you must tell the Windows OS that the desired COM port is “In-Use”. I accomplished this by importing the following REG, which sets COM1-5 to “In-Use”:
https://github.com/brianfgonzalez/Scripts/blob/master/COM01-05-InUse.reg

LockoutCOM1-5

2. Reboot the system.

3. Next, Install any/all drivers that may occupy COM ports, incl. Gobi 5000.

4. Lastly, Edit and run the “ForceCOM.ps1” script, and then reboot before usage:
https://github.com/brianfgonzalez/Scripts/blob/master/ForceCOM.ps1

Additional Files:
https://github.com/brianfgonzalez/Scripts/blob/master/SetACL.exe
https://github.com/brianfgonzalez/Scripts/blob/master/subinacl.exe

# Changelog:
# 7/11/2016 - BFG
#	- Changed query to use "Caption" instead of "Name".
#	- Added code to strip " (COM[0-9]{1,2})" from device name using -replace.
#	- Created block of code to update ComDB to set target COMPort to "In-Use".
#	- Added permission change calls inside of function due to issue with permissions editing the Reg.
#	- Replaced regini.exe with SetACL.exe, which worked consistantly for reg perm changes.

#$DeviceName = "Communications Port (COM3)"
$DeviceName = "u-blox Virtual COM Port"
$ComPort = "COM4"


#Grab script directory
$scriptPath = split-path -parent $MyInvocation.MyCommand.Definition
#Add Administrators to "ENUM" and "COM NAME Arbiter" key parents
Start-Process -FilePath "$scriptPath\SetACL.exe" -ArgumentList @('-on "HKEY_LOCAL_MACHINE\System\CurrentControlSet\ENUM" -ot reg -actn setowner -ownr "n:Administrators"') -Wait -WindowStyle Minimized
Start-Process -FilePath "$scriptPath\subinacl.exe" -ArgumentList @('/subkeyreg "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum" /grant=administrators=f /setowner=administrators') -Wait -WindowStyle Minimized
Start-Process -FilePath "$scriptPath\subinacl.exe" -ArgumentList @('/subkeyreg "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\COM NAME Arbiter" /grant=administrators=f /setowner=administrators') -Wait -WindowStyle Minimized

function Change-ComPort {

 	Param ($Name,$NewPort)

 	#Queries WMI for Device Caption
	#$WMIQuery = 'Select * from Win32_PnPEntity where Descripition = "' + $Name + '"'
	$Device = Get-WmiObject -Class Win32_PnPEntity | Where-Object { $_.Caption -like "*$($Name)*" } 

 	#Execute only if device is present
	if ($Device) {
		
        #Give Permissions to Administrators for desired ENUM key
        Start-Process "$scriptPath\SetACL.exe" @('-on "HKEY_LOCAL_MACHINE\System\CurrentControlSet\ENUM\'+$Device.DeviceID+'" -ot reg -actn setowner -ownr n:Administrators') -Wait -WindowStyle Minimized
        Start-Process "$scriptPath\subinacl.exe" @('/subkeyreg "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\'+$Device.DeviceID+'" /grant=administrators=f /setowner=administrators') -Wait -WindowStyle Minimized
        
		#Get current device info
		$DeviceKey = "HKLM:\SYSTEM\CurrentControlSet\Enum\" + $Device.DeviceID
		$PortKey = "HKLM:\SYSTEM\CurrentControlSet\Enum\" + $Device.DeviceID + "\Device Parameters"
		$Port = get-itemproperty -path $PortKey -Name PortName
		$OldPort = [convert]::ToInt32(($Port.PortName).Replace("COM",""))
		
		#Set new port and update Friendly Name
        $Name = $Name -replace " \(COM[0-9]{1,2}\)", ""
		$FriendlyName = $Name + " (" + $NewPort + ")"
		New-ItemProperty -Path $PortKey -Name "PortName" -PropertyType String -Value $NewPort -Force
		New-ItemProperty -Path $DeviceKey -Name "FriendlyName" -PropertyType String -Value $FriendlyName -Force

 		#Set old Com Port as available
		$Byte = ($OldPort - ($OldPort % 8))/8
		$Bit = 8 - ($OldPort % 8)
		if ($Bit -eq 8) {
			$Bit = 0 
			$Byte = $Byte - 1
		}
		$ComDB = get-itemproperty -path "HKLM:\SYSTEM\CurrentControlSet\Control\COM Name Arbiter" -Name ComDB
		$ComBinaryArray = ([convert]::ToString($ComDB.ComDB[$Byte],2)).ToCharArray()
		while ($ComBinaryArray.Length -ne 8) {
			$ComBinaryArray = ,"0" + $ComBinaryArray
		}
        #Flip bit to 0 for Available
		$ComBinaryArray[$Bit] = "0"
		$ComBinary = [string]::Join("",$ComBinaryArray)
		$ComDB.ComDB[$Byte] = [convert]::ToInt32($ComBinary,2)
		Set-ItemProperty -path "HKLM:\SYSTEM\CurrentControlSet\Control\COM Name Arbiter" -Name ComDB -Value ([byte[]]$ComDB.ComDB)

 		#Set the new Com Port from ComDB is set to InUse
		$NewPort = $NewPort.Replace("COM","")
		$Byte = ($NewPort - ($NewPort % 8))/8
		$Bit = 8 - ($NewPort % 8)
		if ($Bit -eq 8) { 
			$Bit = 0 
			$Byte = $Byte - 1
		}
		$ComDB = get-itemproperty -path "HKLM:\SYSTEM\CurrentControlSet\Control\COM Name Arbiter" -Name ComDB
		$ComBinaryArray = ([convert]::ToString($ComDB.ComDB[$Byte],2)).ToCharArray()
		while ($ComBinaryArray.Length -ne 8) {
			$ComBinaryArray = ,"0" + $ComBinaryArray
		}
        #Flip bit to 1 for In-Use
		$ComBinaryArray[$Bit] = "1"
		$ComBinary = [string]::Join("",$ComBinaryArray)
		$ComDB.ComDB[$Byte] = [convert]::ToInt32($ComBinary,2)
		Set-ItemProperty -path "HKLM:\SYSTEM\CurrentControlSet\Control\COM Name Arbiter" -Name ComDB -Value ([byte[]]$ComDB.ComDB)
		
	}
}

Change-ComPort $DeviceName $ComPort

If you need a batch to call the Powershell, here is what I used:

Call Force COM

/BrianG