1.11M Members

windows service to call batch file

 
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?

 
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.

 
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?

 
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".

 
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... :)

 
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 six months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: