Jump to content

installer and uninstaller for a folder


keyser
 Share

Recommended Posts

Hello,

First thanks to BigDod and JdeB for their help in support forum

Excuse for my english because i'm franch guy :whistle:

I have made this two script files because i have some programs installed in my usb card and this program run directly from the key usb without install,

This is cool but i want the choice to install it on hard disk

First file : install.exe

Make a folder name as the source in c:\program files\

Then a shorcut on desktop

And In startmenu

;Récupération du nom du répertoire courant
$CurDir = StringTrimLeft(@ScriptDir,StringInStr(@ScriptDir,"\",0,-1))

;Création du répertoire dans program files
DirCreate(@ProgramFilesDir & "\" & $CurDir & "\")

;Copie des fichiers
DirCopy(@WorkingDir, @ProgramFilesDir & "\" & $CurDir & "\", 1)

; Création du raccourci bureau
; Type : FileCreateShortcut ( "file", "lnk" [, "workdir" [, "args" [, "desc" [, "icon" [, "hotkey" [, icon number [, state]]]]]]] )
FileCreateShortcut(@ProgramFilesDir & "\" & $CurDir & "\" & $CurDir & ".exe",@DesktopDir & "\" & $CurDir & ".lnk",@ProgramFilesDir & "\" & $CurDir & "\")

;Création du Menu démarrer
DirCreate(@StartMenuCommonDir & "\programmes\" & $CurDir & "\")
FileCreateShortcut(@ProgramFilesDir & "\" & $CurDir & "\" & $CurDir & ".exe",@StartMenuCommonDir & "\programmes\" & $CurDir & "\" & $CurDir & ".lnk",@ProgramFilesDir & "\" & $CurDir & "\")
FileCreateShortcut(@ProgramFilesDir & "\" & $CurDir & "\uninstall.exe",@StartMenuCommonDir & "\programmes\" & $CurDir & "\uninstall.lnk",@ProgramFilesDir & "\" & $CurDir & "\")

Second file : uninstall.exe

Delete all files, shortcut and folders

;Récupération du nom du répertoire courant
$CurDir = StringTrimLeft(@ScriptDir,StringInStr(@ScriptDir,"\",0,-1))

Func _SelfDelete()
    Local $sCmdFile
    FileDelete(@TempDir & "\Scratch.bat")
    $sCmdFile = ':loop' & @CRLF _
            & 'del "' & @ScriptFullPath & '"' & @CRLF _
            & 'cd ' & @ProgramFilesDir & ''  & @CRLF _
            & 'rd ' & $CurDir & '' & @CRLF _
            & 'if exist "' & @ScriptFullPath & '" goto loop' & @CRLF _
            & 'del ' & @TempDir & '\Scratch.bat' 
    FileWrite(@TempDir & "\Scratch.bat", $sCmdFile)
    Run(@TempDir & "\Scratch.bat", @TempDir, @SW_HIDE)
EndFunc; SelfDelete


;Supression du répertoire dans le menu démarrer
DirRemove(@StartMenuCommonDir & "\programmes\" & $CurDir & "\", 1)
;Supression du raccourci sur le bureau
FileDelete(@DesktopDir & "\" & $CurDir & ".lnk")
;Supression du fichier de désinstallation
DirRemove(@ProgramFilesDir & "\" & $CurDir & "\")
_SelfDelete()

All suggests are welcome

And i hope this script can help somebody

Bye

keyser

Bug : the sub folders are not delete during uninstall

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

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