Schreibt keinen Registry Eintrag und kopiert Datei beim zweiten Mal nicht

  • Hey Leute,

    ich habe mal ein "kleines" Problem. Schon habe ich "Kirjaudu" fertiggestellt, funktioniert es nicht. Jedenfalls nicht ganz. Beim ersten Start funktioniert es, dann aber nicht mehr. Ich musste das Programm sogar noch einmal schreiben, aber es geht trotzdem nicht. Hier ist das Script:

    [autoit]

    #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
    #AutoIt3Wrapper_Icon=..\..\Icons\Basic\Basic_set2_Win\photo.ico
    #AutoIt3Wrapper_Outfile=Kirjaudu.exe
    #AutoIt3Wrapper_UseX64=n
    #AutoIt3Wrapper_Res_Comment=Change your Login Wallpaper in Finish
    #AutoIt3Wrapper_Res_Description=Kirjaudu
    #AutoIt3Wrapper_Res_Fileversion=1.1
    #AutoIt3Wrapper_Res_LegalCopyright=(C) LimeSoft Solutions 2012
    #AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator
    #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <GDIPlus.au3>
    _GDIPlus_Startup()
    #region ### START Koda GUI section ### Form=C:\Users\Administrator\Documents\StevenX Media\Kirjaudu\1.1\Gui1.kxf
    $Form1 = GUICreate("Kirjaudu 1.1", 628, 338, 192, 124)
    $Label1 = GUICtrlCreateLabel("Kirjaudu", 232, 24, 148, 49)
    GUICtrlSetFont(-1, 30, 400, 0, "Myriad")
    $Start_1 = GUICtrlCreateButton("Click to start", 24, 136, 569, 89)
    GUISetState(@SW_SHOW)
    #endregion ### END Koda GUI section ###

    [/autoit][autoit][/autoit][autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Start_1
    GUISetState(@SW_HIDE, $Form1)
    $Photo_File = FileOpenDialog("Open the Photo", "", "JPG Photo(*.jpg)")
    _GUI2()
    EndSwitch
    WEnd
    Func _GUI2()
    #region ### START Koda GUI section ### Form=c:\users\administrator\documents\stevenx media\kirjaudu\1.1\gui2.kxf
    $Kirjaudu2 = GUICreate("Kirjaudu 1.1", 630, 453, 309, 100)
    $Group1 = GUICtrlCreateGroup("File Informations", 32, 32, 569, 337)
    $Photo_Dim_L = GUICtrlCreateLabel("Photo Dimensions:", 40, 64,100,100)
    $Photo_Size_L = GUICtrlCreateLabel("Photo Size:", 40, 104,100,100)
    $Desktop_Dim_L = GUICtrlCreateLabel("Desktop Dimensions:", 40, 144,100,100)
    $Ready_L = GUICtrlCreateLabel("Status:", 40, 176,100,100)
    $Pic1 = GUICtrlCreatePic ("", 328, 64, 265,250)
    $Photo_Label = GUICtrlCreateLabel("Photo Path: ", 200, 328,500)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Start_Button = GUICtrlCreateButton("Start", 32, 384, 209, 41)
    $Revert_Button = GUICtrlCreateButton("Back To Normal", 280, 384, 209, 41)
    $Label5 = GUICtrlCreateLabel("Kirjaudu", 240, 8, 103, 36)
    GUICtrlSetFont(-1, 20, 400, 0, "Myriad")
    GUICtrlSetColor(-1, 0x646464)
    GUISetState(@SW_SHOW, $Kirjaudu2)
    GUICtrlSetImage($Pic1, $Photo_File)
    $hImage = _GDIPlus_ImageLoadFromFile($Photo_File)
    $Photo_width = _GDIPlus_ImageGetWidth($hImage)
    $Photo_height = _GDIPlus_ImageGetHeight($hImage)
    GUICtrlSetData($Photo_Label, "Photo Path: " & $Photo_File)
    GUICtrlSetData($Photo_Size_L, "Photo Size: " & FileGetSize($Photo_File) / 1024 & " Kilobytes")
    GUICtrlSetData($Photo_Dim_L, "Dimensions: " & $Photo_width & "X" & $Photo_height)
    GUICtrlSetData($Desktop_Dim_L, "Desktop Dimensions: " & @DesktopWidth & "X" & @DesktopHeight)
    If $Photo_width & "X" & $Photo_height <> @DesktopWidth & "X" & @DesktopHeight And FileGetSize($Photo_File) > 256000 Then
    GUICtrlSetData($Ready_L, "Ready: The Photo size is bigger than 250 kilobytes." & @CRLF & "The Photo Dimensions are not equal with the dimensions of your Desktop. If you start, the picture will not appear.")
    ElseIf FileGetSize($Photo_File) > 256000 Then
    GUICtrlSetData($Ready_L, "Ready: The Photo size is bigger than 250 kilobytes. If you start, the picture will not appear.")
    ElseIf $Photo_width & "X" & $Photo_height <> @DesktopWidth & "X" & @DesktopHeight Then
    GUICtrlSetData($Ready_L, "Ready: The Photo Dimensions are not equal with the dimensions of your Desktop. But you can start")

    [/autoit][autoit][/autoit][autoit]

    Else
    GUICtrlSetData($Ready_L, "Ready: You can start")
    EndIf
    While 1

    [/autoit][autoit][/autoit][autoit]

    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Start_Button
    DirRemove( 'C:\Windows\System32\oobe\Info\backgrounds\')
    DirCreate( 'C:\Windows\System32\oobe\Info\backgrounds\')
    FileDelete( 'C:\Windows\System32\oobe\Info\backgrounds\backgroundDefault.jpg')
    RegDelete( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Background", "OEMBackground");This is the Registry Key for the Background
    $Reg = RegWrite( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Background", "OEMBackground", "REG_DWORD", "1")
    $Copy = FileCopy( $Photo_File, 'C:\Windows\System32\oobe\Info\backgrounds\backgroundDefault.jpg', 8)
    If $Copy = 0 AND $Reg = 0 Then
    MsgBox( 0+16, "ERROR", "Could not edit Registry AND could not copy photo")
    ElseIf $Reg = 0 Then
    MsgBox( 0+16, "ERROR", "Could not edit Registry")
    ElseIf $Copy = 0 Then
    MsgBox( 0+16, "ERROR", "Could not copy photo")
    Else
    MsgBox( 0+64, "Successful", "Finished successfully")
    EndIf
    Case $Revert_Button
    $Reg_Del = RegDelete( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Background", "OEMBackground")
    $Reg = RegWrite( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Background", "OEMBackground", "REG_DWORD", "0")
    If $Reg_Del = 0 AND $Reg = 0 Then
    MsgBox( 0+16, "ERROR", "Could not edit Registry AND could not copy photo")
    ElseIf $Reg = 0 Then
    MsgBox( 0+16, "ERROR", "Could not edit Registry")
    ElseIf $Reg_Del = 0 Then
    MsgBox( 0+16, "ERROR", "Could not copy photo")
    Else
    MsgBox( 0+64, "Successful", "Finished successful")
    EndIf

    [/autoit][autoit][/autoit][autoit]

    EndSwitch
    WEnd
    EndFunc ;==>_GUI2

    [/autoit]

    Der wesentliche Teil ist dieser:

    [autoit]

    DirRemove( 'C:\Windows\System32\oobe\Info\backgrounds\')
    DirCreate( 'C:\Windows\System32\oobe\Info\backgrounds\')
    FileDelete( 'C:\Windows\System32\oobe\Info\backgrounds\backgroundDefault.jpg')
    RegDelete( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Background", "OEMBackground");This is the Registry Key for the Background
    $Reg = RegWrite( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Background", "OEMBackground", "REG_DWORD", "1")
    $Copy = FileCopy( $Photo_File, 'C:\Windows\System32\oobe\Info\backgrounds\backgroundDefault.jpg', 8)
    If $Copy = 0 AND $Reg = 0 Then
    MsgBox( 0+16, "ERROR", "Could not edit Registry AND could not copy photo")
    ElseIf $Reg = 0 Then
    MsgBox( 0+16, "ERROR", "Could not edit Registry")
    ElseIf $Copy = 0 Then
    MsgBox( 0+16, "ERROR", "Could not copy photo")
    Else
    MsgBox( 0+64, "Successful", "Finished successfully")
    EndIf

    [/autoit]

    Ich hoffe, ihr könnt mir helfen.

    MFG,

    Stevenx

    [Blockierte Grafik: http://stefan.blagojevic.at/loading.gif]

    Design, Modellbau, CAD <3
    AutoCAD, ArchiCAD, REVIT (ist ein Scheiss, habe aber das Zertifikat)

    Cinema 4D, RuckZuck Statik Programm

    Michael Bay als Architekt


    Da eine Glasfassade! Booom Sichtbeton! Laminiertes Bild auf Mosaiksteinchen! Granit! Granit! Granit! Sichtbetonwand mit 50° Neigung!
    Holzverkleidung erscheint da! Boooooom!

    Einmal editiert, zuletzt von Stevenx (14. Januar 2012 um 23:06) aus folgendem Grund: Gelöst - Danke Matricus!

  • Ich gehe einmal davon aus, dass du ein 64bit Betriebssystem hast du aber eine 32bit Applikation erzeugst.

    Falls dies zutrifft, so leitet Windows deine Anfragen auf Windows- oder Registry Verzeichnisse automatisch auf die 32bit Version um, anstatt, wie es nötig wäre, auf die 64bit Pfade zuzugreifen (Stichwort: Abwärtskompatibilität).
    In der Registry ist das HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\... bzw. \Windows\SysWOW64 bei Verzeichnisanfragen.

    Bei der Registry ist es möglich dies direkt zu umgehen (HKLM64\Software\... - siehe Hilfe), bei Pfaden jedoch nicht.

    Folgende Zeile einfach an den Anfang deines Scriptes setzen, dann sollte die Umleitung für Verzeichniszugriffe für das laufende Programm deaktiviert sein (und du musst nichts am Code ändern):

    [autoit]

    DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "int", 1)

    [/autoit]

    2 Mal editiert, zuletzt von Matricus (15. Januar 2012 um 04:02)

  • Hey, danke funktioniert :D solche umständlichkeiten muss es nur bei Windows geben :cursing: Jetzt darf ich mal alle Kopien vom Programm im Internet ändern...

    MFG,

    StevenX

    [Blockierte Grafik: http://stefan.blagojevic.at/loading.gif]

    Design, Modellbau, CAD <3
    AutoCAD, ArchiCAD, REVIT (ist ein Scheiss, habe aber das Zertifikat)

    Cinema 4D, RuckZuck Statik Programm

    Michael Bay als Architekt


    Da eine Glasfassade! Booom Sichtbeton! Laminiertes Bild auf Mosaiksteinchen! Granit! Granit! Granit! Sichtbetonwand mit 50° Neigung!
    Holzverkleidung erscheint da! Boooooom!