WhyNotWin11 icon indicating copy to clipboard operation
WhyNotWin11 copied to clipboard

Resolved : Add Current OS Build to file export

Open supertramp4 opened this issue 1 year ago • 5 comments

Would it be possible to include current OS Build number into the File Export ( TXT or CSV )

Results for OS Build 10.0.19045 Architecture True 0 0 ....

For those of us who will be using this great piece of software in a remote way, then this would help to ensure that the Computer is currently on Win10, and is capable of upgrading to Win 11

supertramp4 avatar Jul 16 '24 08:07 supertramp4

Was able to resolve myself. For .TXT exports, this adds a line OS Build WIN_10:19045,X64 for .CSV exports, adds a new column "OSINFO", and report WIN_10:19045

For anyone intrested - modified the WhyNotWin11.au3 file as follows Func OutputResults(ByRef $aResults, ByRef $aSkips, $aOutput)

Local $sFile, $hFile, $sOut = ""

Local $aLabel[11] = ["Architecture", "Boot Method", "CPU Compatibility", "CPU Core Count", "CPU Frequency", "DirectX + WDDM2", "Disk Partition Type", "RAM Installed", "Secure Boot", "Storage Available", "TPM Version"]

Switch $aOutput[1]
	Case "txt"
		If StringInStr($aOutput[2], ":") Or StringInStr($aOutput[2], "\\") Then
			$sFile = $aOutput[2]
		Else
			$sFile = @ScriptDir & "\" & $aOutput[2]
		EndIf
		$hFile = FileOpen($sFile, $FO_CREATEPATH + $FO_OVERWRITE)
		$sOut = "Results for " & @ComputerName & @CRLF & "OS Build " & @OSVersion &  ":" & @OSBuild & ":" & @OSArch & @CRLF
		For $iLoop = 0 To 10 Step 1
			If $aSkips[$iLoop] Then
				$sOut &= $aLabel[$iLoop] & @TAB & True & @TAB & "Skipped" & @TAB & "Skipped" & @CRLF
			Else
				$sOut &= $aLabel[$iLoop] & @TAB & $aResults[$iLoop][0] & @TAB & $aResults[$iLoop][1] & @TAB & $aResults[$iLoop][2] & @CRLF
			EndIf
		Next

	Case "csv"
		If StringInStr($aOutput[2], ":") Or StringInStr($aOutput[2], "\\") Then
			$sFile = $aOutput[2]
		Else
			$sFile = @ScriptDir & "\" & $aOutput[2]
		EndIf
		If Not FileExists($sFile) Then
			$hFile = FileOpen($sFile, $FO_CREATEPATH + $FO_OVERWRITE)
			$sOut = FileWrite($hFile, "Hostname")			
			$sOut &= FileWrite($hFile, ",OSInfo")					
			For $iLoop = 0 To 10 Step 1
				$sOut &= FileWrite($hFile, "," & $aLabel[$iLoop])
			Next
			FileWrite($hFile, $sOut & @CRLF)
		Else
			$hFile = FileOpen($sFile, $FO_APPEND)
		EndIf
		;;;$sOut = @ComputerName
		$sOut = FileWrite($hFile, @ComputerName)			
		$sOut &= FileWrite($hFile, "," & @OSVersion &  ":" & @OSBuild & ":" & @OSArch)				
		For $iLoop = 0 To 10 Step 1
			If $aSkips[$iLoop] Then
				$sOut &= FileWrite($hFile, "," & True)
			Else
				$sOut &= FileWrite($hFile, "," & $aResults[$iLoop][0])
			EndIf
		Next

	Case Else
		;;;

EndSwitch
FileWrite($hFile, $sOut & @CRLF)
FileClose($hFile)

EndFunc ;==>OutputResults

supertramp4 avatar Jul 16 '24 10:07 supertramp4

Would you be okay with this information being after the columns of results? The CSV data order has been consistent for some time now and I'd like to keep other people's scripts/workflows in mind.

rcmaehl avatar Jul 16 '24 13:07 rcmaehl

Hi, Yes the position in the CSV file for me does not matter, so please adjust as necessary. You will also see that i corrected the issue in CSV outputs where no Hostname was output.

supertramp4 avatar Jul 16 '24 13:07 supertramp4

@supertramp4 prs welcome :trollface:

micwoj92 avatar Jul 16 '24 18:07 micwoj92

@supertramp4 prs welcome :trollface:

Nah, I'm adding a lot more improvements than just the OS Version and Build #.

rcmaehl avatar Jul 17 '24 12:07 rcmaehl