[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Cannot run AutoIT script as a program in Microsoft System Center

Posted on 2014-08-22
3
Medium Priority
?
489 Views
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)  
#Else
#   Exit(1605)
#EndIf  

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
0
Comment
Question by:eng_bci
2 Comments
 
LVL 19

Accepted Solution

by:
Mike T earned 2000 total points
ID: 40281892
Hi,

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.

Mike
0
 
LVL 40

Expert Comment

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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Sometimes when I receive a call from my users to solve their problems it is very difficult for me to found their computer IP address. Even finding their computer Host to provide remote support can be a problem.  So I resorted to Goo…
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses
Course of the Month20 days, 12 hours left to enroll

865 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