Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Running a powershell task to call exe while logged off

Posted on 2016-09-09
8
Medium Priority
?
139 Views
Last Modified: 2016-09-12
So I have been researching for hours and tried various solutions, I am still having trouble getting an exe to run while logged off.   This is a utility for a 3rd party program called sync.exe.  It will not run when called directly in task scheduler.

So we are trying a powershell script which works fine when logged in an running it manually outside task scheduler.  But once we set it as a scheduled task, the script apparently runs but the exe that it calls does not start.

We have tried running as a admin group and also privileged AD account.  I am using the start-process command in the script and pointing directly to sync.exe.  It is located on a local drive so it is not networked.

We cannot figure out why the exe does not run while logged off.
0
Comment
Question by:bigeven2002
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 41

Expert Comment

by:footech
ID: 41791798
It seems likely to me that the program either requires a GUI or a user profile environment.   Either one would mean that it can't run as a scheduled task with an account that is not logged in.
0
 
LVL 17

Author Comment

by:bigeven2002
ID: 41791907
Thanks for the reply.  The strange thing is, this sync.exe file was supposed to be designed to run as a task and it has no overhead or interface.  If double clicking to run the sync, the process will show up in task manager and do its thing. There is no window for it.  And when it is finished it auto terminates.
0
 
LVL 41

Accepted Solution

by:
footech earned 2000 total points
ID: 41791987
I would leave calling it from PowerShell out, that just adds another layer of complication and doesn't add any ability to run it as a task.

If you set up a task to run the sync.exe, but set it to run only when user is logged on, does it work?  If so, then it's likely dependent on something in the user profile.  But from there I'm not sure it there's any way to determine what exactly.  Perhaps running Process Explorer or Process Monitor while the program runs could tell you, but especially with ProcMon, it's a lot to sort through.

Can the product maker provide any guidance?
0
Looking for the Wi-Fi vendor that's right for you?

We know how difficult it can be to evaluate Wi-Fi vendors, so we created this helpful Wi-Fi Buyer's Guide to help you find the Wi-Fi vendor that's right for your business! Download the guide and get started on our checklist today!

 
LVL 17

Author Comment

by:bigeven2002
ID: 41792808
I had been working with the maker and that is how we ended up with the powershell script.  The exe will work when set to run when logged in but not when logged out, even though it is supposed to be able to.  I am still working with them as it may just be a bug.  The exit code for the exe is 1 instead of 0 when it finishes so that too may be a bug.

I just didn't know if powershell can circumvent this issue  by forcing it to run under session 0.
0
 
LVL 41

Expert Comment

by:footech
ID: 41793298
Being very familiar with PowerShell, I can't think of any way that it would help the situation.  I wouldn't say it can't definitively, but I would be extremely surprised.

What does the program do?  Where does it get its config (assuming it's not hard-coded into the program)?  What resources does it try to access?

Have you tried it on other machines and OSes?
0
 
LVL 17

Author Comment

by:bigeven2002
ID: 41793437
Yes we have tried server 2008 r2 and server 2012 r2 as those are the only OSes available to try.  I think it is hard coded, I used procmon to dump the strings but didn't find any usable parameters.  We have the 3rd party program installed in multiple office servers that is client data management and this sync utility is provided by that program to synchronize the data across those servers.  

It is meant to be ran from a primary server whereas the others are secondary.  At present we are running the utility manually by logging in and double clicking it.  The 3rd party program even provides a way to setup this utility as a scheduled task so that is how we know it is supposed to work.  I am still leaning more towards bug if it cannot be ran otherwise.

But the reason for powershell was because that was their latest suggestion.  I should be able to find out more later this week when they get back with me.
0
 
LVL 71

Expert Comment

by:Qlemo
ID: 41793560
I agree PowerShell cannot do anything for you here, unless you are using it to change privileges, make sure to run elevated, check parameters or similar.
However, what it can do is to run procmon, the sync utility, and then stop procmon again (not sure about that last part).
ProcMon with a filter of Process PowerShell.exe and sync.exe, with registry and file monitoring active.
0
 
LVL 17

Author Closing Comment

by:bigeven2002
ID: 41795215
Thanks for the replies.  After further information available today, it is a bug and so a user profile login is currently required for it to run.  The maker is going to fix it.
0

Featured Post

Are You Ready for GDPR?

With the GDPR deadline set for May 25, 2018, many organizations are ill-prepared due to uncertainty about the criteria for compliance. According to a recent WatchGuard survey, a staggering 37% of respondents don't even know if their organization needs to comply with GDPR. Do you?

Question has a verified solution.

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

Previously, on our Nano Server Deployment series, we've created a new nano server image and deployed it on a physical server in part 2. Now we will go through configuration.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

721 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