Jump to content
Wingens

Check Windows version using folders

Recommended Posts

Wingens

Hi,

i am trying to create a script that can check wich Windows version is installed on an offline Windows installation.

Can anyone help me?

Share this post


Link to post
Share on other sites
water

What exactly do you mean by "offline"?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
MilesAhead

I don't know if it is coincidence but my Windows 8 shows as Windows 6.2 and if you right click on Kernel32.dll it shows file version 6.2 and a whole bunch of trailing numbers.  If you have booted something Windows you could try calling FileGetVersion on the kernel32.dll that is on the offline disk.

 

Share this post


Link to post
Share on other sites
Wingens

I am using WinPE to capture a installed Windows on the HDD wich at that moment is an offline installation, i am using a little script to capture a .WIM file and saving it to a network share, only problem that i am having now is when i select the driveletter it does not show wich Windows is installed on that drive.

Does anyone have an idea how to get it to work?

V0.0.au3

Edited by Wingens

Share this post


Link to post
Share on other sites
BinaryBrother

You need to learn a little about scopes. Local, Global, etc. This should be a good read. :)
https://www.autoitscript.com/wiki/Variables_-_using_Global,_Local,_Static_and_ByRef

Your script detects "Vista or Above" for me.

2015-05-27_1004.png

Also, I'm not sure checking for @ProgramFiles & "\Windows Mail" is the best way to determine a Windows Vista+ system. I recommend checking 'ntoskrnl.exe'.

Here is a little example I just threw together to detect offline OS version, by first detecting the NT kernel version.
An updated version if further down in this post.

#include <WinAPIFiles.au3>
_WinAPI_Wow64EnableWow64FsRedirection(False) ;Stops 32bit compiled programs
;from being redirected to C:\Windows\SysWOW64 on 64bit Systems, instead of C:\Windows\System32.

$Drive = FileSelectFolder("Select Drive", "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}")
$NT_Kernel = $Drive & "Windows\System32\ntoskrnl.exe"
If FileExists($NT_Kernel) Then
    $Version = FileGetVersion($NT_Kernel) ;Gets Complete NT Version.
    ConsoleWrite("OS Ver: " & $Version & @CRLF)
    $OS = _GetOSFromNTVersion($Version)
    ConsoleWrite("OS_Name: " & $OS)
EndIf

Func _GetOSFromNTVersion($pNT_Version)
    Local $lVersion_Array[1], $lOS_Name
    $lVersion_Array = StringSplit($pNT_Version, ".")
    If IsArray($lVersion_Array) Then
        Switch $lVersion_Array[1]
            Case 5
                Switch $lVersion_Array[2]
                    Case 0
                        $lOS_Name = "Windows 2000"
                    Case 1
                        $lOS_Name = "Windows XP"
                    Case 2
                        $lOS_Name = "Windows Server 2003";This NT version is used for XP X64, Server 2003, Server 2003 R2, and Windows Home Server. But primarily identifies as Server 2003, in my experience.
                    Case Else
                        Return SetError(1,0,0)
                EndSwitch
            Case 6
                Switch $lVersion_Array[2]
                    Case 0
                        $lOS_Name = "Windows Vista"
                    Case 1
                        $lOS_Name = "Windows 7"
                    Case 2
                        $lOS_Name = "Windows 8"
                    Case 3
                        Switch $lVersion_Array[3] ;Windows Build#, I think.
                            Case 9200-9600
                                $lOS_Name = "Windows 8.1"
                            Case Else
                                $lOS_Name = "Windows 10"
                        EndSwitch
                    Case Else
                        Return SetError(2,0,0)
                EndSwitch
            Case Else
                Return SetError(3,0,0)
        EndSwitch
    Else
        Return SetError(4, 0, 0)
    EndIf

    Return $lOS_Name

EndFunc   ;==>_GetOSFromNTVersion

;   6.3.10074 = Current Windows 10 Beta
;    6.3 = Windows 8.1
;    6.2 = Windows 8
;    6.1 = Windows 7
;    6.0 = Windows Vista
;    5.2 = Windows Server 2003
;    5.1 = Windows XP
;    5.0 = Windows 2000
;    4.0 = Windows NT 4

