Client Management Suite

 View Only

Improving client job conditions allowing custom return codes (Windows OS Bit Check) 

Nov 26, 2014 03:39 PM

REQUIREMENTS

 

Create a deployment job that first detects whether the targeted Windows machine is 32 or 64 bit then initiates the appropriate installer.

 

OBSTACLES

 

Unlike DS 6.9, there are no built in conditions on client jobs in 7.x, instead the return code from a previously run task is evaluated in the conditional statement(s).  This allows you to create a client task with a script that returns a code based on a decision (e.g. is this machine 32 bit or 64 bit).  In the client job, you can base your deployment logic on the return code.   The issue is, I don’t see an easy way to add non-zero success codes on a client job (as was offered in DS 6.9).  What is provided is an option to allow the job to continue regardless of failures.  Ignoring failures is not an option for us.  I want our support team to see these failures and act accordingly.  To better illustrate this, please see example below:

 

Conditional Deployment Job with “Fail job if any task fails” option DISABLED (allowed to fail)

  • Run “Script to determine OS bit” (returns 64 for 64 bit OS)
  • IF “Script to determine OS bit” = 64 (returns 0 for TRUE)
  • RUN “64 bit installer” (returns 3 - file not found)
  • ELSE
  • RUN “32 bit installer” (returns false as it should)

In the above example we were able to determine that the targeted machine was 64-bit, but there was an error during the install and the task returned an error code.  Because the “Fail job if any task fails” option was disabled to allow non-zero return codes, we rely on our front-line staff to check back with all tasks within a job to verify success.   I opt for more reliable automation.

 

SOLUTION

 

The question is, where in the 7.x environment can we add success codes?  Software Catalogue.  Basically, what I did was I added a custom executable (script, MSI, EXE) into the Software Catalogue designed to return a code based on the OS Bit.  I add those custom return codes as Software Release success codes.  I create a client task that calls this Software Release and call on that task in all deployment jobs where a 32/64 bit decision is made.

 

Create executable

*** I’m sure you can simply use a script without compiling into an .EXE as I have, but I’ll just go through my approach.  My executable is basically a VBS script compiled as an .EXE.  I compiled my VBS using PrimalScript.  There may be free VBS Compilers out there.

  1. Create a script to determine whether or not the target Windows machine is 32/64 bit.  I’ll add a simple script under the Reference section (at the end of this document).
  2. Using a script compiler utility, compile the script to an .EXE (optional).  

Software Catalogue

  1. Open the Symantec Management Console (SMP)
  2. Navigate to Manage > Software Catalogue
  3. Click on Import
  4. From the Import Software window under Package Contents, click Add
  5. Navigate to the file you create in the previous section and click the Open button
  6. If the filename is not bold, click Set Installation File
  7. Software Type should be Software Release
  8. Click Next
  9. When prompted agree to edit the Software Release after saving
  10. From the Software Release window, click on the Package tab
  11. Under the Command Lines section, click Add Command
  12. Enable “Command Line requires a package” and select your package from the drop-down list
  13. From the Add or Edit Command Line window
    • Name: give your command a meaningful name (e.g. Get OS Bit)
    • Installation file type: if you’ve chosen to go with a script (e.g. VBS), select other.  In my case, I’ve chosen EXE
    • Command type: custom
    • Set as default command for this command type: Yes
    • Command Line: 
      • If you’ve chosen to go with a script, you’ll have to add a command that would launch the script (e.g. “cscript file.vbs”)
      • in my case the command is simply “file.exe”
    • Success codes: enter all success codes here. In my case it’s “10064” for 64-bit and 10032 for 32-bit
  14. Click OK on each window to save your Software Release

Create Quick Software Delivery Task

  1. From SMP, navigate to Jobs/Tasks
  2. Create a new task by right-clicking on the destination container and click on Select > Task
  3. From the Create New Task window, select Quick Delivery
  4. Give it a meaningful name
  5. From the drop-down text box for Software, select the software release you created in the previous section
  6. Verify the correct Command Line and Package values are set
  7. Click OK

Create Deployment Job

  1. From SMP, navigate to Jobs/Tasks
  2. Create a new job by right-clicking on the destination container and click on Select > Client Job
  3. From the Job section (right), give the job a meaningful name
  4. Click on Add Existing
  5. Navigate to the Quick Software Delivery Task you created in the previous section.  For the sake of this example, we’ll name this task “OS Bit Check”
  6. Click OK
  7. Click New > Condition
  8. Edit condition so it displays something similar to the following:
    • Where: [ OS Bit Check - Return Value ] [ Equals ] [ 10064 ]
  9. Click OK
  10. Click Add Existing and select the 64 bit installer task/job
  11. Click Add Existing and select the 32 bit installer task/job
  12. Your deployment job should looks something like the following:
    Job Start
        Run “OS Bit Check”
        If “OS Bit Check” Return Value equals 10064
            Run “64 bit installer”
        Else
            Run “32 bit installer”
    Stop
  13. Make sure the checkbox for “Fail if any job fails” is checked
  14. Click Save Changes

