We recently announced the release of our new free Job Execution Tool (JET). If you haven’t had chance to read the announcement yet you can find it here. In this post, I’m going to detail one of the various use cases for JETCMD. This should give you an idea why we developed it in the first place and how powerful it can be.
My use case is going to focus around using JETCMD in conjunction with RES Workspace Manager to invoke a RES Automation Manager job at logoff time. The purposes of this job is to delete the locally cached user’s profile from the machine which the user has just logged off from. With the constant debate raging on whether we should be using mandatory or local (temporary) profiles, we now have a way of deleting local profiles at log off without fudging HKLM settings in the registry (perhaps another blog post?!). Regardless of how or why we should or shouldn’t be doing this, your immediate reaction at this point might be that RES Workspace Manager already integrates with RES Automation Manager! You would be correct, however we have the following restrictions:
- The integration only allows job scheduling at user login or when launching a managed application; not at logoff ;
- Run Books can’t be invoked – only Projects and Modules;
- You cannot dynamically pass job parameters at runtime, i.e. they are embedded into the Automation Task in RES Workspace Manager.
So how can JETCMD help us? As you’ve probably guessed JETCMD will allow us to both invoke the appropriate RES Automation Manager job at log off and pass the required parameter(s) to delete the relevant profile. The following are the outline steps involved to accomplish this task:
- Create a Module, Project or Run Book in the RES Automation Manager console that will be invoked by JETCMD (making note of the job GUID);
- As JETCMD is part of the free Virtual Engine Toolkit (VET) you’ll need to download from here and install it;
- Add the JETCMD.exe as a “Custom Resource” within RES Workspace Manager. Note: JETCMD.EXE can found in the “%ProgramFiles%\Virtual Engine\JETCMD” or “%ProgramFiles(x86)%\Virtual Engine\JETCMD”, depending whether it was installed on a 32 or 64-bit system;
- Optionally create “Environment Variables” within RES Workspace Manager, which will hold various command line parameters to pass to JETCMD such as TYPE, JOBGUID, USER and PASSWORD. Using this method makes the task you create in RES Workspace Manager extremely powerful and flexible;
- Create the “Execute Command” in RES Workspace Manager that runs JETCMD at logoff. Ultimately this will invoke and schedule the target RES Automation Manager job.
Now lets cover each step in slightly more detail:
STEP 1
I’m not going to cover how you create a Module, Project or Run Book in the RES Automation Manager console in detail. Rather, I am assuming that you have already created one that you would like to be invoked by JETCMD (and have noted down the relevant job GUID!). For the sake of my use case, I’m using a great tool called DelProf2 from Helge Klein (@HelgeKlein) within a RES Automation Manager module. I’ve used the following “Command (Execute)” task.
What you see above might look a little cryptic so I’ll briefly explain:
- The $Workspace{E2EBA027-FA6B-42AB-9358-C7656E99822E} reference is just a resource link that points to the DELPROF2.EXE that has been added as a resource within the RES Automation Manager console. When the RES Automation Manager task executes it will download the executable and run it;
- The /U switch will be passed to DELPROF2 and signifies that we would like it to run unattended, i.e. with no confirmation;
- To only delete a particular user profile, the /id switch is used to include only profile directories whose name matches this pattern;
- Used in conjunction with the /id switch, the $[UserName] is the RES Automation Manager parameter used to hold the user’s name of the profile I wish to delete (refer to JET_PARAMNAME in Step 5 for more details).
STEP 2
Nothing really to explain here other than download and install VET on your machine – simples! .
STEP 3
Before we carry on with this step lets quickly describe what a “Custom Resource” is. This is an abstract from the RES Workspace Manager Administration Guide:
To import JETCMD as a custom resource, just follow these steps:
- In the RES Workspace Manager console, click on “Administration” in the navigation pane;
- Click on the “Custom Resources” node in the same left hand pane;
- Right click in the right hand pane, select “New” and browse to the location of the JETCMD.exe;
- The JETCMD.exe should now appear as a “Custom Resource” in the RES Workspace Manager console as shown below:
STEP 4
Now while I did say this step was optional, I would highly recommend using “Environment Variables” to hold the parameters that JETCMD will use. This allows more visibility of these values and the potential to change them dynamically depending in the ACL’s used behind the “Environment Variables“. For example, utilising environment variables will allow you change the target RES Automation Manager job based on location or security group without having to create additional tasks!
- In the RES Workspace Manager console, click on “Composition” in the navigation pane;
- Click on the “Environment Variables” node in the same left hand pane;
- Right click in the right hand pane, select “New”;
- Give the “Environment Variable” a suitable Name, Administrative Note and Value and change the ACLs etc. accordingly. In my instance I’ll accept the defaults;
- I’m going to create 6 “Environment Variables” to make managing my “Execute Command” as simple and flexible as possible, as you can see below;
- JET_TYPE = RES Automation Job type to invoke i.e. Module, Project or RunBook;
- JET_JOBGUID = The Module, Project or Run Book GUID that can be found in RES Automation Manager console;
- JET_RESAMUSER = The RES Automation Manager console user to authenticate as;
- JET_RESAMPWD = The password for the user as specified in JET_RESAMUSER;
- JET_PARAMNAME = Parameter name(s) that’s specified with the RES Automation Manager job;
- JET_PARAMVALUE = Parameter value(s) that’s used in-conjunction with JET_PARAMNAME (Refer to $[UserName] in Step 1).
STEP 5
The last step involves creating an “Execute Command” in the RES Workspace Manager console that will be executed upon logoff time.
- In the RES Workspace Manager console, click on “Composition” from the left hand pane;
- Click on the “Execute Command” node in the same left hand pane;
- Right click in the right hand pane, select “New”;
- Adjust the “Execute Command” options so “Run Hidden” and “Run Task At Logoff” are selected as shown below:
- The next most import factor here is obviously the command line specified. As I’m using “Environment Variables” my command line looks like this. [code]%RESCUSTOMRESOURCES%\JETCMD.EXE /type:%JET_TYPE% /jobguid:%JET_JOBGUID% /agent:LOCAL /user:%JET_RESAMUSER% /password:%JET_RESAMPWD% /encrypted /paramname:%JET_PARAMNAME% /paramvalue:%JET_PARAMVALUE%[/code]You’ll notice I’m also using the %RESCUSTOMRESOURCES% “Environment variable” – which is used internally by RES Workspace Manager to resolve the location of the “Custom Resources” folder.
And there you have it, a common use case for JETCMD with RES Workspace Manager. I hope by now you can see how flexible and powerful JETCMD can be .
We’d love to hear you comments!!.
Nathan.