It is, by no means, complete or even tested very well... But should be a good start.

Here's the sources I tried to pull the NT Version information from.

http://en.wikipedia.org/wiki/Windows_NT

http://www.mskbfiles.com/ntoskrnl.exe.php

http://www.geoffchappell.com/studies/windows/km/ntoskrnl/history/index.htm

==== Added 3 hours after initial post ==== This might help more, just give it a look. B)

#include <WinAPIFiles.au3>
_WinAPI_Wow64EnableWow64FsRedirection(False) ;Stops 32bit compiled programs
;from being redirected to C:\Windows\SysWOW64 on 64bit Systems, instead of C:\Windows\System32.

$Drive = FileSelectFolder("Select Drive", "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}")
$OS_Name = _GetOfflineOS($Drive)
ConsoleWrite("OS: " & $OS_Name)

Func _GetOfflineOS($pDrive) ;Gets the OS Name from the default Windows Install
    $lWindows_DIR = _FindOSInstallDIR($pDrive)
    If @error Then Return SetError(5,0,0)

    $lNT_Kernel = $lWindows_DIR & "\System32\ntoskrnl.exe"
    $lNT_Version = FileGetVersion($lNT_Kernel)

    Local $lVersion_Array[1], $lOS_Name
    $lVersion_Array = StringSplit($lNT_Version, ".")
    If IsArray($lVersion_Array) Then
        Switch $lVersion_Array[1]
            Case 5
                Switch $lVersion_Array[2]
                    Case 0
                        $lOS_Name = "Windows 2000"
                    Case 1
                        $lOS_Name = "Windows XP"
                    Case 2
                        $lOS_Name = "Windows Server 2003";This NT version is used for XP X64, Server 2003, Server 2003 R2, and Windows Home Server. But primarily identifies as Server 2003, in my experience.
                    Case Else
                        Return SetError(1, 0, 0)
                EndSwitch
            Case 6
                Switch $lVersion_Array[2]
                    Case 0
                        $lOS_Name = "Windows Vista"
                    Case 1
                        $lOS_Name = "Windows 7"
                    Case 2
                        $lOS_Name = "Windows 8"
                    Case 3
                        Switch $lVersion_Array[3] ;Windows Build#, I think.
                            Case 9200 - 9600
                                $lOS_Name = "Windows 8.1"
                            Case Else
                                $lOS_Name = "Windows 10"
                        EndSwitch
                    Case Else
                        Return SetError(2, 0, 0)
                EndSwitch
            Case Else
                Return SetError(3, 0, 0)
        EndSwitch
    Else
        Return SetError(4, 0, 0)
    EndIf

    Return $lOS_Name

EndFunc   ;==>_GetOfflineOS

