norgepaul
norgepaul

Reputation: 6053

Is it possible to run a hidden console application from a Windows service?

I've written a server in Delphi 2010 that needs to launch a console application every now and again to back up a database. The console application can send log information to the console window, but it is not required.

This works fine when running as an application, but when run as a service I get an access violation when launching the console application. This is the case even if I launch it hidden (SW_HIDE).

Is it possible to launch a hidden console application from a Windows service? The solution needs to work on XP, Vista and Windows 7.

EDIT: The access violation happens when I call ShellExecute.

Upvotes: 2

Views: 2032

Answers (1)

Jeroen Wiert Pluimers
Jeroen Wiert Pluimers

Reputation: 24513

If you are using ShellExecute, then don't: it won't work inside a service, and is almost never the best way to start a process.

Use CreateProcess in stead.

See this bunch of ShellExecute / CreateProcess question threads on stackoverflow.

--jeroen

Upvotes: 5

Related Questions