Jump to content
Sign in to follow this  
DigitalFacade82

Bug with FileInstall? [SOLVED] Maybe Help documentation should be updated?

Recommended Posts

DigitalFacade82

Hi guys,

irrelevant non-sense goes here

I think I maybe in a unique situation here? I think that there maybe a bug in AutoIT with FileInstall function? I could be wrong....but the reason for my suspicion is that I am running AutoIT on a PC with the main OS on a solid state drive and the User or data volume on a conventional HDD. Here is why I think this is the issue; initially I read and read and read help, other peoples posts on here who hadn't etc etc...all the suggestions posed to those members did not work for me?


Next I decided that I will use one of the scripts that was designed to help retards like me who can't get sh!t working. I tried that....guess what? I still get an error saying Invalid FileInstall function? hmmmm, I reinstalled AutoIT. Nothing changed.
 

I have made sure that the files are on a valid path string; there are no spaces even in the path either. My code is below.

I used File Install Utility by lafafmentvotre >here and I migrated on to trying SmOke_N's FileInstall Directory Helper >here

Resulting code output was something like so:

 

 

If Not FileExists(@TempDir & "") Then

    Do
        DirCreate(@TempDir & "")
    Until FileExists(@TempDir & "")
EndIf
FileInstall("E:UsersJamesDropboxWinAppsWindows7GifViewerrundll32.exe", @TempDir & "", 0)
FileInstall("E:UsersJamesDropboxWinAppsWindows7GifViewershimgvw.dll", @TempDir & "", 0)

 

and more info here...

Obviously I was not installing to TempDir....but even if I was I still get the same invalid FileInstall function error?

I noticed that I only had the option of choosing files located in my E: there is no option to select files that were installed on C:. I decided to put the script on C: as well as the two files. I put them in a directory; not in a directory and straight in the root of C:; I put the script in the same directory as the files and then I tried it not in the same directory.....guess what? All I can see is E:. It never gives an option for C:. I manually changed the path to point to the file son C: in the root of C and also in their own directory and STILL invalid FileInstall?

I decided to do it at the root of E: even with all the above said combinations and I cannot get it to work?

I pretty much give up now. I was only really doing this because I saw that there were people still asking about this application on sevenforums and some even eagerly awaiting for Corgano to return with a patched update. I felt sorry for them knowing that it does work and is easily fixed. Most people only having the issue of the pop-up error because they haven't set the executable to run in XP mode. 