Func _FindOSInstallDIR($pDrive)
    Local $lSearch1, $lSearch2, $lFileName1, $lFileName2
    $lSearch1 = FileFindFirstFile($pDrive & "*.*") ; Initiate Search in Drive root.

    ; Check if the search was successful.
    If $lSearch1 = -1 Then Return SetError(1,0,0) ; Return if Search fails.

    While 1
        $lFileName1 = FileFindNextFile($lSearch1)
        If @error Then ExitLoop; ExitLoop after all files have been listed.
        If @Extended = 1 Then ; Restrict output to directories.
            ;ConsoleWrite("File: " & $lFileName1 & @CRLF) ; Print Directories for debugging.
            $lSearch2 = FileFindFirstFile($pDrive & $lFileName1 & "\*.*") ;Search within directories in root for Windows install.
            If $lSearch2 = -1 Then ContinueLoop ; Skip over bad directories.
            While 1
                $lFileName2 = FileFindNextFile($lSearch2)
                If @error Then ExitLoop
                If @extended = 1 Then
                    ;ConsoleWrite("File2: " & $lFileName2 & @CRLF)
                    If $lFileName2 = "System32" Then
                        ;Probably the Windows Install.
                        If FileExists($pDrive & $lFileName1 & "\" & $lFileName2 & "\ntoskrnl.exe") Then
                            FileClose($lSearch1)
                            FileClose($lSearch2)
                            Return $pDrive & $lFileName1
                        EndIf
                    EndIf
                EndIf
            WEnd
        EndIf
    WEnd
EndFunc

;X86 Versions
;5.1.2600.0 Windows XP
;5.1.2600.1106  Windows XP SP1
;5.1.2600.2180  Windows XP SP2
;5.1.2600.5512  Windows XP SP3
;5.2.3790.0     Windows Server 2003
;5.2.3790.1830  Windows Server 2003 SP1
;5.2.3790.3959  Windows Server 2003 SP2
;6.0.6000.16386     Windows Vista
;6.0.6001.18000     Windows Vista SP1, Windows Server 2008
;6.0.6002.18005     Windows Vista SP2
;6.1.7600.16385     Windows 7
;6.1.7601.17514     Windows 7 SP1
;6.2.9200.16384     Windows 8

;X64 Versions
;5.2.3790.1830 Windows Server 2003 SP1
;5.2.3790.3959 Windows Server 2003 SP2
;6.0.6000.16386 Windows Vista
;6.0.6001.18000 Windows Vista SP1, Windows Server 2008
;6.0.6002.18005 Windows Vista SP2
;6.1.7600.16385 Windows 7, Windows Server 2008 R2
;6.1.7601.17514 Windows 7 SP1, Windows Server 2008 R2 SP1
;6.2.9200.16384 Windows 8
;6.3.10074 = My current Windows 10 version.

 

Summery: The above script provides the base for detecting an offline install DIR, by searching through folders until the System32 folder is found and then checking for the existence of ntoskrnl.exe. I advise adding more parameters for identification. Ex; Check for "Users", the existence of registry hives, compare the size of the OS Install Folder (Windows?), and you could even compare against other files like "Kernel32.dll". Once the OS install folder has been identified, you can then take note of the version outputs of ntoskrnl.exe and Kernel32.dll to determine the installed OS. My version is incomplete and could possibly say that certain version of Windows 8 are actually Windows 10, because I used "Case Else" rather than specifics.

Another possibility is loading the offline registry hive and checking values for more information. ^.^

Edited by BinaryBrother
  • Like 1

Share this post


Link to post
Share on other sites
MilesAhead

For what it's worth, on my machine ntoskrnl.exe and kernel32.dll both show product version 6.2.9200.16384

 

Share this post


Link to post
Share on other sites
Wingens

Thx i will take a look at it this weekend :D

Share this post


Link to post
Share on other sites
BinaryBrother

For what it's worth, on my machine ntoskrnl.exe and kernel32.dll both show product version 6.2.9200.16384

​That script would tell you that you're running Windows 8, pre 8.1.

The 6.2 kernel is quickly becoming outdated. Well... it is outdated, technically. A lot of the changes occurring in Windows 10, are actually present in the 6.3 kernel, as well. You need to update to 6.3 or Windows 8.1 for some performance and stability improvements! :rambo:

I would recommend Windows 10, but it's pretty much Beta and I have a few functionality issues with it. Not to mention the "Updates" for one version to another are OS reinstalls, right now... :mad2:  The performance improvement is too vast to ignore, though. I am running Windows 10 on an old IBM ThinkCentre, 3GB DDR2, Pentium 4 HT 3.2Ghz, and it is actively being used as the entire office server for;

1.) A Windows Offline Update Server.
2.) CIFS backup server which syncs [in realtime] to a cloud source. Hosting all customer and office backups.
3.) Runs my "TechCenter", which is a compilation of network shared tools that are updated every day @ 7am.
4.) A partial mirror of MSDN. [Just OS ISOs and Office Suits]. Which, surprisingly, is only around ~40GB.
5.) A source for me to Burn OS discs and make bootable flashdrives.

I pretty much use this thing for everything... I've got a Dual-Core i3 3Ghz, 6GB DDR3, sitting right next to it that is never used. They are very competitive in the speed that they complete tasks. I am only limited on the IBM by the speed of the HDD, it seams, which is 1.5Gbps, because of old SATA. However, with a 1Gbps NIC, It's still a faster server than the i3, because the i3 has a 10/100 NIC. All in all, I average around 700-900Mbps. *Which I just tried to confirm, but I am using a 10 year old Cat5 cable that I need to change, so I couldn't generate an accurate report.

My primary point is that, if Windows 10 can be installed onto a 12 year old IBM and run like a $349 Walmart special... Then Windows 10 is accomplishing something. ^.^
For the record, I did see similar performance from Windows 8.1 on this same machine, but Windows 10 performance is more comparable to Windows XP, on this machine. With Windows 10's memory management being much better, Windows 10 is unusually responsive on this unit... I don't know enough about hardware specs to know exactly why, but someone said the front-side bus is 800Mhz, which attributes a bit to making these units snappy. Outside that, though, Windows 10 just makes this thing worth something again, after 12 years.

Also, sorry for being so far off topic, I just Love Windows 10... :P

 

 

​Let us know how it turns out! ^_^

Edited by BinaryBrother
BrewManNH... >.>
  • Like 1

Share this post


Link to post
Share on other sites
BrewManNH

BinaryBrother, interesting information but what exactly does any of that have to do with what the OP was looking to do? You want to praise Windows 10? I'd suggest another thread for that, you're completely off topic for this one, even you realized that in your post so why do it?


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
BinaryBrother

... what exactly does any of that have to do with what the OP was looking to do? ...

Why are you even picking on me BrewManNH? :laser:
I feel like I've helped more than hurt! I was just expressing a quick opinion! :ermm:

I've re-written this response like 5 times and I'm just going to leave it at this; My post did provide some relevant information that you have either ignored or overlooked. I have edited my previous post to better represent the relevant material. However, nothing was added or removed. Your post, ultimately, served only as a Personal Message to me, indicating that you'd prefer to keep opinions to a minimum... :huh:

ConsoleWrite(@CRLF& "FileGetVersion('winver.exe') = "&FileGetVersion("winver.exe") &@CRLF &@CRLF)

​I completely thought you goofed! Getting the version number of an app that returns the version number?! :blink:

After some testing, though... I can see that the version output of WinVer.exe reflects the actual version of WinVer.exe itself, which is the OS Kernel version. No difference appears to exist in collecting the version from WinVer, ntoskrnl.exe, and Kernel32.dll. They should all report the exact same Kernel version #, up to Major.Minor.Build... The 4th attribute may be some-sort of build variant, but doesn't seem to cause any issues. The 4th attribute may vary between ntoskrnl.exe and Kernel32.dll, but everything else should be the same.

*Ahem, all of the below is related to Windows 10, ignore if unneeded...

I'm not sure if offline Windows 10 installations are being messed with, by the OP, but here's a warning nonetheless.
AutoIt and Windows 10 aren't working well together for the collection of kernel version numbers... Check this out.

OS: Windows 10
WinVer:           AutoIt - 6.3.10074.1 |  Manual Check: 10.0.10074.0
Ntoskrnl.exe: AutoIt - 6.3.10074.1 |  Manual Check: 10.0.10074.1
Kernel32.dll:  AutoIt - 6.3.10074.1 |  Manual Check: 10.0.10074.0

When you run this in AutoIt on Windows 10, Build 10074;

$lNT_Kernel = @SystemDir & "\ntoskrnl.exe"
$lNT_Version = FileGetVersion($lNT_Kernel)
ConsoleWrite($lNT_Version)

It will output "6.3.10074.1".

However, if you manually look at the version number of ntoskrnl.exe, in my case, it is 10.0.10074.1!

2015-05-29_1518.png

So AutoIt is seeing a different version than what is actually installed on Windows 10! I have tried with and without #RequireAdmin, with and without the 32bit redirect, and compiled as both X64 and X86 programs with all outputs being incorrect! I've also checked for compatibility mode and it was disabled.

