Windows-7

Windows XP 服務和 Windows 7 服務有什麼區別?

  • November 5, 2011

我已經下載了一個開源 C++ 應用程序。此應用程序作為 Linux 守護程序執行,偵聽埠並等待來自客戶端 PC 的連接。有人在 Cygwin 下編譯了這個應用程序,使其可以在 Windows 環境中執行。Windows 版本帶有一個 .exe 執行檔以及 2 個 Cygwin DLL。

我曾嘗試在 Windows XP 中執行此應用程序。當我在命令行中執行 .exe 執行檔時,該程序能夠將自身置於後台並作為 Windows 服務執行。當我打開任務管理器視窗時,我可以看到程序正在後台執行。客戶端 PC 也能夠成功連接到該程序。

However, when i run the same .exe executable in Windows 7, nothing happened. The program failed to start. When I check the task manager window, I couldn’t see any process related to this application.

May I know what is the difference between Windows XP services and Windows 7 services?

Since it is an open source program, I would like to modify the program so that it can run in both Windows XP and Windows 7 as a service. Appreciate if anyone can give me some guidance how to do it.

Thanks.

One of the big differences between XP and Vista is that services are no longer allowed to use the desktop, so that might be a problem.

Make sure to put your application files in a place that is accessible to the user that executes it, don’t put them in your own userprofile directory.

What I would try first is to register your application as a real service instead of calling it directly from the command line. Check out the “sc” application from the command line. You can use “sc create …” to register your service and then use “sc start …” to start your service. If something goes wrong check out the Event Log for a possible error message.

引用自:https://serverfault.com/questions/328060