As this script stands now. If I put it in the same directory as the DLL and EXE it installs correctly to anywhere on a users system that they choose. Even in a location with spaces in the path (which has been discussed as partly the reason why it doesn't work?).

My actual code for a Windows 7 Gif viewer based off the old XP Windows Fax & Scan application

#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() 

Edited by DigitalFacade82

Share this post


Link to post
Share on other sites
DigitalFacade82

I will give a lolly and a gold star to someone who can find out why me in particular cannot get this to work?

PS: I can dig up other combinations of snippets I have tried (some completely unchanged for the sake of consistency) posted by other forum members (that supposedly work for them?) if needs be? I have kept all backups of my scripts.

Share this post


Link to post
Share on other sites
NewPlaza

I can't see this script writing the registry entries either.

 

Try this at the very beginning of your script.

#RequireAdmin

Also, from the help file --> http://www.autoitscript.com/autoit3/docs/functions/FileInstall.htm

The destination directory path must already exist before this function is called, or the FileInstall will fail, returning 0 and not creating the file, nor path. See DirCreate() for information about creating the directory path.
 

DirCreate($path & "\Windows7GifViewer\")
FileInstall("E:\InstallFiles\rundll32.exe", $path & "\Windows7GifViewer\rundll32.exe", 1)
FileInstall("E:\InstallFiles\shimgvw.dll", $path & \"Windows7GifViewer\shimgvw.dll", 1)

EDIT: I forgot backslashes.....

Edited by NewPlaza

Share this post


Link to post
Share on other sites
JCEF

You have here a piece of work.

You have tried to use the 'FileInstall ()' without macros or variables? With the absolute path?
Perhaps the error occurs in the function 'FileSelectFolder ()' in the second parameter, since, as I understand, you changed the location of some folders as 'desktopdir', which is used in the second parameter of the function 'FileSelectFolder ()'.
Already analize the path that macros 'DesktopDir @', '@ HomeDrive' and '@ HomePath' return to you? Is that correct?
Execute the command 'SET' without parameters in MS-DOS and see if everything is right.

I hope these ideas help you to realize what is wrong in your script.

Share this post


Link to post
Share on other sites
orbs

you have described to very much details what you do and what you tried to do, which is excellent, but...

what is the problem?

- do you get error messages?

- do you get error codes?

- does your script crash?

- does it compile at all?

- does it work perfectly, without errors, but the files are not installed?

what is the return code of FileInstall() ? if there is an error, post a screenshot or something.

without this info it is very difficult to help you, since everyone who will run your script will not encounter any issues. the script is fine.

Share this post


Link to post
Share on other sites
DigitalFacade82

A whole lot of irrelevant info here....

Hi guys,

Sorry for delayed response, as mentioned this is an "on the side thing" and I only really wanted to help those people on the other forum....so thanks for your patience.

 

I can't see this script writing the registry entries either.

 

Try this at the very beginning of your script.

#RequireAdmin

Also, from the help file --> http://www.autoitscript.com/autoit3/docs/functions/FileInstall.htm

The destination directory path must already exist before this function is called, or the FileInstall will fail, returning 0 and not creating the file, nor path. See DirCreate() for information about creating the directory path.
 

DirCreate($path & "\Windows7GifViewer\")
FileInstall("E:\InstallFiles\rundll32.exe", $path & "\Windows7GifViewer\rundll32.exe", 1)
FileInstall("E:\InstallFiles\shimgvw.dll", $path & \"Windows7GifViewer\shimgvw.dll", 1)

EDIT: I forgot backslashes.....

 

Sorry I accidentally left that out when I copied and pasted as it had a heap of junk from the compile at the top of the script that would have blown out the size of my post in here. What I mean is that Yes #RequireAdmin is included in my actual script; I am just silly and left it out of my post. Thanks for that though. I didn't pick up on that when I posted.

Additional info:
Also DirCreate is not needed because the installer creates that earlier in the script if you noticed? Path is defined by FileSelectFolder + Windows7GifViewer (which it creates)
It detects if the location is there and if it isn't it creates it for the user. I can't have the $path & "Windows7GifViewerrundll32.exe" part as a full path, because I am never going to know where that is? I can't assume C:Program Files (x86)Windows7GifViewer just because that is where I install it. What if they are running a 32bit version of Windows 7? Or Windows Vista? Or what if their Program Files is not located on C:? This was the previous issue already noted by many users before when installing to C: that was hard coded in the original installer.
A developer cannot know this or predict this prior to compiling, so this I would consider to be a major bug and should be changed!

If by the very nature that FileInstall() needs to know the hard coded full path of where it is going to (where it is installing too - why should it need that location anyway?) by its very nature and the full path of where it is coming from when compiling at compile time is not enough; then I think the FileInstall() function bloody sucks balls!!! It should be re-written so that it doesn't do this. If that is the case also, then I will be scrapping the FileInstall() function and going with a 3rd party installer and probably should write contact the developer of the FileInstall() function about this issue. We aren't ALL on 32bit Windows XP ya know, there has been 3 releases of Windows since then.

You have here a piece of work.

You have tried to use the 'FileInstall ()' without macros or variables? With the absolute path?
Perhaps the error occurs in the function 'FileSelectFolder ()' in the second parameter, since, as I understand, you changed the location of some folders as 'desktopdir', which is used in the second parameter of the function 'FileSelectFolder ()'.
Already analize the path that macros 'DesktopDir @', '@ HomeDrive' and '@ HomePath' return to you? Is that correct?
Execute the command 'SET' without parameters in MS-DOS and see if everything is right.

I hope these ideas help you to realize what is wrong in your script.

 

Ummm I thought i explained that in my post? Yes I have tried it with absolute paths. It ONLY works with absolute paths. My script shows an absolute path....so that is what my problem is.

The script does a FileSelectFolder....

then it checks the directory that the person selected (maybe there is a create folder button styled FileSelectFolder out there that I can use instead of what I have used?)
Anyway when it checks the folder they have selected and it is the first time the person has tried to install the app it will create a new directory for them. This is incase they are installing over a botched install. Which has been a common problem identified by users on the forum with windows registry having a different path to the actual location of their files. It also checks areas of the registry that would also indicate a botched install. Rather than try correct those messed entries, it removes them and the existing files and then prompts the user to re-run the installer again. They can also if they want to ignore what the installer prompts for removal and try to install over their botched install. I have tried many different scenarios where the user "could have installed" and it works perfectly 100% as it should.

I offer first and foremost to remove the existing install as I think this is a much better idea. Anyway it works exactly as intended.

 
So just for example say it is the users first time install, the installer sees nothing in the directory that they have selected and it prompts the user to create a folder/directory. Say if they install in C:Program Files (x86) then it will check there and see that there is no Windows7GifViewer directory and it will create it for them.

Just to clarify, there is no mention of @DesktopDir of @HomePath or anything like that. I shouldn't need to use the set command as you are suggesting....I think you have not read my post or misunderstood what the issue is? 

I just want the executable (once it compiles that is....which it wont at the moment) to include the files when it compiles.

I understand how FileInstall works it just doesn't work for me. Everything about my script works fine otherwise.

The script does exactly what I want.

If the files are located where they are mentioned in the script it installs them to the Windows7GifViewer directory where ever I choose on my PC (even another drive).

The script creates all the correct registry writes to make the application function as it should in the location where ever the user chose. Prior to this the two solutions offered on the forum were to install in C: the other one was C:WindowsGif
 

Both of these were unacceptable for me. So now it will install where the user would prefer. If they are used to Program Files then so be it....they can install there. I could easily make it install in say AppDataRoamingWindows7GifViewer by default but then there is the issue of trying to help any user who gets stuck installing it and them having to turn on hidden files and go digging inside of appdata.....I didn't want that. So its open ended. They choose and that is the place they go look for it when they are unsure if something didn't work.

I cannot for the life of me get the two files (rundll32.exe and shimgvw.dllto bundled up inside of the install exe (compiled script)????

The error I receive is exactly what everyone else always gets when they do it wrong, except for me when I do it correctly I still get the same errors. What I mean by that is that the examples that I have seen offered as solution to n00bs on the forum that can't understand how FileInstall() works.....those "solutions" do NOT work for me. Even the application made by a long standing member here in the AutoIT forums (for these exact reasons) DOES NOT WORK FOR ME. That is why I think there is a bug with FileInstall

 

To answer specifically, I moved the whole folder to my desktop for simplicity cause it was inside my dropbox....even though there is no spaces in my path for dropbox so it should work regardless right? I put it in a subfolder and not next to the script just in case....

- do you get error messages?  Yes. The error is:                        Invalid FileInstall() Function

                                                                                                    E:UsersJamesDesktopWindows7GifViewerFilesshimgvw.dll

- do you get error codes?  Error code? No...there is no error code for FileInstall()

- does your script crash?  Yes, but only if I try to compile it! It runs fine as an Au3. This is typically the issue that n00bs have who do not understand that FileInstall() needs absolute paths.....to which you can see for your self it darn well does have absolute path!!! grrr

- does it compile at all?  No it never compiles....EVER!!!!! No matter what I do it never compiles.

- does it work perfectly, without errors, but the files are not installed?  No, it works perfectly fine. The script 100% works correctly as it should.  IT EVEN INSTALLS THE FILES AS IT SHOULD!! It just refuses to compile the files inside of the script like it should. Note: There should be a single exe file an AutoIT compiled script that contains two files. It should unpack its self and install those files. It doesn't ever compile.

 

what is the return code of FileInstall() ? if there is an error, post a screenshot or something

As mentioned there is no error code as such. Attached are some screenshots for you. Just in case you wanted to see of it compiles with the 2 files in the same directory as the script, I have included a second screen shot for you. 

 

 

Thanks would really appreciate the help, more so I can understand what the F*#% is going on, cause as it stands it pretty much means I cant package up any apps as I would like using only a single AutoIT script....it means I need to use a 3rd party installer and I really don't want to do that. Its extra mess that I shouldn't have to deal with. 

 

James



Users can refer to the pictures attached though

post-79307-0-91598500-1378222649_thumb.p

post-79307-0-02357400-1378222770_thumb.p

Edited by DigitalFacade82

Share this post


Link to post
Share on other sites
DW1

My thoughts:

1) Is your AV getting in the way?

2) Have you tried running SciTE and/or Aut2Exe as admin?

3) Do you get the same results if you move the included dll to a different directory?

Share this post


Link to post
Share on other sites
DigitalFacade82

More of me being a retard...sorry feel free to check out what I was crapping on about

Windows7GifViewer.zipWindows7GifViewer.zipHahah funny you mention that. I have moved the includes folder into E:UsersJamesAutoIT_ProjectsInclude already and placed a symlink back in C:Program Files (x86)AutoIt3Include that points to this location. I did this because I thought that user permissions and writing to this folder is a bit of a pain and is not best IT practice.

As far as I am concerned all static application execution files and libraries are fine to stay in Program Files or Program Files (x86) and all data should (this is anything that is changing regularly with a large number of writes) be located anywhere withing <drive>Users<Username>Somefolder

Just to note I have no issues compiling scripts in general.
 

SciTE and Aut2Exe are both set to run as admin by default.

Some useless information about me  :geek:

My antivirus has not caused any issues to date with anything AutoIT. It never flags any Au3 files nor any compiled Exes from AutoIT. I use Microsoft Security Essentials. I have switched to vetting all files prior to download via VirusTotal. I think that is the safest bet.
Where possible I send the URL to Virus total prior to downloading. My Virus scanner is not set to so severe that way (well MSS only detects with Real Time switched on....there are no "severity" settings as such?), and on top of that I don't find that I need such severe antivirus protection. I never download anything dodgy.....and if I do (I like to reverse engineer viruses for educational purposes so I can better protect myself) I do this in a dedicated Virtual Machine with all of my analysis software contained. I inspect the results of such analysis by mounting the .VHD inside my own custom made WinPE. Nothing is executed on even opened on my production system. So short answer is that is not the issue. 

Thanks for crossing that one off the list though and raising it to attention.

I still think this is a bug in the FileInstall() function it's self. I think it has something to do with where the Users drive is located?

Just for information. I have correctly set up my SSD and conventional HDD combination through Sysprep when installing Windows 7. I have my E: written into the registry for the location of the User profile. 
AND I have created a symlink between C:Users to point to E:Users for any legacy applications where developers have stupidly hardcoded the install location for User data to C:  :rolleyes: 

My thoughts are that FileInstall() is ignoring the defaults? What I mean is that usually I can type anywhere on my system as either C:Users<my user name> and press enter and it will take me there. I can also type E:Users<my user name> and it will take me there also.....as it should do.

However when I attempt to use the FileInstaller Helper posted as the solution by long term member on the forum which is considered 'The fix' to the FileInstall() misunderstandings....guess what? It does not see my C: what so ever? It only sees all content in E:????

If I even move the executable to the root of C: it still gives me no option to choose a C: location for the files to package up to install when compiling?
This suggests that there must be an underlying issue with the FileInstall code surely?

If someone is willing to try for me I will upload my entire package and see if someone can compile it that doesn't have a solid state drive set up or user data location on another drive like I do?

It would be greatly appreciated if someone can test it for me :)

