Trigger task on server from PC

I want to put an icon on the desktop of a PC which will trigger a task to start on a server 2012.
The server is an AD controller. The PC is a member of the domain.

I have a scheduled task on the server which runs every 24 hours. I want the user to be able to force the task to run sooner by clicking on an icon on their PC. The scheduled task runs a batch file so the icon can trigger the scheduled task or run the batch file.
LVL 13
akbAsked:
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.

Kanti PrasadCommented:
Hi

If the user of the PC have execute access for that server where your batch file is then you can execute it from the PC.
Just map the server to a drive of the PC and put that bat file shortcut on the pc's desktop and click it .
0
akbAuthor Commented:
Hi Kanti,
That won't work. The batch file must run on the server with full admin privileges. The user has only basic user privileges.
I just need the user to trigger the batch to start on the server.
0
Muhammad BurhanManager I.T.Commented:
have you tried schtasks /run /s <machine name> /tn <task name>.
make a bat file wih this cmd and place it on user's desktop then check what happens ?
0
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

akbAuthor Commented:
Hi Muhammad,
No. I haven't tried anything yet.
I'm looking for a solution to the problem.
I was hoping that someone would come up with a known solution without me having to try things.
Thanks for your input.
0
Scott CSenior EngineerCommented:
The problem you are facing is that you want a user to act as an admin in this one instance.  What you are trying to do is bypass the built in security.  

Since the batch file must be run with full admin privileges, I don't think there is a way for a user to kick it off.

I don't think I've ever heard of trying to do something like this.  You are most likely going to have to try things.

I would suggest setting up a small VM lab so you can experiment.
0
Muhammad BurhanManager I.T.Commented:
Tested!
create a task on a server 'Server16' which just open CMD.
then try to trigger it from the client PC with cmd and bat, working both ways and triggers it but Access Denied on standard users.
also tried, make shortcut mark run as admin but standard users can't do it without admin credentials.

schtasks /run /s Server16 /tn \Microsoft\Windows\Test
0
Kanti PrasadCommented:
hi

Below are some options. So you can put those commands in a bat file on your pc desktop and click it

https://technet.microsoft.com/en-us/library/cc770416.aspx
0
akbAuthor Commented:
Thanks for the replies.
ScottCha - I really don't want the user to do anything as an admin or to bypass any security.
Muhammad - Thanks for the effort but this is a standard user so it won't work.
Kanti - Thanks for the link but that doesn't help for non-administrators.

I'm thinking along the lines of:
  User clicks icon.
  Icon runs a script which writes a flag/file to a folder on the server.
  A scheduled task on the server checks for flag/file every 60 seconds.
  If the file exists the flag/file is deleted and the batch file is executed.

This would require no special privileges for the user.
The flag/file will be written to a folder on the server which only the user has access to so no one else can write to the share.

I was hoping to come up with a neater solution to this. I'm not sure what impact running a scheduled task every 60 seconds would have on the server - probably none I'm guessing.
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
Scott CSenior EngineerCommented:
Actually I think you might have figured out a solution.

You probably would see little to no impact on performance.

You might want to have the task check every 60 seconds during business hours.  No point it running after hours when a backup job could be running.
0
David Johnson, CD, MVPOwnerCommented:
so you need 2 scheduled tasks
task 1
your scheduled task

task 2 watcher.cmd
-------------
:start
if exist d:\share\watchfolder\mycrazyfilename.watch runschtasks.cmd
timeout /t 60 /nobreak > NUL
goto start 

Open in new window

-------------
 
runschtasks.cmd
----------------------------
del d:\share\watchfilder\mycrazyfilename.watch
schtasks /run /s Server16 /tn \Microsoft\Windows\Test 

Open in new window

-------------
0
Muhammad BurhanManager I.T.Commented:
@David, it works.

1. Create task and name it as 'Test' and in 'action' ask to do anything you want.

2. Create another task and name it Condition, set its repetition in 'triggers >  repeat task in every 1 min' and ask it to run condition.bat.

Two bat files should be in Server, and 3rd is optional.

1. condition.bat   (which check the existence of file)

:start
if exist C:\Shares\new.txt runtask.bat else stoptask.bat
timeout /t 5 /nobreak > NUL
goto start

2. runtask.bat   (which runs the task and delete file for next run)

del c:\shares\new.txt
schtasks /run /tn \Microsoft\Windows\Test

optional
3. stoptask.bat   (which stops the task if file dsn't there)

schtasks /run /tn \Microsoft\Windows\Test

Note: please remove 'else ' statement in condition.bat and don't create stoptask.bat as well if you don't want that operation.
0
akbAuthor Commented:
Thanks for all your help. I ended up going with my own solution as above. Am happy to divide up the points for all your input.
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
Windows Server 2012

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.