REFERENCE MATERIAL

 

VBS Script to determine 32/64 bit OS

'************************************************************************************************************************************************

' VARIABLE DEFINITION

'************************************************************************************************************************************************

 

CONST HKEY_LOCAL_MACHINE  = &H80000002

 

'************************************************************************************************************************************************

' FUNCTIONS

'************************************************************************************************************************************************

 

function getBitWidth(strComputerName)

    set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputerName & "\root\default:StdRegProv") 

    strKeyPath = "HARDWARE\DESCRIPTION\System\CentralProcessor\0"

    strValueName = "Identifier"

    

    objReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strValue

 

    if (instr(strValue,"64")) then

        getBitWidth = 64

    else 

        getBitWidth = 32

    end if

end function

 

function getOSVersion(strComputerName)

    set objWMI = GetObject("winmgmts://" & strComputerName & "/root/cimv2")

    set colItems = objWMI.ExecQuery("Select * from Win32_OperatingSystem",,48)

 

    for each objItem in colItems

        strOSVersion = left(objItem.Version, 3)

    next

 

    getOSVersion = strOSVersion

end function

 

'************************************************************************************************************************************************

' BEGIN

'************************************************************************************************************************************************

 

strComputerName = "." 'local

intBitWidth = getBitWidth(strComputerName)

strOSVersion = getOSVersion(strComputerName)

 

select case strOSVersion

    case "6.1" : strOSName = "Windows 7"

    case "6.0" : strOSName = "Windows Vista"

    case "5.2" : strOSName = "Windows 2003"

    case "5.1" : strOSName = "Windows XP"

    case "5.0" : strOSName = "Windows 2000"

    case "4.0" : strOSName = "Windows NT 4.0"

    case else : strOSName = "Windows 9x"

end select

 

WScript.Quit("100" & intBitWidth)

 

Statistics
0 Favorited
0 Views
0 Files
0 Shares
0 Downloads

Tags and Keywords

Comments

Jul 01, 2015 05:50 AM

I appreciate your candid response here and I wanted to give you a view from the other perspective. I probably have a few hundred of these kind of items that are pretty easy to code on face value and would add real benefit to a subset of customers. The issue is that given them all, including development, testing, user validation and ongoing maintenance we would have enough to keep us going for a decade. 

The harsh reality of keeping a large and complex product such as ITMS moving forward is that we have to choose the features that add the most value across the customer base. That alone isn't a huge problem but with the constant influx of new developments that are required to keep up with the market, some items that seem easy just fall out of reach for us.

While I'm not at all saying that implementing this is definitely not going to be done (I constantly evaluate and re-evaluate all of the requests I receive), if you sometimes see things not getting done, please don't take that to mean we don't understand or care. I took over this product 12 months ago and am very passionate about it's evolution and improvement and I promise you that we're spending our time wisely and where it needs to be spent.

Please keep the feedback coming, it's exceptionally valuable to me and while I can't promise to do everything I promise we're doing our best.

Thanks,

David

Jul 01, 2015 01:50 AM

While I appreciate Ed's thoroughness in providing a full end-to-end solution here... I cannot help but ask myself:

Why the heck can't Symantec's developers come up with something a lot simpler than this??  Like setting a simple 32-bit or 64-bit Applicability Rule for CMS Jobs & Tasks, like we can on Policies?

I mean, how hard can it be to code this into your product and give your customers simple drop-down menus? It's not like distinguishing between 32 & 64-bit OSs is some sort of exotic request these days. And it would save your customers a lot of time spent coding and debugging it all ourselves.

Jul 01, 2015 01:49 AM

Thanks, RFredette. You solution --though not as ideal as getting some built-in widget directly from Symantec developers (hint, hint)-- is a lot simpler.

Dec 03, 2014 04:33 PM

I have an alternate method that seems to work well - but only if the computer has inventory data and is running Windows.

Create a new Token.  (Settings->All Settings->Notification Server->Task Settings->Tokens)

Enter the Token Name as OSbit

Enter the following as the SQL:

/*** A token to return the operating server architecture (bits) ***/ /*** %OSbit% : Returns operating server bit***/ select [OS Architecture] from [dbo].[Inv_OS_Operating_System] where [_ResourceGuid] = '%COMPUTERID%'

Then create a task to run a Client Script.  For the script enter:

@Echo Off

Echo %OSbit%

 

Make sure that you also check the Advanced setting

Now you can use the output from the script "scriptname - Script" as the Condition - if it equals 32 or 64.

Related Entries and Links

No Related Resource entered.