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?

Recommended Answers

All 5 Replies

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.

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?

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

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.