Edit: Attached is the full source. I have edited the install script. 

FileInstall("C:Program Files (x86)Windows7GifViewerrundll32.exe", $path & "Windows7GifViewerrundll32.exe", 1)
FileInstall("C:Program Files (x86)Windows7GifViewershimgvw.dll", $path & "Windows7GifViewershimgvw.dll", 1)
 
Please change C:Program Files (x86)Windows7GifViewerrundll32.exe to the location of where ever you unzip the attached package. It will not work until you do this. 
 
 
 

 

Edited by DigitalFacade82

Share this post


Link to post
Share on other sites
trancexx

This is so very confusing.

I'm not sure ho in the world you don't see this in your code:

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)
                FileInstall(@ScriptDir & "\rundll32.exe", $path & "\Windows7GifViewer\rundll32.exe", 1)
                FileInstall(@ScriptDir & "\shimgvw.dll", $path & "\Windows7GifViewer\shimgvw.dll", 1)
;...
Do you see anything wrong there?

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
DigitalFacade82

Just to be super tidy I have included removal of the pre-existing known locations for files installed with the previous two botched installers

It now checks C: and removes C:rundll32.exe, C:shimgvw.dll, OR C:WindowsGifrundll32.exe and C:WindowsGifshimgvw.dll and removes them, then it removes the Gif directory from C:Windows. Yes I used Rd inside of ComSpec cause DirRemove is not always successful? I think this maybe due to the script changing directories to the location it is trying to delete when it does a DirRemove? Where as ComSpec executes a command prompt window (hidden) to do the removal for the WinAPI? I could be wrong here but never been successful with DirRemove.....DirRemove and FileDelete seem to work well at removing the contents of the Directory but not the directory it's self? Another bug maybe?

