Jump to content

ANNOUNCE: "Generalized" install.cmd


daddydave

Recommended Posts

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:

addonfolder

Drop install.cmd here

addonfolder\__pf\appname

Put appname's files here to be copied to %ProgramFiles%\appname during installation.

addonfolder\__sp\appname

Put 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. USERS

You 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?

---------------------------------------

Credits

Thanks to everyone on the MSFN forums who responded when I had questions as I was writing this

To 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 daddydave
REM See MSFN forum for instructions
REM [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\Programs
REM ****************************************************

setlocal enableextensions

xcopy __pf\* "%ProgramFiles%" /I /C /Q /Y /H /E
xcopy __sp\* "%ALLUSERSPROFILE%\%PROGRAMS%" /I /C /Q /Y /H /E

for /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 by daddydave
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
  • Recently Browsing   0 members

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