Trying to create and run a Scheduled Task via Command Line as local administrator will not run unless logged in as administrator.

I am trying to create and run a scheduled task via command line with local administrator credentials.  here is the example:

schtasks /create /ru administrator /rp <password> /st 00:00:00 /sc ONCE /tn scriptname /tr 'programname.exe'
schtasks /run /tn scriptname

This task is created successfully and shows up in the GUI but will not run = status could not start

If I login as the administrator in this example it works fine and runs fine but it's when I'm signed in as a normal user it fails every time.

MJSAHLIAsked:
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.

samiam41Commented:
With the command you have listed, doesn't that create the task to run "once" with the credentials supplied?

Also, what permissions does the script have that you are mentioning?  Does the user that is logged in have permissions to the script?
0
MJSAHLIAuthor Commented:
Yes I want it to only run once.  The local users have the rights needed to run the task.  
0
samiam41Commented:
So the user can browse to the path and execute the script without using task scheduler?  Are you creating this on a remote pc?

0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

samiam41Commented:
This site is where I get my syntax commands from and I noticed that there is a disclaimer about user permissions in it.

http://www.ss64.com/nt/schtasks.html

Where is the "programname.exe" located?  Network share/local?
0
Joseph DalyCommented:
This is the syntax I used to create a recurring scheduled task using admin credentials on my machines. It is probably easily modified to do what you like.

schtask /create /tn "Taskname" /tr "program or batchyou want to run" /sc weekly /d mon,tue,wed,thu,fri /st 12:10:00 /ru "username" /rp "password"
0
MJSAHLIAuthor Commented:
samiam41:
So the user can browse to the path and execute the script without using task scheduler?  Are you creating this on a remote pc?

 - Yes the user can go to the location which is a network share an run the exe just fine.

- The .exe is actually a compiled AutoIT Script to run the setup of a software package that doesn't have the silent install option so I'm going to be deploying this to all machines in our network.  

Background:
We use a KACE KBOX for system management.  The problem with them is that they run everything as localsystem and I can't get the .exe file that I created to launch at all because it's trying to access the network.  So their idea is to run a task as administrator or a user with access to the network and then call the .exe that I want to run from the network.  

Again all this works fine as long as the user that is logged on is the same account that creates the scheduled task.

So why then when both users (administrator and user1) are local administrators and a task is created via command line when authenticated as administrator then it will run if the task username is administrator.  But if the task is created with user1 authenticated and the task user as administrator it fails.
0
samiam41Commented:
Why not just make the exe into a service and let your SYSTEM account control it.  That would eliminate this problem.
0
Joseph DalyCommented:
We use a KACE KBOX for system management.  The problem with them is that they run everything as localsystem and I can't get the .exe file that I created to launch at all because it's trying to access the network.  So their idea is to run a task as administrator or a user with access to the network and then call the .exe that I want to run from the network.  

Why not move the installation source to a new share and then just set the permissions to Everyone, Anonymous to have access to it?
0

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
MJSAHLIAuthor Commented:
That's what I just was working on.  Thanks!
0
samiam41Commented:
Are you serious?  Hahahahaha....
0
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
Microsoft Legacy OS

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.