cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
armyedsp
Level 4

automating user name and password for a service

My InstallScript MSI project under InstallShield 2009 Professional is working fine with a windows service component in one of the features successfully installed with a fixed User Name and Password set in the Component's Advanced Settings | Install NT Service property. Now I need to be able to dynamically set these values during the installation. I am able to prompt the user for these values via SdLogonUserInformation function. But the challenge is setting these values in to the component property at run time. Any ideas? The closest thing I found was the FeatureSetData() function. But its nInfo parameter does not have a corresponding numeric value for these settings (user name, password). Any pointers or sample code will be appreciated.

Thanks in advance.
Labels (1)
0 Kudos
(4) Replies
schmoli
Level 6

armyedsp wrote:
My InstallScript MSI project under InstallShield 2009 Professional is working fine with a windows service component in one of the features successfully installed with a fixed User Name and Password set in the Component's Advanced Settings | Install NT Service property. Now I need to be able to dynamically set these values during the installation. I am able to prompt the user for these values via SdLogonUserInformation function. But the challenge is setting these values in to the component property at run time. Any ideas? The closest thing I found was the FeatureSetData() function. But its nInfo parameter does not have a corresponding numeric value for these settings (user name, password). Any pointers or sample code will be appreciated.

Thanks in advance.


If you find a more advanced way I'd love to hear it, but the method I'm currently using is to install my services as LocalSystem, then after InstallServices I execute a custom action that updates the service using the windows "sc.exe" tool.

the syntax is:

[CODE]sc.exe config [SERVICENAME] obj= [USERNAME] password= [PASSWORD][/CODE]
0 Kudos
armyedsp
Level 4

Thanks schmoli. I appreciate your post. I got it working through sc.exe just as you stated. But I could not get the command to execute successfully from within a custom action (doesn't matter if the CA is inserted after InstallServices or StartServices in the execute sequence). I do see a DOS window flash by. Because I was able to execute the command manually from a DOS prompt, I decided to create a mycmd.bat file and placed a pause command in the batch after the sc in an attempt to see what errors if any are reported from the sc. However, the LaunchAppAndWait does not execute a batch from CA! So, I decided to simply invoke the sc from within OnFirstUIAfter. So, in short, I got it to work but not from a custom action as you stated.

It would be nice to be able to simply update the formatted data for user name and password in the msi service table from within installscript.

Thanks again.
0 Kudos
schmoli
Level 6

Glad you got it working, not sure why you were unable to execute it from a CA (are you sure you set it as a Commit CA? it needs to execute after the services are installed [so that there is something to modify]). As far as debugging, what I usually do is replace "sc.exe" with "cmd /k sc.exe" so that you will get a DOS box to appear, and show you your output w/o exiting, so that you can determine the issue (and test possible fixed command lines before typing 'exit').
0 Kudos
armyedsp
Level 4

Thans again. It works now. I had the CA set for Immediate Execution. Corrected that, and that fixed it. Thanks again for your help. I appreciate it.
0 Kudos