Indigo Rose Software

Go Back   Indigo Rose Software Forums > Setup Factory 8.0 > Setup Factory 8.0 Discussion

Reply
 
Thread Tools Display Modes
  #1  
Old 11-09-2008
searcher123 searcher123 is offline
Forum Member
 
Join Date: Jun 2007
Posts: 59
How to check & uncheck an option in a preactivated service?

I have a program that I must follow the following steps manually to run it as a service:
  • Step 1: I must execute myprogram.exe /install in command line to run it as a service.
  • Step 2: I must start myprogram in Administrative Tools' Services list, after checking its Allow service to interact with desktop checkbox.
  • Step 3: I must stop the service, uncheck Allow service to interact with desktop and start it again.
How should I follow this process by SF8? A code please!.

Best Regards
Reply With Quote
  #2  
Old 11-09-2008
pww's Avatar
pww pww is offline
Forum Member
 
Join Date: Jun 2005
Posts: 343
SF has built-in actions to start/stop/query services, so I guess the question is how to set/reset "Allow service to interact with desktop"

Make sure box is un-checked and goto
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Servic es\<service_name>
Check the value of "Type"
Now check the box "Allow service..", apply, refresh Regedit window and check the value of Type again.

If I correctly remember this is the change that has to be made to set/reset desktop interaction directly (but you may do a registry snapshot immediately before and after the change and compare). Needless to say, check this on several systems. Also I'm not sure when the change becomes effective - immediately or after a service (re)start.

Last edited by pww; 11-09-2008 at 03:25 AM.
Reply With Quote
  #3  
Old 11-09-2008
searcher123 searcher123 is offline
Forum Member
 
Join Date: Jun 2007
Posts: 59
Thank you very much dear PWW,
Worked great

Quote:
Originally Posted by pww View Post
(...) I'm not sure when the change becomes effective - immediately or after a service (re)start.
The change was affected immediately.

Best Regards

P.S: For future needers:
Under windows XP
1. Type is a DWORD value.
2. Set it to 16 to Allow service to interact with desktop be checked
3. Set it to 272 to Allow service to interact with desktop be unchecked

Last edited by searcher123; 11-09-2008 at 06:18 AM.
Reply With Quote
  #4  
Old 11-09-2008
pww's Avatar
pww pww is offline
Forum Member
 
Join Date: Jun 2005
Posts: 343
Quote:
Originally Posted by searcher123 View Post
P.S: For future needers:
Under windows XP
1. Type is a DWORD value.
2. Set it to 16 to Allow service to interact with desktop be checked
3. Set it to 272 to Allow service to interact with desktop be unchecked
Actually this isn't always like that, I haven't explained it the right way in my first post, sorry.
To allow a service to interact with desktop, the 8-th bit of 'Type' value must be set to 1. Or in other words, you should OR the current value (when Desktop interaction is disabled) with 256 decimal to set the 8-th bit to 1 and enable it.
To disable Desktop interaction , you should reset the 8-th bit.

So values of 16 and 272 are valid for your particular case/service only.

Last edited by pww; 11-09-2008 at 08:08 AM.
Reply With Quote
  #5  
Old 11-10-2008
searcher123 searcher123 is offline
Forum Member
 
Join Date: Jun 2007
Posts: 59
Quote:
Originally Posted by pww View Post
Actually this isn't always like that, I haven't explained it the right way in my first post, sorry.
To allow a service to interact with desktop, the 8-th bit of 'Type' value must be set to 1. Or in other words, you should OR the current value (when Desktop interaction is disabled) with 256 decimal to set the 8-th bit to 1 and enable it.
To disable Desktop interaction , you should reset the 8-th bit.

So values of 16 and 272 are valid for your particular case/service only.
Thanks for your supplementary explanation too

So, the following code will set Allow service to interact with desktop checked for any service:

Code:
nType    = Registry.GetValue(HKEY_LOCAL_MACHINE, "System\\CurrentcontrolSet\\Services\\<ServiceKeyName>", "Type", true);
nNewType = nType + 256
Registry.SetValue(HKEY_LOCAL_MACHINE, "System\\CurrentcontrolSet\\Services\\Alerter", "Type", SessionVar.Expand(nNewType), REG_DWORD);
and the following code will set it unchecked for the same service again:

Code:
nType    = Registry.GetValue(HKEY_LOCAL_MACHINE, "System\\CurrentcontrolSet\\Services\\<ServiceKeyName>", "Type", true);
nNewType = Math.Abs(nType - 256)
Registry.SetValue(HKEY_LOCAL_MACHINE, "System\\CurrentcontrolSet\\Services\\Alerter", "Type", SessionVar.Expand(nNewType), REG_DWORD);
OK?
Reply With Quote
  #6  
Old 11-11-2008
pww's Avatar
pww pww is offline
Forum Member
 
Join Date: Jun 2005
Posts: 343
well the best way would be to bitwise OR the current value with 256 decimal to enable, and to bitwise AND the current value with 65279 decimal to disable.
But AFAIK Lua doesn't support bitwise operations. Maybe there is a plugin or something for the purpose.
In your case Type has known values, so you may
-to set - if current value < 256, add 256, else do nothing(already set)
-to reset - if current value >256, subtract 256, else do nothing(already reset)

Setting Type to Math.Abs(nType - 256) may cause a mess if desktop interaction is already reset
Reply With Quote
  #7  
Old 11-11-2008
searcher123 searcher123 is offline
Forum Member
 
Join Date: Jun 2007
Posts: 59
Quote:
Originally Posted by pww View Post
(...)But AFAIK Lua doesn't support bitwise operations.(...)
I wrote a simple utility for eliminating this leakage in SF. The attached will bitwise AND, OR and XOR two number and return the result to SF or show it on Command Com window. I hope be useful for future needers.

Best Regards
Attached Files
File Type: zip Bitwiser_v1.0.zip (223.8 KB, 12 views)
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Command: Stop Service & Start Service ??? linhardt Setup Factory 6.0 3 07-13-2004 01:14 PM


All times are GMT -6. The time now is 10:39 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright © 2000 - 2009 Indigo Rose Corporation. All rights reserved.
Indigo Rose Software