#NoTrayIcon
#RequireAdmin

#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 <File.au3>

Opt("WinTitleMatchMode", 2)
SystemCheck()

Func SystemCheck()
    Local $path = FileSelectFolder("Please select install location", "")
    Local $command, $command1, $command2, $Msg1
    ;Detect if another installation exists
    If FileExists('C:\rundll32.exe') Then
    FileDelete('C:\rundll32.exe')
    If FileExists('C:\shimgvw.dll') Then
    FileDelete('C:\shimgvw.dll')
    If FileExists('C:\Windows\Gif\rundll32.exe') Then
    FileDelete('C:\Windows\Gif\rundll32.exe')
    If FileExists('C:\Windows\Gif\shimgvw.dll') Then
    FileDelete('C:\shimgvw.dll')
    If FileExists('C:\Windows\Gif') Then
    Run(@ComSpec & " /c rd C:\Windows\Gif", @SW_HIDE)
    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")
                ;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)
                MsgBox(0, "Existing Installation Removed", "Please re-run the installer to install again")
            Case $Msg1 = 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
                        DirCreate($path & '\Windows7GifViewer')
                        ConsoleWrite("Install" & @CRLF)
                        ;Commence installation
                        FileInstall("E:\InstallFiles\rundll32.exe", $path & "\Windows7GifViewer\rundll32.exe", 1)
                        FileInstall("E:\InstallFiles\shimgvw.dll", $path & "\Windows7GifViewer\shimgvw.dll", 1)
                        ;Note:- This works from an uncompiled script and the source files can be either in the script directory or referenced from somewhere else in this case and works
                        ;For some reason again this likes to only register from the command line?
                        $command1 = 'regsvr32 /s ' & $path & "\Windows7GifViewer\rundll32.exe"
                        $command2 = 'regsvr32 /s ' & $path & "\Windows7GifViewer\shimgvw.dll"
                        Run(@ComSpec & " /c " & $command, $path & "\Windows7GifViewer", @SW_HIDE)
                        Run(@ComSpec & " /c " & $command2, $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', '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', 'MuiVerb', 'REG_SZ', '@shimgvw.dll,-550')
                        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"')
                        ;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")
                        MsgBox(0, "Installation Complete!", "To run double click or open any .Gif file. Run again to Uninstall")
                    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_Gif_Viewer.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')
                               ;NOTE TO SELF DON'T BE RETARDED! IF you are going to be lazy and copy and paste code make sure you change BOTH parts of the code when they are incorrect!
           ConsoleWrite("Install" & @CRLF)
           FileInstall(@ScriptDir & "\rundll32.exe", $path & "\Windows7GifViewer\rundll32.exe", 1)
           FileInstall(@ScriptDir & "\shimgvw.dll", $path & "\Windows7GifViewer\shimgvw.dll", 1)
                $command = 'regsvr32 /s ' & $path & "\Windows7GifViewer\rundll32.exe"
                $command2 = 'regsvr32 /s ' & $path & "\Windows7GifViewer\shimgvw.dll"
                Run(@ComSpec & " /c " & $command, $path & "\Windows7GifViewer", @SW_HIDE)
                Run(@ComSpec & " /c " & $command2, $path & "\Windows7GifViewer", @SW_HIDE)
                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', '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', 'MuiVerb', 'REG_SZ', '@shimgvw.dll,-550')
                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_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers", $path & "\Windows7GifViewer" & "\rundll32.exe", "REG_SZ", "WINXPSP3")
                MsgBox(1, "Installation Complete!", "To run double click or open any .Gif file. Run again to Uninstall")
            EndIf
        EndIf
    EndIf
EndFunc   ;==>SystemCheck

Func Restart()
    Run(@ScriptDir & "\Windows_7_Gif_Viewer.exe")
EndFunc   ;==>Restart
Edited by DigitalFacade82

Share this post


Link to post
Share on other sites
DW1

 

Just to be super tidy I have included removal of the pre-existing known locations for files installed with the previous two botched installers

It now checks C: and removes C:rundll32.exe, C:shimgvw.dll, OR C:WindowsGifrundll32.exe and C:WindowsGifshimgvw.dll and removes them, then it removes the Gif directory from C:Windows. Yes I used Rd inside of ComSpec cause DirRemove is not always successful? I think this maybe due to the script changing directories to the location it is trying to delete when it does a DirRemove? Where as ComSpec executes a command prompt window (hidden) to do the removal for the WinAPI? I could be wrong here but never been successful with DirRemove.....DirRemove and FileDelete seem to work well at removing the contents of the Directory but not the directory it's self? Another bug maybe?

#NoTrayIcon
#RequireAdmin

#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 <File.au3>

Opt("WinTitleMatchMode", 2)
SystemCheck()

Func SystemCheck()
    Local $path = FileSelectFolder("Please select install location", "")
    Local $command, $command1, $command2, $Msg1
    ;Detect if another installation exists
    If FileExists('C:\rundll32.exe') Then
    FileDelete('C:\rundll32.exe')
    If FileExists('C:\shimgvw.dll') Then
    FileDelete('C:\shimgvw.dll')
    If FileExists('C:\Windows\Gif\rundll32.exe') Then
    FileDelete('C:\Windows\Gif\rundll32.exe')
    If FileExists('C:\Windows\Gif\shimgvw.dll') Then
    FileDelete('C:\shimgvw.dll')
    If FileExists('C:\Windows\Gif') Then
    Run(@ComSpec & " /c rd C:\Windows\Gif", @SW_HIDE)
    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")
                ;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)
                MsgBox(0, "Existing Installation Removed", "Please re-run the installer to install again")
            Case $Msg1 = 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
                        DirCreate($path & '\Windows7GifViewer')
                        ConsoleWrite("Install" & @CRLF)
                        ;Commence installation
                        FileInstall("E:\InstallFiles\rundll32.exe", $path & "\Windows7GifViewer\rundll32.exe", 1)
                        FileInstall("E:\InstallFiles\shimgvw.dll", $path & "\Windows7GifViewer\shimgvw.dll", 1)
                        ;Note:- This works from an uncompiled script and the source files can be either in the script directory or referenced from somewhere else in this case and works
                        ;For some reason again this likes to only register from the command line?
                        $command1 = 'regsvr32 /s ' & $path & "\Windows7GifViewer\rundll32.exe"
                        $command2 = 'regsvr32 /s ' & $path & "\Windows7GifViewer\shimgvw.dll"
                        Run(@ComSpec & " /c " & $command, $path & "\Windows7GifViewer", @SW_HIDE)
                        Run(@ComSpec & " /c " & $command2, $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', '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', 'MuiVerb', 'REG_SZ', '@shimgvw.dll,-550')
                        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"')
                        ;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")
                        MsgBox(0, "Installation Complete!", "To run double click or open any .Gif file. Run again to Uninstall")
                    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_Gif_Viewer.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)
                FileInstall(@ScriptDir & "\rundll32.exe", $path & "\Windows7GifViewer\rundll32.exe", 1)
                FileInstall(@ScriptDir & "\shimgvw.dll", $path & "\Windows7GifViewer\shimgvw.dll", 1)
                $command = 'regsvr32 /s ' & $path & "\Windows7GifViewer\rundll32.exe"
                $command2 = 'regsvr32 /s ' & $path & "\Windows7GifViewer\shimgvw.dll"
                Run(@ComSpec & " /c " & $command, $path & "\Windows7GifViewer", @SW_HIDE)
                Run(@ComSpec & " /c " & $command2, $path & "\Windows7GifViewer", @SW_HIDE)
                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', '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', 'MuiVerb', 'REG_SZ', '@shimgvw.dll,-550')
                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_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers", $path & "\Windows7GifViewer" & "\rundll32.exe", "REG_SZ", "WINXPSP3")
                MsgBox(1, "Installation Complete!", "To run double click or open any .Gif file. Run again to Uninstall")
            EndIf
        EndIf
    EndIf
EndFunc   ;==>SystemCheck

Func Restart()
    Run(@ScriptDir & "\Windows_7_Gif_Viewer.exe")
EndFunc   ;==>Restart

You still have the FileInstall() lines that are not going to work.

The source path of the file to compile. This must be a literal string; it cannot be a variable or the result of a function call. It can be a relative path (using . or .. in the path) to the source file (.au3).

Share this post


Link to post
Share on other sites
DigitalFacade82

This is so very confusing.

I'm not sure ho in the world you don't see this in your code:

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)
                FileInstall(@ScriptDir & "\rundll32.exe", $path & "\Windows7GifViewer\rundll32.exe", 1)
                FileInstall(@ScriptDir & "\shimgvw.dll", $path & "\Windows7GifViewer\shimgvw.dll", 1)
;...
Do you see anything wrong there?

 

 

Sorry I still learning.....and I maybe be very blindly stupid  :blink: 

I have read many of your posts and I know that you know LOTS. Please enlighten me? 

If it is the ConsoleWrite part....that was part of the previous installer that member Corgano had written?? I am not sure why it is in there but I didn't change that part. If it's something to do with checking the path and creating the directory then that is all me and my fault  :>

Share this post


Link to post
Share on other sites
DigitalFacade82

oH CRAP! I see it now!

Its the second part I copied and pasted from above *prior* to understanding the FileInstall Function!

Damn it

I am stupid

Share this post


Link to post
Share on other sites
DigitalFacade82

It compiles. I am retarded. Sorry guys. Thanks for all your help. I will crawl away in my little hole now  :>  :>

Edited by DigitalFacade82

Share this post


Link to post
Share on other sites
DigitalFacade82

Ok, well I am back.....but I am posting in here just in case other forum members have similar issues to myself and they happen to use the search function (like I initially did when I had the problem in the first place). Granted my issue was due to stupidity but of a different kind.

I initally responded this in a PM but it probably better off in the forum where it can be shared.

I have a much simpler idea that works with the FileInstall function.

What lead me to this solution...

It is kind of required to be used when you are considering sharing code across repos like Git and/or SVN etc, just for the sheer fact that you can't guarantee that users will synch their repo to the exact identical path as your self (actually I can guarantee that most users WON'T have the same path as each other especially if they project is somewhere like their local home directory lol).....so this would have meant dramas at every compile time for every person involved in a project. Posting what I created on the sevenforums actually got the attention of the previous developer (hence he wanted to work further on this together via Github)....and as you can see the dilemma

I figured that if at compile time I bring the Environment variable forward to the script directory then that is the base line to read from and will cause no confusions to the file install function. I knew there had to be something similar to doing cd "~dp0" or some autoIT equivalent, so I went with the following:

