Jump to content

How to make this run in Win7 64bit


Docfxit
 Share

Go to solution Solved by JohnOne,

Recommended Posts

This is the script that I am useing.  I don't get any errors.  The output on a 32bit machine shows the values for the registry entries. The 64bit machine doesn't find some registry entries and doesn't show any of the values.

;AutoIt_Debugger_Command:Disable_Debug
#RequireAdmin
#include <Array.au3>
#include <File.au3>
#include <FileConstants.au3>
#include <_RegEnumKeyValEx.au3>
; The above #included script was written by DXRW4E
;     and can be found here: http://www.autoitscript.com/forum/topic/144234-regenumkeyvalex-regenumkeyex-regenumvalex/?p=1207033
;AutoIt_Debugger_Command:Enable_Debug

Global $a, $Error, $Extended, $KeyName
Local Const $ExtensionsFile = @ScriptDir & "\%OriginalRegistryKeys.txt"
FileDelete($ExtensionsFile)
Local $hExtensionsFile = FileOpen($ExtensionsFile, $FO_APPEND)
FileCreate($hExtensionsFile, "")
$KeyName = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"

$a = _RegEnumValEx($KeyName, 128 + 256 + 32, "AutoAdminLogon")
$Error = @Error
$Extended = @Extended
_WriteRecord($hExtensionsFile, $a, $Error, $Extended)

$a = _RegEnumValEx($KeyName, 128 + 256 + 32, "ForceAutoLogon")
$Error = @Error
$Extended = @Extended
_WriteRecord($hExtensionsFile, $a, $Error, $Extended)

$a = _RegEnumValEx($KeyName, 128 + 256 + 32, "DefaultUserName")
$Error = @Error
$Extended = @Extended
_WriteRecord($hExtensionsFile, $a, $Error, $Extended)

$a = _RegEnumValEx($KeyName, 128 + 256 + 32, "AltDefaultUserName")
$Error = @Error
$Extended = @Extended
_WriteRecord($hExtensionsFile, $a, $Error, $Extended)

$a = _RegEnumValEx($KeyName, 128 + 256 + 32, "DefaultPassword")
$Error = @Error
$Extended = @Extended
_WriteRecord($hExtensionsFile, $a, $Error, $Extended)

$a = _RegEnumValEx($KeyName, 128 + 256 + 32, "DefaultDomainName")
$Error = @Error
$Extended = @Extended
_WriteRecord($hExtensionsFile, $a, $Error, $Extended)

$a = _RegEnumValEx($KeyName, 128 + 256 + 32, "AltDefaultDomainName")
$Error = @Error
$Extended = @Extended
_WriteRecord($hExtensionsFile, $a, $Error, $Extended)

 FileClose($hExtensionsFile)
;_AutoLogon(1, "UserID", "Password", @ComputerName)

RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce","Run(@ScriptDir & '\LoginAutoWindowsBack.au3')","REG_SZ",@ScriptFullPath)
;    shutdown(2)

Func _AutoLogon($iOnOff, $sUserName, $sPassword, $sDomain, $iForceAutoLogon = 0)
If $iOnOff = 0 Then ;Auto Logon OFF.
RegWrite($KeyName, "AutoAdminLogon", "REG_SZ", "0")
Else ;Auto Logon ON. If $iOnOff is anything but 0, it is set to 1 (ON).
RegWrite($KeyName, "AutoAdminLogon", "REG_SZ", "1")
EndIf

If $iForceAutoLogon = 1 Then ;Force Auto Logon ON.
RegWrite($KeyName, "ForceAutoLogon", "REG_SZ", "1")
Else  ;Force Auto Logon OFF. If $iForceAutoLogon is anything but 1, it is set to 0 (OFF).
RegWrite($KeyName, "ForceAutoLogon", "REG_SZ", "0")
EndIf

RegWrite($KeyName, "DefaultUserName", "REG_SZ", $sUserName)
RegWrite($KeyName, "AltDefaultUserName", "REG_SZ", $sUserName)
RegWrite($KeyName, "DefaultPassword", "REG_SZ", $sPassword)
RegWrite($KeyName, "DefaultDomainName", "REG_SZ", $sDomain)
RegWrite($KeyName, "AltDefaultDomainName", "REG_SZ", $sDomain)

EndFunc   ;==>_AutoLogon

; Create a file.
Func FileCreate($hExtensionsFile, $sString)
    Local $bReturn = True ; Create a variable to store a boolean value.
    If FileExists($hExtensionsFile) = 0 Then $bReturn = FileWrite($hExtensionsFile, $sString) = 1 ; If FileWrite returned 1 this will be True otherwise False.
    Return $bReturn ; Return the boolean value of either True of False, depending on the return value of FileWrite.
EndFunc   ;==>FileCreate

Func _WriteRecord($hExtensionsFile, $a, $Error, $Extended)
If $Error = "4" Then
;ConsoleWrite("Return = " & $a & " - $Error = " & $Error & " - $Extended = " & $Extended & @LF)
FileWrite($hExtensionsFile, 'Registry Key Not Found' & @CRLF)
Else
;ConsoleWrite("Return = " & $a & " - $Error = " & $Error & " - $Extended = " & $Extended & @LF)
_FileWriteFromArray($hExtensionsFile, $a)
EndIf
EndFunc

The output on the 64 bit machine is:

Registry Key Not Found
Registry Key Not Found
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon|DefaultUserName|REG_SZ|
Registry Key Not Found
Registry Key Not Found
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon|DefaultDomainName|REG_SZ|
Registry Key Not Found

The first key is in the registry and the output shows it isn't found.

The third key does have a value in the registry.

The sixth one does have a value in the registry.

The output on a 32bit machine is:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon|AutoAdminLogon|REG_SZ|1
Registry Key Not Found
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon|DefaultUserName|REG_SZ|UserName
Registry Key Not Found
Registry Key Not Found
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon|DefaultDomainName|REG_SZ|DOCFXIT
Registry Key Not Found

Thanks for looking at it.

Docfxit

Link to comment
Share on other sites

 

When running on 64-bit Windows if you want to read a value specific to the 64-bit environment you have to suffix the HK... with 64 i.e. HKLM64.

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

Yep, simply using @OSArch to find if it is X64 or X86 would help. :D

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

Yep, simply using @OSArch to find if it is X64 or X86 would help. :D

 

That's super.  I will add that macro right now.  It sure makes life easy. 

Thanks a bunch.

Thank you both.   That makes it tough to decide which answer to mark as solved.

Docfxit

Link to comment
Share on other sites

Just happy we could help. ;)

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

That worked great even though it doesn't show that in the registry.  I had no idea that would be required.

Amazing.

You guys are really great.

Thanks,

Docfxit

 

Thought it might be something like that. You want to read the 64-bit keys, and the Registry Redirector gave you the 32-bit keys.

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...