Edited by BinaryBrother
  • Like 1

Share this post


Link to post
Share on other sites
jguinch

It's also possible to retrieve the OS full name in the offline Software registry hive by loading it with "reg load".

Windows version and service pack are stored in the two values ProductName and CSDVersion under the {sofware hive}\Microsoft\Windows NT\CurrentVersion

Sure, it's more complicated than using FileGetVersion, but it could work.

I cannot test it and don't know if it works with a WindowsPE environment (I think it's what you're using ?)

 

So maybe you can try my registry-based code and give me a feedback ?

#RequireAdmin

#include <WinAPIReg.au3>
#include <Security.au3>
#include <WinAPI.au3>


$sDrive = "X:"

$ret = _WinAPI_RegLoadKey($HKEY_USERS, "OfflineWindows", $sDrive "\windows\system32\config\software")
If Not @error Then
    $sVersion = RegRead("HKEY_USERS\OfflineWindows\Microsoft\Windows NT\CurrentVersion", "ProductName")
    $sServicePack = RegRead("HKEY_USERS\OfflineWindows\Microsoft\Windows NT\CurrentVersion", "CSDVersion")
    If $sVersion & $sServicePack <> "" Then MsgBox(0, "", "Offline operating system is : " & $sVersion & " " & $sServicePack)
    _WinAPI_RegUnloadKey($HKEY_USERS, "OfflineWindows")
EndIf


Func _WinAPI_RegUnloadKey($hKey, $sSubkey)
    _SetRESTORE_NAMEPrivilege()
    If @error Then Return SetError(@error)
    _SetBACKUP_NAMEPrivilege()
    If @error Then Return SetError(@error)

    Local $aRet = DllCall('advapi32.dll', 'long', 'RegUnLoadKeyW', 'handle', $hKey, 'wstr', $sSubkey)
    If @error Then Return SetError(@error, @extended, 0)
    Return SetError($aRet[0], 0, $aRet[0] = 0)
EndFunc

Func _WinAPI_RegLoadKey($hKey, $sSubkey, $sFile)
    _SetRESTORE_NAMEPrivilege()
    If @error Then Return SetError(@error)
    _SetBACKUP_NAMEPrivilege()
    If @error Then Return SetError(@error)
    
    Local $aRet = DllCall('advapi32.dll', 'long', 'RegLoadKeyW', 'handle', $hKey, 'wstr', $sSubkey, 'wstr', $sFile)
    If @error Then Return SetError(@error, @extended, 0)
    Return SetError($aRet[0], 0, $aRet[0] = 0)
EndFunc



Func _SetRESTORE_NAMEPrivilege()
; thanks SMOKE_N : https://www.autoitscript.com/forum/topic/165774-two-process-with-same-name-but-diferent-folder-how-close-one-specific/?do=findComment&comment=1210720

    Local $h_curproc = _WinAPI_GetCurrentProcess()
    Local $h_token = _Security__OpenProcessToken($h_curproc, _
        BitOR($TOKEN_ADJUST_PRIVILEGES, $TOKEN_QUERY))
    If Not $h_token Then
        Return SetError(2, 0, 0)
    EndIf

    Local $n_sdn = _Security__LookupPrivilegeValue("", $SE_RESTORE_NAME)

    Local $t_tokenpriv = DllStructCreate("dword;dword;long;dword")
    Local $p_tokenpriv = DllStructGetPtr($t_tokenpriv)
    DLLStructSetData($t_tokenpriv, 1, 1)
    DLLStructSetData($t_tokenpriv, 2, $n_sdn)
    DLLStructSetData($t_tokenpriv, 3, 0)
    DLLStructSetData($t_tokenpriv, 4, $SE_PRIVILEGE_ENABLED)
    Local $n_tokensize = DllStructGetSize($t_tokenpriv)

    Local $b_ret = _Security__AdjustTokenPrivileges($h_token, False, _
        $p_tokenpriv, $n_tokensize)

    _WinAPI_CloseHandle($h_token)

    Return SetError(Not $b_ret, 0, $b_ret)
