Jump to content

32Bit DISM command will not run on 64Bit Windows PC


Recommended Posts

I am writing a provisioning script to upgrade Windows 10 to the Enterprise version.  First, I need to determine if the target PC is a candidate or not and then upgrade it if it is.  DISM.exe runs normally when I launch it via the CMD.exe with administrator privilege.  However, I cannot run or execute DISM.exe from my AutoIT script.  I have include part of the script below for review.  I cannot figure it out so am asking for additional eyes and talents to see what I am missing here.  Thank you for your time.

Script kicked up the following error:

Error: 11

You cannot service a running 64-bit operating system with a 32-bit version of DISM.
Please use the version of DISM that corresponds to your computer's architecture.

The DISM log file can be found at C:\windows\Logs\DISM\dism.log

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=F:\Koda Forms\Enterprise_Provisioning.kxf
$Form1 = GUICreate("Form1", 436, 291, 194, 124)
$Edit1 = GUICtrlCreateEdit("", 0, 8, 433, 233)
GUICtrlSetData(-1, "Edit1")
$Button1 = GUICtrlCreateButton("START", 180, 256, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

If @OSArch == "X64" Then
     $Windows = @WindowsDir & "sysnative"
Else
     $Windows = @SystemDir
EndIf

;Retrieve current Windows 10 edition.
;RunWait(@ComSpec & " /c " & "C:\windows\system32\dism " & "/online " & "/get-currentedition " & ">> C:\Windows\Temp\prov.txt", @SystemDir, @SW_HIDE)
;RunWait(@ComSpec & " /c " & "C:\windows\syswow64\dism " & "/online " & "/get-currentedition " & ">> C:\Windows\Temp\prov.txt", @SystemDir, @SW_HIDE)
;RunWait($Windows & "dism.exe " & "/online " & "/get-currentedition " & ">> C:\Windows\Temp\prov.txt", @SystemDir, @SW_HIDE)
Run("dism.exe " & "/online " & "/get-currentedition " & ">> C:\Windows\Temp\prov.txt", @SystemDir, @SW_HIDE)

$sOS_ver = FileRead("C:\Windows\Temp\prov.txt")

; Set the Dashboard
GUICtrlSetData($Edit1, $sOS_ver & @CRLF)

 

Link to comment
Share on other sites

You have to use the x64 version. You can do it by disabling the wow64 redirection

_WinAPI_Wow64EnableWow64FsRedirection ( False ) is a good way :

#RequireAdmin

#include <WinAPIFiles.au3>
_WinAPI_Wow64EnableWow64FsRedirection ( False )
Run (@ComSpec & " /k dism.exe /online /get-currentedition")

 

Link to comment
Share on other sites

Thank you jguinch,

From your insight I was able to tweak it to my liking.  Again, thanks!  Below is the working version I intend to build upon with the rest of my codes in case someone else have similar question with DISM.exe and Windows 64bit.

#RequireAdmin
#include <WinAPIFiles.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPIFiles.au3>
#Region ### START Koda GUI section ### Form=F:\Koda Forms\Enterprise_Provisioning.kxf
$Form1 = GUICreate("Windows 10 Enterprise provisioning script", 436, 291, 194, 124)
$Edit1 = GUICtrlCreateEdit("", 0, 8, 433, 233)
GUICtrlSetData(-1, "")
$Button1 = GUICtrlCreateButton("START", 180, 256, 75, 25)
GUISetState(@SW_SHOW)
GUICtrlSetState($Button1, $Gui_Disable)
#EndRegion ### END Koda GUI section ###

Global $data

_WinAPI_Wow64EnableWow64FsRedirection ( False )

;Retrieve current Windows 10 edition.
RunWait(@ComSpec & " /c dism.exe /online /get-currentedition > C:\Windows\temp\prov.txt", @WindowsDir, @SW_HIDE)

$data = FileRead("C:\Windows\temp\prov.txt")

; Set the Dashboard
GUICtrlSetData($Edit1, $data & @CRLF)

GUICtrlSetState($Button1, $Gui_Enable)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...