|
-
August 22nd, 2009, 01:11 AM
#1
Issues with using ControlService(hService, CustomCommand) and VISTA/Windows7?
I currently have a Windows Service written in C# .NET 2.0 which is automatically started and runs under the LocalSystem account - lets call it Serv.exe - this service is responsible for performing administrative tasks (a bunch of them).
There is another application (lets call it A.exe written in C++) which is run under the USER account (non-administrator), this application communicates with the Service (Serv.exe), using custom commands (ControlService(hService, CustomCommand) to tell it what task to perform.
Now - this all works perfectly fine right now, using Windows 2000 and XP - but will this cause problem when migrating to VISTA and Windows7? I know people mentioned that in Vista services run in a different session (not exactly sure what that entails) - will there be any issues using ControlService(...) under OS's past XP?
Key point to recall is that A.exe (non-admin user account) is communicating with Serv.exe (Local System service) to perform tasks like:
- copy files, delete files, move files
- extract files, zip files
- run setup.exe's, apply .MSI files
- register COM objects
- affecting the registry
- etc...
(pretty much anything you could image)
I need to know if there will be porting problems, if so I'll completly change my approach now (while I have the time).
(and use Named Pipes instead)
The reason I was using ControlService(...) instead of Pipes or Sockets is due to the fact that I only communicate with the service once every 20-30mins and only to request a specific operation be performed (simply send a single integer one-way), I thought pipes/sockets might be overkill for my needs ... I could be wrong ...
Looking for some advice, any help would be much appreciated...
Thanks,
-
August 22nd, 2009, 03:38 PM
#2
Re: Issues with using ControlService(hService, CustomCommand) and VISTA/Windows7?
 Originally Posted by Shaitan00
this all works perfectly fine right now, using Windows 2000 and XP - but will this cause problem when migrating to VISTA and Windows7?
Listen, how can we tell without seeing your app? Why don't you compile it and run it on Vista and see for yourself? Then if you can't figure it out, isolate the code chunk that's causing the issue and post it here.
From my personal experience, simply assuming that something will run under Vista/Win7 is a gross underestimation (otherwise Microsoft wouldn't lose a good portion of its followers to Apple). To be honest with you none of my "serious" coding projects worked smoothly under Vista when I first ported them from XP.
As for a service to be able to run under Vista, it probably will, (and this is my generalization only) since it will still be running under session 0, and as long as it doesn't rely on interacting with a desktop (uses SERVICE_INTERACTIVE_PROCESS flag during its creation, or sends messages to windows) it will probably still run. Read more here.
The problem usually happens with a client app, that doesn't run under session 0 anymore, like it used to under XP, and you may start having problems with it performing some administrative tasks, that should've been moved to a service in the first place, or, most certainly in a way it communicates with the service if you opted to use any method other than the one recommended by MSDN (i.e. named pipes, COM, maybe some others, like mail slots and sockets).
As for ControlService(), it will probably work if you manage to get a handle to the service. For that make sure you specify the minimum required access flags when you call OpenSCManager() and OpenService().
One very rough way to see if your app will work under Vista (if you just happen to live in a place where Vista is totally inaccessible) is to run it under a Guest account in XP. If it doesn't work there, then expect some problems under Vista/Win7.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|