daddydave Posted January 30, 2007 Share Posted January 30, 2007 (edited) Ever wanted to create an application addon for a program that didn't really need a setup program, but felt it should have a proper folder in %ProgramFiles%, some shortcuts in the start menu, and a rudimentary but functional entry in the Add/Remove Programs applet, using a generalized install.cmd that rarely has to be edited? No? OK, I'll go away then. That's what I wanted. So if you are me, here is how you work the Universal install.cmd. (Knowledge of how to create addons using Addon Maker for nLite or another method is assumed.) Create an empty folder and put install.cmd in it. Give that folder two subfolders called __pf and __sp (double underscores). __pf contains folders that are to be copied to Program Files, and __sp contains folders of Start Menu shortcuts that are to be copied to the Start Menu\Programs for all users.Each folder directly under __pf corresponds to an entry to be added to the Add/Remove Programs applet. The folder names under __sp must match up to the folder names under __pf. To summarize the folder structure: addonfolderDrop install.cmd here addonfolder\__pf\appnamePut appname's files here to be copied to %ProgramFiles%\appname during installation. addonfolder\__sp\appnamePut appname's shortcuts here to be copied to Start Menu\Programs\appname during installation. This is the not-so-fun part. I create them manually for now. Unfortunately unless %ProgramFiles%\appname\appfile actually exists, Windows will not let you create a shortcut to it. So to create the shortcuts, I have been copying my app files to %ProgramFiles% so I can create the shortcuts. Having to create the shortcuts for this folder manually at design time will be a deal breaker for some people, and I am looking into ways to make this easier in the future. Try to make the shortcuts point a path beginning with "%ProgramFiles%" rather than "C:\Program Files".IMPORTANT: Make sure you use the same appname in __pf as you do in __sm. Once I had the basic functionality working, it was simple to add support for multiple apps. So you can do the same for appname2, appname3, etc. in the same application addon. The appname from each top level folder in __pf is used in the Add/Remove Programs applet, and the uninstall worked during testing on a Windows 2000 box (be aware that a cmd window is briefly visible during uninstall). Next step is to run carnificina's excellent Addon Maker for nLite (or some other method, although this is my preference), choosing install.cmd as your setup program and create your addon. These addons work fine with HFSLIP as well as nLite. Addon Maker will automatically cause the addon to hide the cmd window during installation.---------------------------------------IMPORTANT NOTE FOR NON-U.S. USERSYou will have to modify this line in install.cmd so that it points to the correct folder name. Use the same syntax as below:set PROGRAMS=Start Menu\Programs Example (French): set PROGRAMS=Menu Démarrer\Programmes I'm not sure about the U.K. Is it Start Menu\Programs or Start Menu\Programmes? --------------------------------------- CreditsThanks to everyone on the MSFN forums who responded when I had questions as I was writing thisTo get the code take the following and paste it into a file install.cmd REM Generalized install.cmd for application addons (HFSLIP, nLite, RyanVM's, etc.)REM by daddydaveREM See MSFN forum for instructionsREM [url="http://www.msfn.org/board/index.php?showtopic=91889&st=0#entry619670"]http://www.msfn.org/board/index.php?showto...t=0#entry619670[/url]REM ****************************************************: Non-U.S. Users must change this line:set PROGRAMS=Start Menu\ProgramsREM ****************************************************setlocal enableextensionsxcopy __pf\* "%ProgramFiles%" /I /C /Q /Y /H /Excopy __sp\* "%ALLUSERSPROFILE%\%PROGRAMS%" /I /C /Q /Y /H /Efor /D %%Z in (__pf\*) do ( >%TMP%\__install-%%~nZ.reg echo Windows Registry Editor Version 5.00 >>%TMP%\__install-%%~nZ.reg echo. >>%TMP%\__install-%%~nZ.reg echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\%%~nZ] >>%TMP%\__install-%%~nZ.reg echo "DisplayName"="%%~nZ" >>%TMP%\__install-%%~nZ.reg echo "UninstallString"="cmd /c >\"%%TMP%%\\__uninstall-%%~nZ.reg\" echo Windows Registry Editor Version 5.00&>>\"%%TMP%%\\__uninstall-%%~nZ.reg\" echo.&>>\"%%TMP%%\\__uninstall-%%~nZ.reg\" echo [-HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\%%~nZ]&>>\"%%TMP%%\\__uninstall-%%~nZ.reg\" echo.&rd /S /Q \"%%ALLUSERSPROFILE%%\\Start Menu\\Programs\\%%~nZ\"&rd /S /Q \"%%ProgramFiles%%\\%%~nZ\"&\"%%SystemRoot%%\\regedit\" /s \"%%TMP%%\\__uninstall-%%~nZ.reg\"" >>%TMP%\__install-%%~nZ.reg echo. "%systemroot%\regedit" /s "%TMP%\__install-%%~nZ.reg") Edited January 30, 2007 by daddydave Link to comment Share on other sites More sharing options...
iCEhOT Posted January 31, 2007 Share Posted January 31, 2007 Ooo very nice, just the other day I was thinking about something along these lines, then I see this post! Brilliant script! Link to comment Share on other sites More sharing options...
daddydave Posted January 31, 2007 Author Share Posted January 31, 2007 (edited) Ooo very nice, just the other day I was thinking about something along these lines, then I see this post! Brilliant script! Thanks! Edited January 31, 2007 by daddydave 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