Cannot run AutoIT script as a program in Microsoft System Center

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
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mike TLeading EngineerCommented:

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.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Vadim RappCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.