EnvSet("path", EnvGet("path") & ";" & @ScriptDir)

;note this line here is important ^^^^

FileInstall("rundll32.exe", $path & "\Windows7GifViewer\rundll32.exe", 1)
FileInstall("shimgvw.dll", $path & "\Windows7GifViewer\shimgvw.dll", 1)

This allows the users to have the resources placed inside the same directory as the script and compile and not need to know any paths   :thumbsup:  That means I can push to any repo or put the code anywhere on any system with AutoIT and it will compile no problems.

Why this is not in the Help file for simplicity is beyond me? Should I reply back to my own thread for others to search or ask that the Help be upgraded to at least have this as an example? I mean Forum members have gone to the troubles of creating entire applications dedicated to this often asked problem by new comers.....I am sure a much simpler way from the help section couldn't hurt? Wish I had done it before making a goof of myself in my thread   :>

Edited by DigitalFacade82

Share this post


Link to post
Share on other sites
trancexx

How is that different than simple and obvious:

FileInstall("rundll32.exe", @ScriptDir & "\Windows7GifViewer\rundll32.exe", 1)
Or even better:

FileInstall(".\rundll32.exe", @ScriptDir & "\Windows7GifViewer\rundll32.exe", 1)
Edited by trancexx

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
MHz

How has EnvSet got anything to do with FileInstall at compile time? EnvSet is a runtime function.

Share this post


Link to post
Share on other sites
DigitalFacade82

How is that different than simple and obvious:

FileInstall("rundll32.exe", @ScriptDir & "\Windows7GifViewer\rundll32.exe", 1)
Or even better:

FileInstall(".\rundll32.exe", @ScriptDir & "\Windows7GifViewer\rundll32.exe", 1)

Because the above will never work that's why.

You cannot have relative paths in the FileInstall function simple as that. I knew this at the beginning however I was stupid and forgot I duplicated the code so I didn't change one part and so always got the FileInstall error as mentioned above  :thumbsdown: 

 

