How to run procedures interactively and/or under the context of the logged-on user

certero logo_cropped_png-01 1.png

Nowadays, there is an increasing amount of software that can be installed by users without administrative rights - think Google Chrome or GoToMeeting. Their setup routines differ slightly in that they may offer an option during installation (Install for 'Everyone' or 'Just me') and are generally configured to copy files and registry settings to the user's profile.

In previous versions of the platform, procedures would run silently under the context of an administrative account (device-based installations) which prevented the distribution of user-based software. In version 8 onwards, procedures can now be created so they run under the context of the logged-on user.

Procedures can also be configured to run 'Interactively' which allows any on-screen prompts or progress bars to be visible to the end user - useful if distributing packages created using the PowerShell App Deployment Toolkit .

Creating a procedure

  • Navigate to Distribution > Packages and create a new package (or open an existing one).

  • Select the Procedures property group and click [Add New].

  • Enter a Name for the procedure .

  • Enter values in the Command and Parameters fields, substituting hard-coded paths with environment variables (see below).

  • In the Execution Context field, choose Run with administrative rights (device-based)' or 'Run as the active user (user-based)'.

  • To allow the user to interact with the procedure, tick Allow User Interaction .

Environment Variables

When creating procedures you should always use environment variables when referring to folders on the source/target filesystem. Using environment variables caters for any variances on target computers.

Environment Variable

Default Path

%PKGDIR%

The package source directory (UNC Path)

%ALLUSERSPROFILE%

C:\ProgramData
Windows Vista and above
C:\Documents and Settings\All Users
Wind ows XP/2003

%APPDATA%

C:\Users\< Username> \AppData\Roaming
Windows Vista and above
C:\Documents and Settings\<Username>\Application Data
Windows XP/2003

%COMMONPROGRAMFILES%

C:\Program Files\Common Files

%COMMONPROGRAMFILES(x86)%

C:\Program Files (x86)\Common Files
64-bit Windows only

%COMSPEC%

C:\Windows\System32\cmd.exe

%HOMEDRIVE%

C:

%HOMEPATH%

C:\Users\< Username>
Windows Vista and above
C:\Documents and Settings\<Username>
Windows XP/2003

%LOCALAPPDATA%
NOTE: Not available on Windows XP/2003

C:\Users\< Username> \AppData\Local
Windows Vista and above

%PROGRAMDATA%
NOTE: Not available on Windows XP/2003

C:\ProgramData

%PROGRAMFILES%

C:\Program Files

%PROGRAMFILES(X86)%

C:\Program Files (x86)
64-bit Windows only

%PUBLIC%
NOTE: Not available on Windows XP/2003

C:\Users\Public

%SystemDrive%

C:

%SystemRoot%

C:\Windows

%TEMP% and %TMP%

C:\Users\< Username> \AppData\Local\Temp
Windows Vista and above
C:\Documents and Settings\<Username>\Local Settings\Temp
Windows XP/2003

%USERPROFILE%

C:\Users\< Username>
Windows Vista and above
C:\Documents and Settings\<Username>
Windows XP/2003

%WINDIR%

C:\Windows

Viewing the progress of Active Jobs

With the introduction of user-based installations, it is possible that a procedure may be run many times on the same computer. An example would be a job configured with an 'Infinite' duration that executes a 'user-based' procedure. In this scenario, the job will be executed on a target computer whenever a new user logs on, meaning the number of times the job has 'Started' would exceed the number of 'Targeted' computers.

In this regard, there are now separate drill-down datagrids behind the numbers shown in the Active Jobs datagrid. Clicking the Targeted figure will show all computers that have been targeted with the distribution job. New links behind the Started , Completed and Errors figures now show the associated records for each status.