EndFunc

Func _SetBACKUP_NAMEPrivilege() ; thanks SMOKE_N : https://www.autoitscript.com/forum/topic/165774-two-process-with-same-name-but-diferent-folder-how-close-one-specific/?do=findComment&comment=1210720
    Local $h_curproc = _WinAPI_GetCurrentProcess()
    Local $h_token = _Security__OpenProcessToken($h_curproc, _
        BitOR($TOKEN_ADJUST_PRIVILEGES, $TOKEN_QUERY))
    If Not $h_token Then
        Return SetError(2, 0, 0)
    EndIf

    Local $n_sdn = _Security__LookupPrivilegeValue("", $SE_BACKUP_NAME)

    Local $t_tokenpriv = DllStructCreate("dword;dword;long;dword")
    Local $p_tokenpriv = DllStructGetPtr($t_tokenpriv)
    DLLStructSetData($t_tokenpriv, 1, 1)
    DLLStructSetData($t_tokenpriv, 2, $n_sdn)
    DLLStructSetData($t_tokenpriv, 3, 0)
    DLLStructSetData($t_tokenpriv, 4, $SE_PRIVILEGE_ENABLED)
    Local $n_tokensize = DllStructGetSize($t_tokenpriv)

    Local $b_ret = _Security__AdjustTokenPrivileges($h_token, False, _
        $p_tokenpriv, $n_tokensize)

    _WinAPI_CloseHandle($h_token)

    Return SetError(Not $b_ret, 0, $b_ret)
EndFunc


 

Edited by jguinch
  • Like 1

Share this post


Link to post
Share on other sites
iamtheky

or just run DISM /Get-WIMInfo

  • Like 1

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites
BinaryBrother

*Please ignore this post. I'm having issues with the editor and my browser.

To Mod: Feel free to delete this post. I am sorry for the inconvenience. :>

Edited by BinaryBrother

Share this post


Link to post
Share on other sites
Wingens

It's also possible to retrieve the OS full name in the offline Software registry hive by loading it with "reg load".

Windows version and service pack are stored in the two values ProductName and CSDVersion under the {sofware hive}\Microsoft\Windows NT\CurrentVersion

Sure, it's more complicated than using FileGetVersion, but it could work.

I cannot test it and don't know if it works with a WindowsPE environment (I think it's what you're using ?)

 

So maybe you can try my registry-based code and give me a feedback ?

#RequireAdmin

#include <WinAPIReg.au3>
#include <Security.au3>
#include <WinAPI.au3>


$sDrive = "X:"

$ret = _WinAPI_RegLoadKey($HKEY_USERS, "OfflineWindows", $sDrive "\windows\system32\config\software")
If Not @error Then
    $sVersion = RegRead("HKEY_USERS\OfflineWindows\Microsoft\Windows NT\CurrentVersion", "ProductName")
    $sServicePack = RegRead("HKEY_USERS\OfflineWindows\Microsoft\Windows NT\CurrentVersion", "CSDVersion")
    If $sVersion & $sServicePack <> "" Then MsgBox(0, "", "Offline operating system is : " & $sVersion & " " & $sServicePack)
    _WinAPI_RegUnloadKey($HKEY_USERS, "OfflineWindows")
EndIf


Func _WinAPI_RegUnloadKey($hKey, $sSubkey)
    _SetRESTORE_NAMEPrivilege()
    If @error Then Return SetError(@error)
    _SetBACKUP_NAMEPrivilege()
    If @error Then Return SetError(@error)

    Local $aRet = DllCall('advapi32.dll', 'long', 'RegUnLoadKeyW', 'handle', $hKey, 'wstr', $sSubkey)
    If @error Then Return SetError(@error, @extended, 0)
    Return SetError($aRet[0], 0, $aRet[0] = 0)
EndFunc

