Click here to Skip to main content
15,895,538 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: Creating one file from all the files created using 'Publish' Pin
Curtis Schlak.6-Mar-09 2:37
Curtis Schlak.6-Mar-09 2:37 
GeneralRe: Creating one file from all the files created using 'Publish' Pin
Eddy Vluggen6-Mar-09 3:06
professionalEddy Vluggen6-Mar-09 3:06 
AnswerRe: Creating one file from all the files created using 'Publish' Pin
Curtis Schlak.6-Mar-09 1:48
Curtis Schlak.6-Mar-09 1:48 
QuestionAxWebBrowser - Customizing Print Content Pin
CoolCoder_New4-Mar-09 19:11
CoolCoder_New4-Mar-09 19:11 
QuestionPing Using UDP Pin
tiger08064-Mar-09 4:58
tiger08064-Mar-09 4:58 
QuestionCalculating the cheksum of code in memory Pin
push19884-Mar-09 3:03
push19884-Mar-09 3:03 
AnswerRe: Calculating the cheksum of code in memory Pin
Mark Churchill4-Mar-09 15:11
Mark Churchill4-Mar-09 15:11 
QuestionHow can I define startup parameters for a windows service while installing it? Pin
Member 25855274-Mar-09 1:52
Member 25855274-Mar-09 1:52 
Hi everyone! With one sentence: How can I define startup parameters for a windows service while installing it?
Here is the detailed story which I think that it would be helpful for help 
I wrote and installed my custom windows service. I didn’t use the right mouse click to create a service installer instead I derived it from the “Installer” class and wrote it myself. Now I need to use my service sometimes as a windows application. In the main Main() method of my application I made a check for parameters. If there is a parameter called “-ui” it works as a Windows application. If there is not a parameter it checks if it’s already installed into the windows services or not. If not installed then it installs itself and runs. The service/windows application runs well. Now I just want it to run it without a parameter as a Windows application and with a parameter as a service (the total opposite as I am using it right now). So I changed my Main() method for the parameters. With a double click on the exe it runs as windows application. For starting the service now the application is expecting a parameter called “-service” from the command line. The service must also be notified that it can take parameters. By double clicking in the “services” window we can see “Path to executable" (which is the “ImagePath” key in the registry). I modified the value of the “ImagePath” key by hand and the service worked well. Now I want to skip the editing the registry by hand part and automate it. First I tried add the parameter into the assembly location.
this.Context.Parameters["assemblypath"]= Assembly.GetEntryAssembly().Location + " -service";
this modification truly changed the see “Path to executable" of my service in the services window and and “ImagePath” in the registry like this:
“myPath\MyService.exe –service”
but the funny thing was that my service stoped working after the modification. The reason that it was working when I modified the registry by hand was that the ”-service” parameter wasn’t in the double quotes. Instead it was like this.
“myPath\MyService.exe’ –service
I checked several web sites to figure out how to define startup parameters into a windows service and I always came to a code which modified the registry key “ImagePath”.

using (RegistryKey system = Registry.LocalMachine.OpenSubKey("System"))
{
if (system == null)
return;

using (RegistryKey currentControlSet = system.OpenSubKey("CurrentControlSet"))
{
if (currentControlSet == null)
return;

using (RegistryKey services = currentControlSet.OpenSubKey("Services"))
{
if (services == null)
return;

using (RegistryKey service = services.OpenSubKey(KmsService.SERVICE_NAME))
{
string imagePath = service.GetValue("ImagePath") as string;
service.SetValue("ImagePath", imagePath + " -service");
Registry.LocalMachine.Flush();
service.Close();
}
services.Close();
}
currentControlSet.Close();
}
system.Close();
}

But now I got permission issues to write to the registry. How can I solve this problem. Because I can normally write to the registry otherwise it would not write to it in the first place.
In the end thank you in advance…
Sincerely
Mehmet Rasim Inceoglu
QuestionProblem with MSI Installer Pin
Subrahmanya Narayana3-Mar-09 20:42
Subrahmanya Narayana3-Mar-09 20:42 
AnswerRe: Problem with MSI Installer Pin
Subrahmanya Narayana3-Mar-09 21:44
Subrahmanya Narayana3-Mar-09 21:44 
Questionsplitting image Pin
rohan40403-Mar-09 19:46
rohan40403-Mar-09 19:46 
AnswerRe: splitting image Pin
Thomas Stockwell5-Mar-09 7:48
professionalThomas Stockwell5-Mar-09 7:48 
Questioncoverting image Pin
rohan40403-Mar-09 19:45
rohan40403-Mar-09 19:45 
AnswerRe: coverting image - Repost Pin
ABitSmart3-Mar-09 20:45
ABitSmart3-Mar-09 20:45 
AnswerRe: coverting image Pin
annathor5-Mar-09 3:32
annathor5-Mar-09 3:32 
QuestionProblem in reading a xml string into data set Pin
Renukapadhamanaban3-Mar-09 17:21
Renukapadhamanaban3-Mar-09 17:21 
AnswerRe: Problem in reading a xml string into data set Pin
Cybernate6-Mar-09 3:12
Cybernate6-Mar-09 3:12 
QuestionDistribution Restrictions on CodeDom? Pin
Bill Bielke3-Mar-09 12:24
Bill Bielke3-Mar-09 12:24 
QuestionVB.Net MDI Child form loading issue... Pin
Tej Aj3-Mar-09 6:51
Tej Aj3-Mar-09 6:51 
QuestionEntity Framework with Services : several Reference.cs for the same database Pin
WolveFred23-Mar-09 1:31
WolveFred23-Mar-09 1:31 
QuestionScheduling tasks Pin
1sabine83-Mar-09 0:07
1sabine83-Mar-09 0:07 
AnswerRe: Scheduling tasks [modified] Pin
Eddy Vluggen3-Mar-09 3:59
professionalEddy Vluggen3-Mar-09 3:59 
AnswerRe: Scheduling tasks Pin
Dave Kreskowiak3-Mar-09 7:03
mveDave Kreskowiak3-Mar-09 7:03 
QuestionDebugging XSLT with VS2008 Pin
bVagadishnu2-Mar-09 3:27
bVagadishnu2-Mar-09 3:27 
Questioncoversion of image into pixel matrix [modified] Pin
rohan40401-Mar-09 18:51
rohan40401-Mar-09 18:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.