We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,561 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

windows service to call batch file

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?

4
Contributors
5
Replies
6 Hours
Discussion Span
1 Year Ago
Last Updated
6
Views
spowel4
Junior Poster in Training
57 posts since Jul 2008
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 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.

thines01
Postaholic
Team Colleague
2,433 posts since Oct 2009
Reputation Points: 447
Solved Threads: 408
Skill Endorsements: 7

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?

spowel4
Junior Poster in Training
57 posts since Jul 2008
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 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".

BobS0327
Junior Poster
185 posts since Feb 2008
Reputation Points: 35
Solved Threads: 24
Skill Endorsements: 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... :)

thines01
Postaholic
Team Colleague
2,433 posts since Oct 2009
Reputation Points: 447
Solved Threads: 408
Skill Endorsements: 7

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

viljoed
Newbie Poster
4 posts since Nov 2009
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page generated in 0.1083 seconds using 2.65MB