Func _WinAPI_RegLoadKey($hKey, $sSubkey, $sFile)
    _SetRESTORE_NAMEPrivilege()
    If @error Then Return SetError(@error)
    _SetBACKUP_NAMEPrivilege()
    If @error Then Return SetError(@error)
    
    Local $aRet = DllCall('advapi32.dll', 'long', 'RegLoadKeyW', 'handle', $hKey, 'wstr', $sSubkey, 'wstr', $sFile)
    If @error Then Return SetError(@error, @extended, 0)
    Return SetError($aRet[0], 0, $aRet[0] = 0)
EndFunc



Func _SetRESTORE_NAMEPrivilege()
; thanks SMOKE_N : https://www.autoitscript.com/forum/topic/165774-two-process-with-same-name-but-diferent-folder-how-close-one-specific/?do=findComment&comment=1210720

    Local $h_curproc = _WinAPI_GetCurrentProcess()
    Local $h_token = _Security__OpenProcessToken($h_curproc, _
        BitOR($TOKEN_ADJUST_PRIVILEGES, $TOKEN_QUERY))
    If Not $h_token Then
        Return SetError(2, 0, 0)
    EndIf

    Local $n_sdn = _Security__LookupPrivilegeValue("", $SE_RESTORE_NAME)

    Local $t_tokenpriv = DllStructCreate("dword;dword;long;dword")
    Local $p_tokenpriv = DllStructGetPtr($t_tokenpriv)
    DLLStructSetData($t_tokenpriv, 1, 1)
    DLLStructSetData($t_tokenpriv, 2, $n_sdn)
    DLLStructSetData($t_tokenpriv, 3, 0)
    DLLStructSetData($t_tokenpriv, 4, $SE_PRIVILEGE_ENABLED)
    Local $n_tokensize = DllStructGetSize($t_tokenpriv)

    Local $b_ret = _Security__AdjustTokenPrivileges($h_token, False, _
        $p_tokenpriv, $n_tokensize)

    _WinAPI_CloseHandle($h_token)

    Return SetError(Not $b_ret, 0, $b_ret)
EndFunc

Func _SetBACKUP_NAMEPrivilege() ; thanks SMOKE_N : https://www.autoitscript.com/forum/topic/165774-two-process-with-same-name-but-diferent-folder-how-close-one-specific/?do=findComment&comment=1210720
    Local $h_curproc = _WinAPI_GetCurrentProcess()
    Local $h_token = _Security__OpenProcessToken($h_curproc, _
        BitOR($TOKEN_ADJUST_PRIVILEGES, $TOKEN_QUERY))
    If Not $h_token Then
        Return SetError(2, 0, 0)
    EndIf

    Local $n_sdn = _Security__LookupPrivilegeValue("", $SE_BACKUP_NAME)

    Local $t_tokenpriv = DllStructCreate("dword;dword;long;dword")
    Local $p_tokenpriv = DllStructGetPtr($t_tokenpriv)
    DLLStructSetData($t_tokenpriv, 1, 1)
    DLLStructSetData($t_tokenpriv, 2, $n_sdn)
    DLLStructSetData($t_tokenpriv, 3, 0)
    DLLStructSetData($t_tokenpriv, 4, $SE_PRIVILEGE_ENABLED)
    Local $n_tokensize = DllStructGetSize($t_tokenpriv)

    Local $b_ret = _Security__AdjustTokenPrivileges($h_token, False, _
        $p_tokenpriv, $n_tokensize)

    _WinAPI_CloseHandle($h_token)

    Return SetError(Not $b_ret, 0, $b_ret)
EndFunc


 

​Thank you this works, i changed one register value that i use instead of the CSDVERSION i use: EditionID then i get a readout like: Starter, Home Premium etc.

More user friendly.

 

Thank you sow much guys!

Share this post


Link to post
Share on other sites
MilesAhead

​That script would tell you that you're running Windows 8, pre 8.1.

 

 

 

​Let us know how it turns out! ^_^

That is what I am running. I see no reason to update to 8.1.  This Laptop has booting issues.  It doesn't want to complete a Restore Point so I can just imagine how it would do with a live OS update through the store.  Afa day to dayuse, it ain't broke so I'm not gonna' fix it.  :)

 

 

