Showing posts with label what is active setup. Show all posts
Showing posts with label what is active setup. Show all posts

Friday, 15 June 2012

Increment ActiveSetup Version - VBScript


'This script will create the Active setup if not present on the system, otherwise it will increment the version of the active setup 


' Need to replace the "Any that you want to run" with the exact path of the EXE/MSI/Script which has to run
' Replace the "<NameOfActiveSetup>" with the related unique application name




Option Explicit
On Error Resume Next
Dim WshShell ,PrgFiles,KeyValue
Set WshShell=CreateObject("WScript.Shell")




KeyValue=WshShell.RegRead("HKLM\SOFTWARE\Microsoft\Active Setup\Installed Components\<NameOfActiveSetup>\Version")


WshShell.RegWrite "HKLM\SOFTWARE\Microsoft\Active Setup\Installed Components\<NameOfActiveSetup>\StubPath", "Any that you want to run"


'Err.Clear


If  Err.Number=0 Then
     
WshShell.RegWrite "HKLM\SOFTWARE\Microsoft\Active Setup\Installed Components\<NameOfActiveSetup>\Version",KeyValue+1,"REG_SZ"   

Else

WshShell.RegWrite "HKLM\SOFTWARE\Microsoft\Active Setup\Installed Components\<NameOfActiveSetup>\Version","1","REG_SZ"

End If




Set WshShell = Nothing
Set PrgFiles = Nothing


WScript.Quit

Friday, 8 June 2012

Which one will execute first is Run or Active setup?


The answer is “Active setup”.

Because,  Activesetup is using to configure the userprofile settings if no entry points exists in the package and this will be running only once for a specific user.
Where as RUN key will execute everytime when user login the machine.
These settings are configured with different sequence , in order to speedup to get access to windows desktop\user level settings.

Sunday, 11 March 2012

What is Active Setup


Active setup is a process that runs automatically when a user logs in.
 
Registry keys at 
 
HKLM\Software\Microsoft\Active Setup\Installed Components\%APPNAME% 
 
and 
 
HKCU\Software\Microsoft\Active Setup\Installed Components\%APPNAME% 
 
are compared, and if the HKCU registry entries don't exist, or the version number of HKCU is less than HKLM, then the specified application is executed for the current user. 
 
If your application requires installation of components such as files or registry keys on a per-user basis, but your application has no advertised entry points or other triggers to initiate the installation process, then Active Setup is the solution. To implement Active Setup, 
populate the following registry key with two ( REG_SZ ) values: 
 
KEY: 
HKLM\SOFTWARE\Microsoft\Active Setup\Installed Components\%APPNAME% - where %APPNAME% is an arbitrary string which can be the application name, or its product code GUID if using an MSI. (As long as it is unique on that workstation!)
 
VALUE1: StubPath=<full local path>\YourActiveSetup.exe 
 
VALUE2: Version=1 
 
When each new user logs on, the operating system compares Active Setup keys between HKLM and HKCU, and runs the nominated executable if the HKCU entry is missing or the version in HKCU is less than HKLM.  So if you ever need to update the ActiveSetup executable, just install
a new version, and increment the Version registry key (VALUE2 above) in HKLM. Next time the user logs on, the active setup will run again for that user. 
 
To force a repair using the existing MSI where a separate Active Setup EXE is not required, you can do it this way: 
Create the following key structure under HKEY_LOCAL_MACHINE hive:
HKEY_LOCAL_MACHINE\Software\Microsoft\ActiveSetup\InstalledComponents\[ProductCode]
Under this registry key, create a <new string value> such as:
 
"StubPath"="msiexec /fous {ProductCode} /qb"

Run, Run Once Registry Keys


Run keys cause programs to automatically run each time that a user logs on. The Windows registry includes the following four Run keys:


HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce
 


Each of these keys has a series of values. The values allow multiple entries to exist without overwriting one another. The data value for a value is a command line.


There are some special considerations for the third and fourth keys in the list, the RunOnce keys:
1.     By default, Run keys are ignored when the computer starts in Safe mode. Under the RunOnce keys, you can prefix a value name with an asterisk (*) to force the associated program to run even in Safe mode.
2.     You can prefix a RunOnce value name with an exclamation point (!) to defer deletion of the value until after the command runs.
3.     Without the exclamation point prefix, a RunOnce value is deleted before the command runs. As a result, if a RunOnce operation does not run properly, the associated program is not asked to run the next time you start the computer.

If more than one program is registered under any particular key, the order in which those programs are run is indeterminate. A program run from any of these keys should not write to the key during its execution. Doing so will interfere with the execution of other programs registered under the key. Furthermore, applications should use the RunOnce keys only for transient conditions (such as to complete application setup); an application must not continually re-create entries under RunOnce. Doing so will interfere with Windows Setup.

Monday, 29 August 2011

Active Setup Registry Keys

Following Registries are to be included in package to load User settings(either registries/files) so that by the time User
logs in his current user settings will be available on the machine.

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Active Setup\Installed Components\[ProductCode]]
"StubPath"="msiexec /fup {9A346205-EA92-4406-B1AB-50379DA3F057} /qn"
"Version"="1,0"

Sunday, 28 August 2011

What is Active Setup

Active setup provides a solution when the aim is to deliver user based components when no advertised entry points exist in an MSI package.


Most packages will contain some kind on entry point; commonly an advertised shortcut. When launching this kind of shortcut Windows Installer will check the keypath of the component the shortcut belongs to and verifies that the component is installed. If it is found to be missing Windows Install will kick off a repair.


This provides a great solution for installing current user data when the package is not installed in the user context. It is also a very good reason why you should never mix machine and user data in the same feature.

On logon the following registry keys are compared:


HKLM\Software\Microsoft\Active Setup\Installed Components\<UID>
HKCU\Software\Microsoft\Active Setup\Installed Components\<UID>


<UID> has to unique; it is good practise to use a GUID.


If the HKCU key is not found the contents of the string value StubPath is executed. The HKLM key is then copied to HKCU.


The executable in StubPath can be anything (a VBS script, a regsvr32.exe call, etc), but our aim, in this example, is to deliver missing current user data from a previously installed MSI. To do this we need to force the package to repair so Msiexec.exe will be used:


Msiexec.exe /fpu /qn


/f - Repair
/p - only if file is missing
/u - all required user-specific registry entries
If you choose to, the entire installation can be repaired:



Msiexec.exe /fomus /qn


[HKLM\SOFTWARE\Microsoft\Active Setup\Installed Components\{44CCA842-CC51-11CF-AAFA-00AA00B6015B}]
"Version"="1"
"StubPath"="Msiexec.exe /fpu {44CCA842-CC51-11CF-AAFA-00AA00B6015B}"


Where a version is included; StubPath will only execute if the version of HKCU is less than the version of HKLM.


When a new user logs on Windows will find the HKCU active setup key missing, run Msiexec.exe with the repair arguments from StubPath and copy the HKLM key to HKCU. Next time this user logs in the repair won't run as the key already exists in HKCU.