• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1038
  • Last Modified:

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.

0
MJSAHLI
Asked:
MJSAHLI
  • 5
  • 3
  • 2
1 Solution
 
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 5
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now