Edited by MilesAhead
  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • Gowrisankar
      By Gowrisankar
      Dear members, 
      I am working on a project where, emails from outlook are to be read and moved to various folders within the mailbox, based on the content of the emails.
      I used the below code for moving mails. It works fine when I run it against individual mail ids. But when I run it on Shared mailbox, the mails are not moved to respective folders.
      _OL_ItemMove($oOutlook, $sEntryId, Default, $sDestinationFolder) The value of $sEntryId is saved in an excel report initially. The current process reads the $sEntryId from the excel and passes it to "_OL_ItemMove" statement.
      Requesting the guidance of the forum members in this issue.
    • Gowrisankar
      By Gowrisankar
      Dear members,
      I'm trying to move unread mails from Inbox to a different folder using OutlookEx UDF.
      But its not working for me. I'm not sure what mistake I do.
      I get the error code 6 when the following is executed. From the UDF it is observed that  "No or an invalid item has been specified".
      Note : The UDF version is 1.3.3.1. AutoIt version (v3.3.14.2).
      #include <OutlookEX.au3> Global $oOutlook = _OL_Open() If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error creating a connection to Outlook. @error = " & @error & ", @extended = " & @extended) Global $aOL_Item = _OL_ItemFind($oOutlook, "*\Inbox", $olMail, "[UnRead]=True", "", "", "Subject", "", 1) If $aOL_Item[0][0] = 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemMove Example Script", "Could not find a task item in folder 'Outlook-UDF-Test\SourceFolder\Tasks'. @error = " & @error) _ArrayDisplay($aOL_Item, "OutlookEX UDF: _OL_ItemFind Example Script - Unread mails") _OL_ItemMove($oOutlook, $aOL_Item[1][0], Default, "*\Outlook-UDF-Test\TargetFolder\Mail") If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemMove Example Script", "Error moving specified task. @error = " & @error) Any help is deeply appreciated. Thanks in advance.
      Thanks and regards,
      Gowrisankar R.
    • TheSaint
      By TheSaint
      Files Checklist
      Just a simple little (complex enough) program I whipped up, for a purpose ... but only too happy to share.
      It can of course be modified to do more, but at the moment just compares file names with or without path ... Location versus Checklist.
      There are of course other compare programs out there, most doing a lot more than mine (i.e. WinMerge or FileComparer). But I wanted something quick and simple with drag & drop, that uses up a smallish amount of screen real estate.
      NOTE - The SAVE button is also a LOAD one, and displays 'Load' when the list is empty. So you can save and load specific lists. While in SAVE mode, the button can also be used with CTRL held down, to ADD another list to existing (displayed one) ... combining as they say ... though not saved until you SAVE. CLEAR button removes a selected entry, or if used with CTRL held down, queries about removing all listed entries.
              
      Files Checklist v1.2.zip
      Files Checklist v1.3.zip
      Files Checklist v1.4.zip  (Includes a BUGFIX.)
        (source included)
      WARNING - While this program does not act on files or folders ADDED or CHECKED, you might act on the results, so I advise caution, and I also recommend using the new 'Relative' option in v1.3 or newer ... but you still need to understand what you are doing and what the results actually mean. Some basic examples in the next post.
      Enjoy!
      RELATED
      Users might also be interested in another somewhat related program of mine.
      DeleteIf Same
      Cheers!
    • VITSUSA
      By VITSUSA
      I am using window XP in my desktop, so I want to convert basic disk to a dynamic disk, so how it is possible?
    • nacerbaaziz
      By nacerbaaziz
      Detect if the focus item is a button or check box
      Hello everyone.
      My dears I have a problem
      When I try to use
      ControlGetFocus function
      it  doesn't recognize the check  boxes.
      The result is that the selector is a button
      Although the specified is a check box
      but I want a way to identify the check boxes.
      Because I want to make a tool that helps screen readers users
      I hope you have the solution.
      Thank you in advance.
       
×