Neither of those two that you have posted will work because @ScriptDir. $path is a known quantifiable path location and always was, it's just that the $path is never known until the user selects where they would like to install the application, because that was an unknown (user selected at install time - not compile time) and could end up in any number of places. However you have missed the point and the issue entirely. The issue was never the install location but the compile location hence why "rundll32.exe" in your particular script will never work cause the FileInstall function always reverts back to ComSpec AFAIK? Just like you would in a batch file by expanding your environment to resolve the script location with something like with cd "%~dp0"....so too do you need do the same with Au3 script.

FileInstall cannot have relative paths in the location of the resource. What is @scriptdir in relation to the file to be compiled? absolutely nothing shrug.gif . The FileInstall function doesn't know until it resolves location of the resource (that it is intending to compile) to a known location (hence why full path is needed). If you make the environment come forward to the script execution location then that is like going from C:WindowsSystem32  -> batch file location on some other drive.

Until you bring the "environment" to the script directory FileInstall has no reference. EnvSet("path", EnvGet("path") & ";" & @ScriptDir) This says to the script find where you are in relation to the current environment, then move the environment to your location and make where you are zero or the base location. The path then IS "." and "." is known. 

There is a possibility that your first line above *may?* (and this is questionable?) work if you went and dumped the exe and the dll inside of C:WindowsSystem32 and tried to compile. But that is stupid to have to do, and I want to make the script "portable" for the fact of being able to share via repo synch. That is the exact reason why I responded to my own thread, so that others can "SHARE" their scripts in multi-editor environments like SVN and GitHub.

trancexx,  have a go at trying to compile my script using your code (I have provided my sources in a post above) and see what happens? And then do what I am saying should be done and try it again?  ;)  :) 

In addition to this (and I am yet to look at the code that members have used in their special FileInstall applications made to address this issue?) is that the au3 script is only resolving to the drive letter just like using %CD% would from within a batch script. This IS the reason why I was having issues using their Applications in the first place. I am using a SSD for my O/S drive and conventional HDD for my User drive.

What I mean is that their FileInstall Helper applications never resolved the Environment properly either. 

 

 

%cd% is available either to a batch file or at the command prompt and expands to the drive letter and path of the current directory (which can change e.g. by using the CD command) 

%~dp0 is only available within a batch file (not within the command prompt) and expands to the drive letter AND path in which that batch file is located (which cannot change). It is obtained from %0 which is the batch file's name.

 

So what I am getting at here is that I strongly suggest people who are either A) Using modern SSD architecture (where scripts are compiled across multiple drives) to consider doing as I have done with EnvSet("path", EnvGet("path") & ";" & @ScriptDir)  OR B) if they are sharing across multiple users AND/OR any combinations of multiple drives. Alternative to that they can go digging through the code of the FileInstallerHelper App and change it accordingly.....but why bother when a simple fix that is 1 line that I have posted solves all the problems that people have been having.

Question though now....Does AutoIT adhere properly to the same constraints as ComSpec/Command prompt and normal Windows Environment variables and require something like "END LOCAL" at the end of the script?? It is possibly one of the most forgotten things in batch scripting and personally I have yet to have it bite me for not doing it, but if it IS important in this case then I think it should be discussed. 

 

Share this post


Link to post
Share on other sites
MHz

But you can have relative paths in FileInstall. I consider you may need to do some testing to prove this as correct. The examples that trancexx has given are correct.

Share this post


Link to post
Share on other sites
DigitalFacade82

But you can have relative paths in FileInstall. I consider you may need to do some testing to prove this as correct. The examples that trancexx has given are correct.

That maybe so, but I am identifying it here because what I am saying is that trancexx's examples don't work. The example that I have give does however? I am not saying I am right either, I am just trying to discuss why it works for me and what might be the reasoning behind this?

I do understand that trancexx is a wealth of knowledge and I am will admit that I am only new to here, so I am all ears when it comes to AutoIT, especially trancexx and also your self likewise. I am not being a smarty pants.

Try the code for your self. I will upload my latest of the script and if you can tell me why or how I would love to learn and know how if you guys can come up with an explanation? Maybe things could be different on your system? Who knows? We can't prove or deny that unless another person tries it and then gives some feedback and input :-)

The reason I posted in here is simply because the solution I have to offer is much much more simpler than the alternative solutions offered on the forums (naturally this is a 'tricky' topic for n00bs like myself and from what I can tell many others that share frustrations of FileInstall?).

What I am saying isn't theory. The script compiles one way and doesn't another. I used my own understanding and logic to try something that I thought would work.

 

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
Sign in to follow this  

×