1,105,288 Community Members

windows service to call batch file

Member Avatar
spowel4
Junior Poster in Training
72 posts since Jul 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

I need to create a service that will call a batch file. Here's the catch though - once the service calls the batch file, the command window that the batch file runs in must be visible on the desktop, it cannot run hidden. So far nothing I've tried results in the command window being visible. Any suggestions?

Member Avatar
thines01
Postaholic
2,420 posts since Oct 2009
Reputation Points: 389 [?]
Q&As Helped to Solve: 413 [?]
Skill Endorsements: 10 [?]
Team Colleague
Featured
 
0
 

Does it really need to be a windows service?
Could it just be a windowless app that has an internal timer that fires and spawns the batch file?
You could launch it from the startup folder or from the registry.

Member Avatar
spowel4
Junior Poster in Training
72 posts since Jul 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

It just needs to run any time the server reboots or powers up after a shutdown, and it needs to run whether a user is logged on or not. I thought of a service because a service can be set to run automatically. Would the registry approach solve that aspect of the problem?

Member Avatar
BobS0327
Posting Whiz in Training
203 posts since Feb 2008
Reputation Points: 24 [?]
Q&As Helped to Solve: 29 [?]
Skill Endorsements: 0 [?]
 
0
 

By default, services aren't allowed to create user interface elements. You can enable this by going to Services in Control Panel and viewing the Properties for your service. Go to the Log On tab and check "Allow service to interact with desktop".

Member Avatar
thines01
Postaholic
2,420 posts since Oct 2009
Reputation Points: 389 [?]
Q&As Helped to Solve: 413 [?]
Skill Endorsements: 10 [?]
Team Colleague
Featured
 
0
 

It would not run unless a user is logged in.

You could also use the Windows Scheduler. It does not require a user to be logged in, but you would need to put an entry for every time of day you would want it to run.
I can't remember though, if it would pop-up a window if the user is logged-in.
One way to find out... :)

Member Avatar
viljoed
Newbie Poster
4 posts since Nov 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Add PAUSE to the bottom of the batch file so the console doesn't open and close so fast you don't notice.

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: