Cannot run AutoIT script as a program in Microsoft System Center

Posted on 2014-08-22
Last Modified: 2015-02-07
We are running Microsoft System Center 2007.  We have the CCM agent installed on our machines and they have UAC enabled.  We run MSIs with no problem on machines frequently using the CCM agent, we also run Shell commands on machines frequently with no issues using the "ShellExecuteWait" function.

I am trying to run a simple AutoIT script to remove some directories and files from a machine.  If I run this script on my own machine using a Local Administrator account it works perfectly.  If I set it up as a program in SCCM and advertise it to a machine it works up to the point of execution and then hangs.

There doesn't seem to be any problem on SCCM:
The package is copied to the remote machine
CCMexec.exe runs the script
The script "sticks" on execution and never finishes... you can see it running as System in task manager.

Why does this work on my machine using a Local Admin, but when I run it under the LSA account using CCMexec.exe it fails?  I think it may have something to do with the LSA not having a registry hive.  I've ran processexplorer on the hung process and it seems to indicate its waiting for user input as the process state displays "state:wrUserRequest".

The script is below:
#$ProgramPath="c:\Program Files (x86)\Program\Version1"
#IF FileExists ($ProcommPath)    Then
#   DirRemove ( "c:\Program Files (x86)\Program\Version1", 1)
#   DirRemove ( "c:\Program Files (x86)\Program", 1)
#   Exit(0)  
#   Exit(1605)

Please don't respond with "why don't you do it using a MSI, or powershell script or ShellExecuteWait" or using some other function.  We know how to make this work using other methods.  We want to know why this won't work, or what we are doing wrong that is keeping it from working.

Thank you
Question by:eng_bci
    LVL 16

    Accepted Solution


    Is the typo below in your real script for your SCCM package:

    #$ProgramPath="c:\Program Files (x86)\Program\Version1"
    #IF FileExists ($ProcommPath)    Then
    I guess it's a Freudian slip of the fingers?

    Since the script works when run manually I doubt it is there but am mentioning it just in case.

    As for running via SCCM, have you tried logging on as an admin and deploying with "Run as user" set? It might give you a clue if it works, somewhere in the logs. ccmexec.log would be a good one to check.

    Also running as a local admin will not test anything in the same context as SCCM because it's still a user account.
    If you want to really simulate SCCM you have to resort to using the task-scheduler to run the job as "system" or try the sysinternals tool, psexec.

    I have found running as system frequently threw curve balls because there just isn't a user context, which led to much head-scratching running scripts, driver installers and more. I normally just persevered and scoured the logs.

    LVL 40

    Expert Comment

    by:Vadim Rapp
    This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    In this tutorial I will show you how to provide a dynamic RTF document on your website generated with data from your database. For this tutorial you will need Microsoft Word or WordPad, WhizBase and Microsoft Access. In this tutorial I will show …
    The System Center Operations Manager 2012, known as SCOM, is a part of the Microsoft system center product that provides the user with infrastructure monitoring and application performance monitoring. SCOM monitors:   Windows or UNIX/LinuxNetwo…
    Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now