DigitalFacade82 Posted September 17, 2013 Author Share Posted September 17, 2013 Here is my final code for compiled script Other resources are available here: https://github.com/Jarmezrocks/Windows7GifViewer You will need: Installer setup icon Setup.ico AutoIT Au3 script Windows7GifViewer.au3 Windows XP rundll32.exe Windows XP shimgvw.dll and my Windows 7 Gif viewer splash.jpg It's less than 700kb. Can someone please try it before they make judgements or comments please, I need to know if this is unique to me or if this will be a solution for everyone? expandcollapse popup#NoTrayIcon #RequireAdmin #region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=Setup.ico #AutoIt3Wrapper_Outfile=Windows_7_GifViewer.exe #endregion ;**** Directives created by AutoIt3Wrapper_GUI **** #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.8.1 Author: Jarmezrocks aka Digitalfacade82 jarmezrocks@gmail.com Script Function: This installer is based off the one written by Corgano, CorganoWade@gmail.com from sevenforums and autoIT forums Additions added by me: 1. Instead of forcing us to install anywhere let alone root of the system drive I would rather give people a choice. This makes the solution a bit more "polished" - Note as it was I was using Corgano's installer and then carrying with me an additional reg file to run afterwards to move the install away from the root of C:\ and correct the following: 2. I made some small adjustments to Registry writes to incorrect locations that were annoying for me to have to go and change after installing 3. Correctly added the rundll32.exe in compatability mode for Windows XP Service Pack 3 4. I fixed a lot of spelling mistakes, but drastically changed the script so most likely added some as well :-) Notes taken directly from Corgano's script "This script provides a one-click Installation for easy gif viewing experience identical (literally!) to that of windows XP Terms of use: This script is free to use, distribute, modify, and what else have your fancies be as long as these three conditions are met 1: This header must remain intact with any mods or copies of this script 2: You may not sell or in any way make profit off of this script. It's free, for free use by anyone, anywhere. 3: This is by no means an official fix. It's just a workaround to make windows XP's photo viewer work on win 7. May work for win 8, may fuck up your computer. I'm not responsible for any loss of data or hair as result of this program What it does: This is based off of this idea - http://www.goofwear.com/windows/ However, there were many errors. All the addresses were static, and assumed that the system drive was C:. It doesn't work if your system drive isn't C:, so I re-wrote it to use %WinDir% making it much, MUCH more robust. I also moved the files to windows\gif, which is cleaner IMO. Replaced the modified "shimgvw.dll" with the real file and wrote a simpler Installer 1.1 Added an unInstall option Fixed spelling mistakes (derp) Added message confirming Install Enjoy" You will require AutoIT version 3x to run this as an uncompiled script. Please use the exe provided. #ce ---------------------------------------------------------------------------- $Title = "Windows 7 Fax & Scan Gif Viewer" #include <GUIConstantsEx.au3> #include <File.au3> #include <Process.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #include <EditConstants.au3> #include <StaticConstants.au3> WinSetOnTop("Windows_7_GifViewer.exe", "", 1) Opt("WinTitleMatchMode", 2) Func CreateSplash() EnvSet("path", EnvGet("path") & ";" & @ScriptDir) ;Include splash image in exe FileInstall("splash.jpg", @TempDir & "\splash.jpg", 1) ;Show splash $splash = GUICreate("Loading...", 430, 154, -1, -1, $WS_POPUPWINDOW) WinSetTrans($splash, "", 0) GUICtrlCreatePic(@TempDir & "\splash.jpg", -0, -0, 432, 155) GUISetState(@SW_SHOW, $splash) For $i = 0 To 255 Step 6 WinSetTrans($splash, "", $i) Sleep(1) Next Sleep(3000) GUIDelete($splash) MsgBox(0, "", "Please select a location to install Windows 7 Gif Viewer") EndFunc ;==>CreateSplash Func SystemCheck() Local $path = FileSelectFolder("Please select install location", "") Local $command, $command1, $command2, $command3, $command4, $command5, $Msg1 ;Detect if another installation exists If FileExists('C:\rundll32.exe') Then FileDelete('C:\rundll32.exe') EndIf If FileExists('C:\shimgvw.dll') Then FileDelete('C:\shimgvw.dll') EndIf If FileExists('C:\Windows\Gif\rundll32.exe') Then FileDelete('C:\Windows\Gif\rundll32.exe') EndIf If FileExists('C:\Windows\Gif\shimgvw.dll') Then FileDelete('C:\shimgvw.dll') EndIf If FileExists('C:\Windows\Gif') Then Run(@ComSpec & " /c rd C:\Windows\Gif", @SW_HIDE) EndIf If RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers", $path & "\Windows7GifViewer\rundll32.exe") = "WINXPSP3" Or FileExists($path & '\Windows7GifViewer') Then ;If one does exist ask to remove it $Msg1 = MsgBox(3, "Application already installed", "Setup has detected a previous installation" & @CRLF & "Would you like to uninstall the existing Windows 7 Gif Viewer first?") Select Case $Msg1 = 6 ConsoleWrite("Remove" & @CRLF) RegDelete('HKEY_CLASSES_ROOT\.GIF') RegDelete('HKEY_CLASSES_ROOT\GIFImage.Document') RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers", $path & "\Windows7GifViewer\rundll32.exe") FileDelete($path & "\Windows7GifViewer") DirRemove($path & "\Windows7GifViewer") ;neither of the above work so good ol dos seems to do the trick here $command = 'rd Windows7GifViewer ' & '>nul ' & '2>&1' Run(@ComSpec & " /c " & $command, $path, @SW_HIDE) $command1 = 'del /Q' & $path & '\Windows7GifViewer ' & '>nul ' & '2>&1' Run(@ComSpec & " /c " & $command, $path, @SW_HIDE) MsgBox(0, "Existing Installation Removed", "Please re-run the installer to install again") Case $Msg1 = 7 Local $RegPath = ($path & "\Windows7GifViewer\shimgvw.dll,4") ; Double check there's no directory before prompting the user if they want to create one If Not FileExists($path & '\Windows7GifViewer') Then If MsgBox(36, "Location does not exist", "There is no directory for Windows 7 Gif Viewer? " & @CRLF & "Would you like to create one?") = 6 Then DirCreate($path & '\Windows7GifViewer') ConsoleWrite("Install" & @CRLF) ;Commence installation EnvSet("path", EnvGet("path") & ";" & @ScriptDir) FileInstall("rundll32.exe", $path & "\Windows7GifViewer\rundll32.exe", 1) FileInstall("shimgvw.dll", $path & "\Windows7GifViewer\shimgvw.dll", 1) ;For some reason again this likes to only register from the command line? $command2 = 'regsvr32 /s ' & $path & "\Windows7GifViewer\rundll32.exe" $command3 = 'regsvr32 /s ' & $path & "\Windows7GifViewer\shimgvw.dll" Run(@ComSpec & " /c " & $command2, $path & "\Windows7GifViewer", @SW_HIDE) Run(@ComSpec & " /c " & $command3, $path & "\Windows7GifViewer", @SW_HIDE) ;Here commence normal Writes to the registry....all is good from here on RegWrite('HKEY_CLASSES_ROOT\.GIF', '', 'REG_SZ', 'GIFImage.Document') RegWrite('HKEY_CLASSES_ROOT\GIFImage.Document', 'EditFlags', 'REG_DWORD', '65536') RegWrite('HKEY_CLASSES_ROOT\GIFImage.Document', 'FriendlyTypeName', 'REG_EXPAND_SZ', $path & "\Windows7GifViewer\shimgvw.dll" & ',-306') RegWrite('HKEY_CLASSES_ROOT\GIFImage.Document', 'InstallTemp', 'REG_EXPAND_SZ', @ScriptDir) RegWrite('HKEY_CLASSES_ROOT\GIFImage.Document', 'ImageOptionFlags', 'REG_DWORD', '0') RegWrite('HKEY_CLASSES_ROOT\GIFImage.Document', 'BrowserFlags', 'REG_DWORD', '8') RegWrite('HKEY_CLASSES_ROOT\GIFImage.Document', '', 'REG_SZ', 'GIF Image') RegWrite('HKEY_CLASSES_ROOT\GIFImage.Document\DefaultIcon', '', 'REG_EXPAND_SZ', $path & "\Windows7GifViewer\shimgvw.dll" & ',4') RegWrite('HKEY_CLASSES_ROOT\GIFImage.Document\shell', '', 'REG_SZ', '') RegWrite('HKEY_CLASSES_ROOT\GIFImage.Document\shell\open', '', 'REG_SZ', 'Windows 7 Gif Viewer') RegWrite('HKEY_CLASSES_ROOT\GIFImage.Document\shell\open', 'Icon', 'REG_SZ', $path & "\Windows7GifViewer\shimgvw.dll") RegWrite('HKEY_CLASSES_ROOT\GIFImage.Document\shell\open\command', '', 'REG_EXPAND_SZ', $path & '\Windows7GifViewer' & '\rundll32.exe shimgvw.dll,ImageView_Fullscreen %1') RegWrite('HKEY_CLASSES_ROOT\GIFImage.Document\shell\open\DropTarget', 'Clsid', 'REG_SZ', '{E84FDA7C-1D6A-45F6-B725-CB260C236066}') RegWrite('HKEY_CLASSES_ROOT\GIFImage.Document\shell\printto\command', '', 'REG_SZ', $path & '\Windows7GifViewer' & '\rundll32.exe shimgvw.dll,ImageView_PrintTo /pt "%1" "%2" "%3" "%4"') RegWrite('HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers', $path & '\Windows7GifViewer' & '\rundll32.exe', 'REG_SZ', 'WINXPSP3') ;Corrected the key from HKLM to HKCU to make this work - This is why rundll32.exe was not actually being set to Windows SP3 mode RegWrite('HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers', $path & '\Windows7GifViewer' & '\rundll32.exe', 'REG_SZ', 'WINXPSP3') Run("explorer.exe", Call(ProcessClose("explorer.exe"))) Sleep(500) Run("explorer.exe /n,/e," & $path & "\Windows7GifViewer") Opt('WinTitleMatchMode', 2) Sleep(100) WinSetState("Windows7GifViewer", "", @SW_HIDE) Sleep(100) Run("explorer.exe /n,/e," & @WorkingDir) Opt('WinTitleMatchMode', 2) Sleep(100) WinSetState(@WorkingDir, "", @SW_HIDE) Sleep(100) WinMinimizeAll() Sleep(200) Run("explorer.exe /n,/e," & @UserProfileDir & "\Pictures") Sleep(500) MsgBox(0, "Installation Complete!", "To run any .Gif animation simply double click the .Gif file" & @CRLF & "" & @CRLF & "To Uninstall Windows 7 Gif Viewer, please re-run the installation" & @CRLF & "and select the same location where it was installed") Opt('WinTitleMatchMode', 2) WinWaitActive("Installation Complete!", "", 3) WinSetOnTop("Installation Complete!", "", 1) WinSetState("Installation Complete!", "", @SW_MAXIMIZE) EndIf EndIf Case $Msg1 = 2 MsgBox(48 + 4096, "Installation Aborted!", "User cancelled installation", 5) ;This part will only work once the script is compiled If ProcessExists("Windows_7_GifViewer.exe") Then OnAutoItExitRegister("Restart") Exit EndIf EndSelect Else ;Obviously here I was lazy and couldn't bothered to a re-arrange all my code with a nicer loop ;A good developer never re-uses large chunks of code twice! If Not FileExists($path & '\Windows7GifViewer') Then If MsgBox(36, "Location does not exist", "There is no directory for Windows 7 Gif Viewer? " & @CRLF & "Would you like to create one?") = 6 Then DirCreate($path & '\Windows7GifViewer') ConsoleWrite("Install" & @CRLF) ;Commence installation EnvSet("path", EnvGet("path") & ";" & @ScriptDir) FileInstall("rundll32.exe", $path & "\Windows7GifViewer\rundll32.exe", 1) FileInstall("shimgvw.dll", $path & "\Windows7GifViewer\shimgvw.dll", 1) ;For some reason again this likes to only register from the command line? $command4 = 'regsvr32 /s ' & $path & "\Windows7GifViewer\rundll32.exe" $command5 = 'regsvr32 /s ' & $path & "\Windows7GifViewer\shimgvw.dll" Run(@ComSpec & " /c " & $command4, $path & "\Windows7GifViewer", @SW_HIDE) Run(@ComSpec & " /c " & $command5, $path & "\Windows7GifViewer", @SW_HIDE) ;Here commence normal Writes to the registry....all is good from here on RegWrite('HKEY_CLASSES_ROOT\.GIF', '', 'REG_SZ', 'GIFImage.Document') RegWrite('HKEY_CLASSES_ROOT\GIFImage.Document', 'EditFlags', 'REG_DWORD', '65536') RegWrite('HKEY_CLASSES_ROOT\GIFImage.Document', 'FriendlyTypeName', 'REG_EXPAND_SZ', $path & "\Windows7GifViewer\shimgvw.dll" & ',-306') RegWrite('HKEY_CLASSES_ROOT\GIFImage.Document', 'InstallTemp', 'REG_EXPAND_SZ', @ScriptDir) RegWrite('HKEY_CLASSES_ROOT\GIFImage.Document', 'ImageOptionFlags', 'REG_DWORD', '0') RegWrite('HKEY_CLASSES_ROOT\GIFImage.Document', 'BrowserFlags', 'REG_DWORD', '8') RegWrite('HKEY_CLASSES_ROOT\GIFImage.Document', '', 'REG_SZ', 'GIF Image') RegWrite('HKEY_CLASSES_ROOT\GIFImage.Document\DefaultIcon', '', 'REG_EXPAND_SZ', $path & "\Windows7GifViewer\shimgvw.dll" & ',4') RegWrite('HKEY_CLASSES_ROOT\GIFImage.Document\shell', '', 'REG_SZ', '') RegWrite('HKEY_CLASSES_ROOT\GIFImage.Document\shell\open', '', 'REG_SZ', 'Windows 7 Gif Viewer') RegWrite('HKEY_CLASSES_ROOT\GIFImage.Document\shell\open', 'Icon', 'REG_SZ', $path & "\Windows7GifViewer\shimgvw.dll") RegWrite('HKEY_CLASSES_ROOT\GIFImage.Document\shell\open\command', '', 'REG_EXPAND_SZ', $path & '\Windows7GifViewer' & '\rundll32.exe shimgvw.dll,ImageView_Fullscreen %1') RegWrite('HKEY_CLASSES_ROOT\GIFImage.Document\shell\open\DropTarget', 'Clsid', 'REG_SZ', '{E84FDA7C-1D6A-45F6-B725-CB260C236066}') RegWrite('HKEY_CLASSES_ROOT\GIFImage.Document\shell\printto\command', '', 'REG_SZ', $path & '\Windows7GifViewer' & '\rundll32.exe shimgvw.dll,ImageView_PrintTo /pt "%1" "%2" "%3" "%4"') RegWrite('HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers', $path & '\Windows7GifViewer' & '\rundll32.exe', 'REG_SZ', 'WINXPSP3') ;Corrected the key from HKLM to HKCU to make this work - This is why rundll32.exe was not actually being set to Windows SP3 mode RegWrite('HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers', $path & '\Windows7GifViewer' & '\rundll32.exe', 'REG_SZ', 'WINXPSP3') Run("explorer.exe", Call(ProcessClose("explorer.exe"))) Sleep(500) Run("explorer.exe /n,/e," & $path & "\Windows7GifViewer") Sleep(100) Opt('WinTitleMatchMode', 2) WinSetState("Windows7GifViewer", "", @SW_HIDE) Sleep(100) Run("explorer.exe /n,/e," & @WorkingDir) Opt('WinTitleMatchMode', 2) WinSetState(@WorkingDir, "", @SW_HIDE) Sleep(100) WinMinimizeAll() Sleep(200) Run("explorer.exe /n,/e," & @UserProfileDir & "\Pictures") Sleep(500) MsgBox(1, "Installation Complete!", "To run any .Gif animation simply double click the .Gif file" & @CRLF & "" & @CRLF & "To Uninstall Windows 7 Gif Viewer, please re-run the installation" & @CRLF & "and select the same location where it was installed") Opt('WinTitleMatchMode', 2) WinWaitActive("Installation Complete!", "", 3) WinSetOnTop("Installation Complete!", "", 1) WinSetState("Installation Complete!", "", @SW_MAXIMIZE) EndIf EndIf EndIf EndFunc ;==>SystemCheck Func Restart() Run(@ScriptDir & "\Windows_7_GifViewer.exe") EndFunc ;==>Restart Func Cleanup() FileDelete(@TempDir & "\splash.jpg") EndFunc ;==>Cleanup Sleep(100) CreateSplash() SystemCheck() Cleanup() Link to comment Share on other sites More sharing options...
BrewManNH Posted September 17, 2013 Share Posted September 17, 2013 And as others pointed out EnvSet doesn't run at compile time, so there's no way to set the environment variable to the scriptdir before running the script at least once. Try it on a fresh script that you have never run from SciTE before and you'll see for yourself. Relative paths work for fileinstall and your workaround won't. 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 GudeHow 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 Link to comment Share on other sites More sharing options...
DW1 Posted September 17, 2013 Share Posted September 17, 2013 For the destination, you can use whatever combination of log/variables that you want, it is only the source that must be a literal string with no variables or logic (the reason is because the file is added at compile, and the script is not executed at compile, so how could it know what the contents of the variable or logic could be). What Trancexx posted works as expected since there is no logic or variable in the source parameter. AutoIt3 Online Help Link to comment Share on other sites More sharing options...
DigitalFacade82 Posted September 17, 2013 Author Share Posted September 17, 2013 Please don't dismiss me without trying it. Try it and then post back here with you logical answers as to why. I am not arguing with you, I am saying that your logic as clear as it may seem doesn't work. And my logic as silly as it sounds works. I need confirmation not arguments. Please download the source and compile the script and report back. Link to comment Share on other sites More sharing options...
MHz Posted September 17, 2013 Share Posted September 17, 2013 I understand that you are not being a smarty pants. You seem confused to me as what is the truth in all of this. I have some knowledge with CMD and AutoIt and am rather amused by all you cover to come to the conclusions. And to note, AutoIt does not have an EndLocal like CMD has. Here is a simple test for you to understand FileInstall I hope with relative paths. Create a au3 script with this in it inside a empty folder. DirCreate(@ScriptDir & "\Windows7GifViewer") FileInstall("rundll32.exe", @ScriptDir & "\Windows7GifViewer\rundll32.exe", 1) At a command prompt at the working directory at the folder, type: copy %systemroot%\system32\rundll32.exe . So you now have the script and rundll32.exe in the same directory. Now compile the script. Run the compiled script. You should then see the "Windows7GifViewer" folder created and rundll32.dll will be inside it. If it fails then repeat the steps as you may have made a mistake. Note that FileInstall will not create the folder path with the destination so you may need to use DirCreate. So you can work relative to the script so another user that you share the script with can also use a relative path to compile the script. Or am I missing something of special interest? I am here to help. Meanwhile, I will review your current source in the 1st post. Link to comment Share on other sites More sharing options...
DigitalFacade82 Posted September 17, 2013 Author Share Posted September 17, 2013 I don't know why, but the same code doesn't register the dll against the .gif file type correctly when I try it the other way. I have two scripts in front of me one compiled each way and one that does not compile at all. One of Trancexx's solutions works, the one that claimed to work better doesn't work. When running the exe, the one that Trancexx suggested that did compile does not register the dlls properly to the gif file? It leaves slashes out of the path in the registry and displays a broken icon for the .gif file. I am not sure why this is the case? Works EnvSet("path", EnvGet("path") & ";" & @ScriptDir) FileInstall("rundll32.exe", $path & "\Windows7GifViewer\rundll32.exe", 1) FileInstall("shimgvw.dll", $path & "\Windows7GifViewer\shimgvw.dll", 1) Partially works? broken paths in registry trancexx, on 17 Sept 2013 - 6:12 PM, said: How is that different than simple and obvious: FileInstall("rundll32.exe", @ScriptDir & "Windows7GifViewerrundll32.exe", 1) Doesn not work trancexx, on 17 Sept 2013 - 6:12 PM, said: Or even better: FileInstall(".rundll32.exe", @ScriptDir & "Windows7GifViewerrundll32.exe", 1) Link to comment Share on other sites More sharing options...
DigitalFacade82 Posted September 17, 2013 Author Share Posted September 17, 2013 It could quite well be that I am doing something incorrect still? but this is what happens for file type icons FileInstall("rundll32.exe", @ScriptDir & "\Windows7GifViewer\rundll32.exe", 1) Ends up being "C:Program Files (x86) Windows7GifViewershimgvw.dll" .....................................^ missing slashes? I had this issue all last week for some unknown reason? I still don't know. But it doesn't write to the registry correctly? See for me reading this from the help FileInstall ( "source", "dest" [, flag] ) @scriptdir makes no sense to me? Say if I have the exe installer downloaded to my downloads drive which is D: Then say me the user goes through the installation. I choose a location for the installation to be installed. At that location there is currently no directory for the application where ever that may be? Lets say C:Program Files (x86) That then becomes $path in the script. There is some checking etc etc for previous installs bla bla bla but then it otherwise creates a folder called Windows7GifViewer inside of C:Program Files (x86). C:Program Files (x86)Windows7GifViewer @ScriptDir is back on D: ? Why would I use @ScriptDir? That would make sense to install files at D:Windows7GifViewer Wouldn't it? To me it seems logical to have FileInstall ( "source", "dest" [, flag] ) ..................." source", "destination ", 1) FileInstall("rundll32.exe", $path & "Windows7GifViewerrundll32.exe", 1) Keep in mind that path and $path are different. This is something I have to ask the other guy I was working on another project with that I borrowed this code from. I ended up digging through an older script that I was working on with another guy on an Android forum for reverse engineering apk files. We used that particular line in the script. AutoIT crashes when I try to compile the following? It does not produce an error FileInstall(".rundll32.exe", @ScriptDir & "Windows7GifViewerrundll32.exe", 1) This below....somehow works without fail? Maybe it is something to do with my PC configuration, maybe not? All I know is that it works. It worked him too on the other project... I never questioned why? EnvSet("path", EnvGet("path") & ";" & @ScriptDir) FileInstall("rundll32.exe", $path & "Windows7GifViewerrundll32.exe", 1) FileInstall("shimgvw.dll", $path & "Windows7GifViewershimgvw.dll", 1) Link to comment Share on other sites More sharing options...
DigitalFacade82 Posted September 17, 2013 Author Share Posted September 17, 2013 Granted I am not so silly to know that when files don't install that of course there are not icons registered to the gif file, however I am saying that even when I do change the code to $Path instead of @ScriptDir and not use EnvSet("path", EnvGet("path") & ";" & @ScriptDir) prior, that it will result in files installed, a working app but broken icons in context menu and file type .gif? Just to note, also I owe Trancexx an apology, the second script does actually compile...there was some sort of glitch when I compiled just before posted earlier about this -> FileInstall(".rundll32.exe", @ScriptDir & "Windows7GifViewerrundll32.exe", 1) not compiling, well it does.....however it doesn't install at all for the reasons I mentioned in my previous post. What I wanted to discuss from all of this was a few things. 1) '?do=embed' frameborder='0' data-embedContent>> using this doesn't help anyone when they have an OS across two drives like myself. It is tricky, and the helper app is bound to the drive similar to to %CD% doesn't work when you have a batch script on another drive other than C: 2) Instead of the full path being the recommendation in the helpfile and the response from others assisting n00bs like me, maybe (if proven to work that is?) a simple 1 line solution that I have proposed could be a good alternative. It would negate the need for even using a FileInstall Helper app altogether. Link to comment Share on other sites More sharing options...
MHz Posted September 17, 2013 Share Posted September 17, 2013 The use of $path suits your task. The @scriptdir is just an example given that FileInstall can work in the script directory. You use FileSelectFolder to set a path to FileInstall the files which is suitable to do. Your use of EnvSet has no effect on anything that I can see of how you use it. trancexx 1 Link to comment Share on other sites More sharing options...
DigitalFacade82 Posted September 17, 2013 Author Share Posted September 17, 2013 I understand that you are not being a smarty pants. You seem confused to me as what is the truth in all of this. I have some knowledge with CMD and AutoIt and am rather amused by all you cover to come to the conclusions. And to note, AutoIt does not have an EndLocal like CMD has. Here is a simple test for you to understand FileInstall I hope with relative paths. Create a au3 script with this in it inside a empty folder. DirCreate(@ScriptDir & "\Windows7GifViewer") FileInstall("rundll32.exe", @ScriptDir & "\Windows7GifViewer\rundll32.exe", 1) At a command prompt at the working directory at the folder, type: copy %systemroot%\system32\rundll32.exe . So you now have the script and rundll32.exe in the same directory. Now compile the script. Run the compiled script. You should then see the "Windows7GifViewer" folder created and rundll32.dll will be inside it. If it fails then repeat the steps as you may have made a mistake. Note that FileInstall will not create the folder path with the destination so you may need to use DirCreate. So you can work relative to the script so another user that you share the script with can also use a relative path to compile the script. Or am I missing something of special interest? I am here to help. Meanwhile, I will review your current source in the 1st post. A couple of things. In most cases rundll32.exe would (and always has) resided in C:\Windows\System32\ for Windows 7, However the one provided with this app is not a Windows 7 version of rundll32.exe, this is the Windows XP one that has the additional functionality for the Windows XP Fax and Scanner application that plays gif files using the Windows XP version of shimgvw.dll (not the Windows 7 one that also resides in System32 as well). The destination has never been the issue, it was the compile that was the issue, although using @ScriptDir as per the Trancexx's recommendations it creates this problem lol. DirCreate(@ScriptDir & "Windows7GifViewer") <- This will never be an option. The user is never installing the application where the installation executable is located. Logically people download an installer, most of the time it is located somewhere like C:Users<UserName>Downloads In my case it just so happens to be that I have my Downloads Symlinked to another volume D: which is not unusual, anyway @ScriptDir would make a directory inside of Downloads which seems silly to me? I would guess and assume one of two places, either C:Program Files (x86) (or just C:Program Files for 32Bit) AND/OR C:Users<UserName>AppDataLocal. I wanted the installer to also be the uninstaller also to keep things simple and lightweight. So to uninstall all the user needs to do is run the installer again. Choose the parent folder and it removes everything for them. Had it been in the depths of AppData somewhere god only knows what that would spell for an unknowing person trying to locate the application to remove it LOL. Sure in good time I might get around to making a listing in Installed Programs in control panel but this was just a good working base to start off with for now. I guess I didn't explain myself real well.....or more so I guessed people would read all the information I posted before commenting. Maybe I just thought people could plainly read the flow and my decision making process in the script? It seemed obvious to me? The script prompts the user for the location to install (call it the parent folder) and because I don't know how to put "Create new folder" as part of the FileSelectFolder (not that I would want to and I will explain why in a minute); to me it seemed easier to prompt the user to for the app to create the directory for them. To do the alternative would mean I would have to create a GUI and add case select and all that jazz and would still need more code to read the directory (a custom one at that....you give people choices and it always makes things difficult) and then store that as a new variable to write the path to the registry...No thanks! Just thinking about all of that adds an overwhelming amount more complexity that isn't needed. If you give users the option of "Create new folder" in say a FolderList GUI then it leaves it open for them to call it what ever they want....Windows 7 Gif Viewer, Or Windows Fax and Scanner or anything? When you realised the frustrations I had last week with slashes "" randomly falling off paths written in the registry last week for no apparent reason what so ever, THEN you will understand my craziness in KISS (keep it simple stupid). For me FileSelectFolder and then creating a known Directory name of Windows7GifViewer (no spaces) inside of their directory of choice seems the simplest and easiest solution to get the job done. Prior to my installer users were already getting confused with right clicking the Windows XP rundll32 executable and setting it's properties to run in compatibility mode. My installer does all of that for them now, but I have nothing but issues with registry doing things any different to how you see the final script. Anyway I digress sorry. I just thought I would explain my logical reasoning behind why I made the choices I made. If someone can point me to info about when to use double quotes and when to use single quotes AutoIT for writing to the Windows registry that would be greatly appreciated. As you will see there are all sorts of mixed combinations in my install script that seem to do what I want. Why and how and reasoning behind that I have not got a single clue about? Some need double quotes to work some need single. Using the incorrect ones doesn't work? Link to comment Share on other sites More sharing options...
DigitalFacade82 Posted September 17, 2013 Author Share Posted September 17, 2013 The use of $path suits your task. The @scriptdir is just an example given that FileInstall can work in the script directory. You use FileSelectFolder to set a path to FileInstall the files which is suitable to do. Your use of EnvSet has no effect on anything that I can see of how you use it. I ended up getting frustrated with registry writes dropping off slashes in no particular order and for no reason. I went back to an old script that I knew did worked and cut that bit of code out (not just that one line) and things started working as intended? I will ask my friend to explain his reasoning behind it all as it isn't my work. Come to think of it I should add him to the credits of the script. All I knew is that he knew much much more than I did, and his script worked. Mine was not working. I added the whole file install routine and bobs ya aunty it started to work as intended and without corrupted/broken icons bla bla bla. Testing the script again without it tonight and the issues returned. I added my own reasoning to why it may have worked, hence why I wanted to discuss it :-) I think if you read my stupidly large post above you will gather why I made the choices that i made. All I know is that it works. I would like to know more about why, so that is where you guys come in I guess? you are all the more wiser than I, and have far more experience and context (even knowing bugs and tracking them through the years and the corrections and where things have developed from) all of that stuff is something that I don't have. Ask me about gym training, building performance cars, spatial sciences& cartography etc.....all of that is stuff I could probably surprise you with the amount of knowledge I have haha Link to comment Share on other sites More sharing options...
MHz Posted September 17, 2013 Share Posted September 17, 2013 I have finished hacking up your code. Much leaner now. expandcollapse popup#NoTrayIcon #RequireAdmin #region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=Setup.ico #AutoIt3Wrapper_Outfile=Windows_7_GifViewer.exe #endregion ;**** Directives created by AutoIt3Wrapper_GUI **** #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.8.1 Author: Jarmezrocks aka Digitalfacade82 jarmezrocks@gmail.com Script Function: This installer is based off the one written by Corgano, CorganoWade@gmail.com from sevenforums and autoIT forums Additions added by me: 1. Instead of forcing us to install anywhere let alone root of the system drive I would rather give people a choice. This makes the solution a bit more "polished" - Note as it was I was using Corgano's installer and then carrying with me an additional reg file to run afterwards to move the install away from the root of C:\ and correct the following: 2. I made some small adjustments to Registry writes to incorrect locations that were annoying for me to have to go and change after installing 3. Correctly added the rundll32.exe in compatability mode for Windows XP Service Pack 3 4. I fixed a lot of spelling mistakes, but drastically changed the script so most likely added some as well :-) Notes taken directly from Corgano's script "This script provides a one-click Installation for easy gif viewing experience identical (literally!) to that of windows XP Terms of use: This script is free to use, distribute, modify, and what else have your fancies be as long as these three conditions are met 1: This header must remain intact with any mods or copies of this script 2: You may not sell or in any way make profit off of this script. It's free, for free use by anyone, anywhere. 3: This is by no means an official fix. It's just a workaround to make windows XP's photo viewer work on win 7. May work for win 8, may fuck up your computer. I'm not responsible for any loss of data or hair as result of this program What it does: This is based off of this idea - http://www.goofwear.com/windows/ However, there were many errors. All the addresses were static, and assumed that the system drive was C:. It doesn't work if your system drive isn't C:, so I re-wrote it to use %WinDir% making it much, MUCH more robust. I also moved the files to windows\gif, which is cleaner IMO. Replaced the modified "shimgvw.dll" with the real file and wrote a simpler Installer 1.1 Added an unInstall option Fixed spelling mistakes (derp) Added message confirming Install Enjoy" You will require AutoIT version 3x to run this as an uncompiled script. Please use the exe provided. #ce ---------------------------------------------------------------------------- #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> WinSetOnTop("Windows_7_GifViewer.exe", "", 1) Opt("WinTitleMatchMode", 2) Sleep(100) CreateSplash() Global $path, $command1, $command2, $command3 Do $path = FileSelectFolder("Please select install location", "", 1) If @error And MsgBox(0x24, @ScriptName, 'Do you want to quit the installation?') = 6 Then Exit Until $path ;Detect if another installation exists If FileExists('C:\rundll32.exe') Then FileDelete('C:\rundll32.exe') EndIf If FileExists('C:\shimgvw.dll') Then RunWait('regsvr32 /s /u "C:\shimgvw.dll"') FileDelete('C:\shimgvw.dll') EndIf If FileExists('C:\Windows\Gif\rundll32.exe') Then FileDelete('C:\Windows\Gif\rundll32.exe') EndIf If FileExists('C:\Windows\Gif\shimgvw.dll') Then RunWait('regsvr32 /s /u "C:\Windows7GifViewer\shimgvw.dll"') FileDelete('C:\shimgvw.dll') EndIf If FileExists('C:\Windows\Gif') Then Run(@ComSpec & " /c rd C:\Windows\Gif", @SW_HIDE) EndIf If RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers", $path & "\Windows7GifViewer\rundll32.exe") = "WINXPSP3" Or FileExists($path & '\Windows7GifViewer') Then ;If one does exist ask to remove it Switch MsgBox(3, "Application already installed", "Setup has detected a previous installation" & @CRLF & "Would you like to uninstall the existing Windows 7 Gif Viewer first?") Case 6 ConsoleWrite("Remove" & @CRLF) RunWait('regsvr32 /s /u "' & $path & '\Windows7GifViewer\shimgvw.dll"') RegWrite('HKLM\SOFTWARE\Classes\.GIF', '', 'REG_SZ', 'giffile'); return to previous association RegDelete('HKLM\SOFTWARE\Classes\GIFImage.Document') RegDelete("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers", $path & "\Windows7GifViewer\rundll32.exe") Shell_Association_Change() DirRemove($path & "\Windows7GifViewer", 1) DirRemove($path) MsgBox(0, "Existing Installation Removed", "Please re-run the installer to install again") Case 7 ; Double check there's no directory before prompting the user if they want to create one If Not FileExists($path & '\Windows7GifViewer') Then If MsgBox(36, "Location does not exist", "There is no directory for Windows 7 Gif Viewer? " & @CRLF & "Would you like to create one?") = 6 Then Install() EndIf EndIf Case 2 MsgBox(48 + 4096, "Installation Aborted!", "User cancelled installation", 5) ;This part will only work once the script is compiled If ProcessExists("Windows_7_GifViewer.exe") Then OnAutoItExitRegister("Restart") Exit EndIf EndSwitch Else ;Obviously here I was lazy and couldn't bothered to a re-arrange all my code with a nicer loop ;A good developer never re-uses large chunks of code twice! If Not FileExists($path & '\Windows7GifViewer') Then If MsgBox(36, "Location does not exist", "There is no directory for Windows 7 Gif Viewer? " & @CRLF & "Would you like to create one?") = 6 Then Install() EndIf EndIf EndIf Cleanup() Exit Func CreateSplash() Local $splash ;Include splash image in exe FileInstall("splash.jpg", @TempDir & "\splash.jpg", 1) ;Show splash $splash = GUICreate("Loading...", 430, 154, -1, -1, $WS_POPUPWINDOW) WinSetTrans($splash, "", 0) GUICtrlCreatePic(@TempDir & "\splash.jpg", -0, -0, 432, 155) GUISetState(@SW_SHOW, $splash) For $i = 0 To 255 Step 6 WinSetTrans($splash, "", $i) Sleep(10) Next Sleep(2000) GUIDelete($splash) MsgBox(0, "", "Please select a location to install Windows 7 Gif Viewer") EndFunc ;==>CreateSplash Func Install() ; Not Local $path If DirCreate($path & '\Windows7GifViewer') Then ConsoleWrite("Install" & @CRLF) ;Commence installation FileInstall("rundll32.exe", $path & "\Windows7GifViewer\rundll32.exe", 1) If FileInstall("shimgvw.dll", $path & "\Windows7GifViewer\shimgvw.dll", 1) Then RunWait('regsvr32 /s "' & $path & '\Windows7GifViewer\shimgvw.dll"') EndIf ;Here commence normal Writes to the registry....all is good from here on RegWrite('HKLM\SOFTWARE\Classes\.GIF', '', 'REG_SZ', 'GIFImage.Document') RegWrite('HKLM\SOFTWARE\Classes\GIFImage.Document', 'EditFlags', 'REG_DWORD', '65536') RegWrite('HKLM\SOFTWARE\Classes\GIFImage.Document', 'FriendlyTypeName', 'REG_SZ', $path & "\Windows7GifViewer\shimgvw.dll" & ',-306') RegWrite('HKLM\SOFTWARE\Classes\GIFImage.Document', 'InstallTemp', 'REG_SZ', @ScriptDir) RegWrite('HKLM\SOFTWARE\Classes\GIFImage.Document', 'ImageOptionFlags', 'REG_DWORD', '0') RegWrite('HKLM\SOFTWARE\Classes\GIFImage.Document', 'BrowserFlags', 'REG_DWORD', '8') RegWrite('HKLM\SOFTWARE\Classes\GIFImage.Document', '', 'REG_SZ', 'GIF Image') RegWrite('HKLM\SOFTWARE\Classes\GIFImage.Document\DefaultIcon', '', 'REG_SZ', $path & "\Windows7GifViewer\shimgvw.dll" & ',4') RegWrite('HKLM\SOFTWARE\Classes\GIFImage.Document\shell', '', 'REG_SZ', '') RegWrite('HKLM\SOFTWARE\Classes\GIFImage.Document\shell\open', '', 'REG_SZ', 'Windows 7 Gif Viewer') RegWrite('HKLM\SOFTWARE\Classes\GIFImage.Document\shell\open', 'Icon', 'REG_SZ', $path & "\Windows7GifViewer\shimgvw.dll") RegWrite('HKLM\SOFTWARE\Classes\GIFImage.Document\shell\open\command', '', 'REG_SZ', $path & '\Windows7GifViewer' & '\rundll32.exe shimgvw.dll,ImageView_Fullscreen %1') RegWrite('HKLM\SOFTWARE\Classes\GIFImage.Document\shell\open\DropTarget', 'Clsid', 'REG_SZ', '{E84FDA7C-1D6A-45F6-B725-CB260C236066}') RegWrite('HKLM\SOFTWARE\Classes\GIFImage.Document\shell\printto\command', '', 'REG_SZ', $path & '\Windows7GifViewer' & '\rundll32.exe shimgvw.dll,ImageView_PrintTo /pt "%1" "%2" "%3" "%4"') RegWrite('HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers', $path & '\Windows7GifViewer' & '\rundll32.exe', 'REG_SZ', 'WINXPSP3') ;Corrected the key from HKLM to HKCU to make this work - This is why rundll32.exe was not actually being set to Windows SP3 mode RegWrite('HKCU\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers', $path & '\Windows7GifViewer' & '\rundll32.exe', 'REG_SZ', 'WINXPSP3') Shell_Association_Change() Sleep(500) MsgBox(0, "Installation Complete!", "To run any .Gif animation simply double click the .Gif file" & @CRLF & _ "" & @CRLF & "To Uninstall Windows 7 Gif Viewer, please re-run the installation" & @CRLF & _ "and select the same location where it was installed" _ ) EndIf EndFunc Func Restart() Run(@ScriptDir & "\Windows_7_GifViewer.exe") EndFunc ;==>Restart Func Cleanup() FileDelete(@TempDir & "\splash.jpg") EndFunc ;==>Cleanup Func Shell_Association_Change() Local Const $SHCNE_ASSOCCHANGED = 0x8000000, $SHCNF_FLUSH = 0x1000 ; function call presented by AZJIO to notify the system shell of a change by an event. DllCall('shell32.dll', 'none', 'SHChangeNotify', _ 'long', $SHCNE_ASSOCCHANGED, _ 'uint', $SHCNF_FLUSH, _ 'ptr', 0, _ 'ptr', 0 _ ); wEventId, uFlags, dwItem1, dwItem2 EndFunc The large double up of code has been merged. Double quotes added around some paths to help with success, especially the regsvr32 lines. Removed most of includes as they were not used. Put FileSelectFolder in a loop. Unregister Dlls at uninstall time. Associate .GIF to giffile at uninstall time. Added Shell_Association_Change() to refresh environment. Added flag 1 for DirRemove so RmDir backup no longer needed. Changed RegWrite HKCR to HKLMSOFTWAREClasses as it should be. Removed the EnvSet lines. See how it goes. I have tested it and seems to work fine. Link to comment Share on other sites More sharing options...
DigitalFacade82 Posted September 18, 2013 Author Share Posted September 18, 2013 (edited) Hey MHz, Thank you so much for that. I really appreciate your input I'm extremely exhausted right now. It's late and I have narcolepsy so I really need to sleep; I will take a look at what you did sometime tomorrow. Edit: Just had a read. Man you're awesome! Thank you so so much, owe you big time. Thanks again mate Edited September 18, 2013 by DigitalFacade82 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now