Remko Weijnen's Blog (Remko's Blog)

About Virtualization, VDI, SBC, Application Compatibility and anything else I feel like

Archive for the ‘SQL Server’ Category

Deleting scheduled Altiris tasks from SQL

I needed to delete around 50 scheduled tasks from several machines in Altiris because something went wrong in on of the first jobs.

It would have better if the jobs were configured to fail on error and not continue but they weren’t.

Deleting the jobs from the Altiris console is very, very, slow. First the console asks for confirmation (after showing the hourglass for a long time):


Then the actual delete can take a few minutes and then the next server and so on.

I decided to delete the tasks directly from SQL.

I know this is not preferred but I think in the end it’s safe enough because I found a stored procedure called del_event_schedule which looks like this:

So al it does is a (transacted) delete from the table.



  • 1 Comment
  • Filed under: SQL Server, VMWare
  • Apply IP Configuration from a Database

    I am currently deploying 64 Citrix XenApp servers with Altiris. The deployment consists of an OS Image, OS Configuration and finally Citrix XenApp and Applications.

    In the OS Configuration part the IP configuration needs to be applied and I decided to do this with a database.

    The database consists of 2 tables; one table with the per host settings and one table with the global settings (such as DNS).

    In the Altiris job both tables are read from an embedded VBScript and assigned to the NIC.

    Database configuration

    I created a database (SQL Server) called IPManagement with 2 tables:




    Last time I showed a User Defined Function to the Full Path of an Altiris Job given it’s id (event_id). Note that Altiris calls a Job an Event so the terms Event and Jobs are interchangeable here.

    To complete it we first need to prepend the server and share name to the path.

    I looked into the Altiris database tables to find the best place to get the servername and it seems that the hostname column of the mmsettings table is a good way.

    In my database there was only one row in the table but I restrict the results by adding top 1:

    Then I looked into the available tokens for one that returns a job id but we can only return a job name or a computer id. Since a job name is not unique I decided to use the computername and find the active job for this computer.

    When a Job is scheduled an entry is added to the event_schedule table. If you look into this table you will notice a column status_code which is NULL initially and when the job start it will get a value of -1 which indicates the job is active.

    When the job has finished the status will always be 0 or higher. (more…)

    Earlier I described a SQL Query to get the Full Path of an Altiris Job, today I will describe how we can make a User Defined Function (UDF) in SQL so we can call it easier.

    I am using an UDF because it allows us to specify parameters, in this case a single parameter (the EventId (or job id).

    This is the SQL that creates the UDF:


    I wanted to query the full path name of an Altiris Job, this sounds easier that it is though.

    Consider the following hierarchy:


    Now I want to assemble the full Path, in this case: RPA\Getronics\PKG_p007.Citrix_Components.


    Altiris AxSched ignores the DSN parameter

    I was playing around with the AxSched tool that comes with Altiris, in my case the version that comes with v6.9 build 453.

    I could not make it connect to the Deployment Server from my test machine, it seemed like the /dsn parameter I used was totally ignored.

    I also tried the /d and /db parameters but they didn’t have any effect at all, the message was always:

    Error opening database connection:
    SQL Server does not exist or access denied.
    ConnectionOpen (Connect()).

    So I opened AxSched in Ida Pro and set a Breakpoint to the place where the SQL Connection seems to be made:


    Ida nicely hints us that the ConnectionString is in the ECX register so we only have to inspect it to see it’s value.

    Actually AxSched does several attemps and the used Connection Strings are:

    1. DRIVER={SQL Server};DSN=;SERVER=;Trusted_Connection=yes;
    2. DRIVER={SQL Server};DSN=;SERVER=;UID=sa;PWD=;Trusted_Connection=no;
    3. DSN=Altiris eXpress Database;
    4. DSN=Altiris eXpress Database;Trusted_Connection=yes;
    5. DSN=Altiris eXpress Database;UID=sa;PWD=;Trusted_Connection=no;

    So I bypassed by adding a DSN with the name Altiris eXpress Database and then it works.

    Earlier today I wrote about my Altiris Job Builder tool but when I tested the actual produced build job I noticed something weird: the job was scheduled but not executed.

    I then tried to manually push a job to this server and that one executed fine.

    When I clicked the Job I could see that it was scheduled:


    But when I clicked the Server it wasn’t there:



    Altiris Job Builder

    I have created a little tool for myself that I have call Altiris Job Builder, it retreives the Jobs from the Altiris database and shows them in a Treeview.

    Then I can assemble a Master Build Job by dragging the needed Jobs to another Treeview on the right. Since it’s just for me it doesn’t have a fancy gui:


    So why did I write it? Well I have divided my Jobs into Prerequisites and Packages, for instance IIS and Terminal Server and Java are prereqisuites for Citrix. But many prereqisuites are required for one or more other packages, eg Java is also used for certain applications. (more…)

    I was trying to install HP Insight Control server deployment (previously called HP Rapid Deployment Pack) on Sql Server 2008 Express. I will just call it Deployment Server or DS from here.

    I first installed SQL 2008 Express with Advanced Services and configured it to listen op Port 1433 as required by DS.

    The installation of the first part (Deployment Server version 6.9.4) indicated a successfull install but the prereqisuites check of the Hotfix version 2.0 installer failed on the last step:

    No Attached Consoles HP Deployment Server

    This was strange because I didn’t yet startup the console, so I decided to start it and close it as this would perhaps allow me to continue.

    The next screen was a clear indication something went wrong:

    Altiris Deploymeny Server Unable to Connect

    I presumed that the ODBC connection was missing so I went to Adminstrative Tools | Data Sources (ODBC). But the ODBC connection was present. I then fired up SQL Server Management Studio which showed me the eXpress database was missing.

    Script to clear SQL Transactions logs

    Script to clear SQL Transactions Logs

    Did you know that when you backup a SQL database with Backup Exec (with the SQL Agent) the transaction log is not cleared? This means that if you use the full recovery model your transaction log keeps growing and growing. I tested this with Backup Exec v11D and you can only create a seperate scheduled job to backup the transactions logs but not one to just clear it or truncate it after successfull backup.

    Therefore I made a VBS script that clears SQL transactions logs, an option would be to schedule this as a post backup job.

    This is the script: