How to use variable in Filename

B

Bruno

Hello,


I createted a Windows service as shown in the folowing video
http://www.labo-dotnet.com/Videos/Veille/Créer un Service Windows/0/1304.aspx

Now I added Process1 and Process2, two actions to execute when the
service starts and stops. I declared:



// TODO : ajoutez ici le code pour démarrer votre service.
this.eventLog1.WriteEntry("Service Démarré");
this.process1.Start();
}

/// <summary>
/// Arrêt du service.
/// </summary>
protected override void OnStop()
{
// TODO : ajoutez ici le code pour effectuer les destructions
nécessaires à l'arrêt de votre service.
this.eventLog1.WriteEntry("Service Stoppé");
this.process2.Start();
}

The command I want to execute in process1 and process2 is:

%OVPERLBIN% %OvAgentDir%\bin\Opc\cmds\SwitchControl.pl Start VtomClt
(Process1)

%OVPERLBIN% %OvAgentDir%\bin\Opc\cmds\SwitchControl.pl Stop VtomClt
(Process2)


%OVPERLBIN% = d:\usr\OV\bin\perl.exe

Of course the variable exists in the target machine.

In StartInfo Filename, I wrote d:\usr\OV\bin\perl.exe and in Arguments
%OvAgentDir%\bin\Opc\cmds\SwitchControl.pl Start VtomClt, this works
all right when I start and stop the service.


Now my problem appears when I want to write the variable %OVPERLBIN%
instead of the absolute path of the perl.exe command line (in
Filename).


Thanks by advance for your help
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

Normally you could find the value of it using
Enrivonment.GetEnvironmentVariable("OVPERLBIN")

I don;t know if they exist in a windows service , you could try though.

cheers,
 
B

Bruno Castaing

Hi ignacio,

Thanks for answering

I alredy tried to declare %OVPERLBIN% in EnvironnemtVariables
System.Collections.Specialized.StringDictionary but without success.


Cheers

Bruno
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

If Environment does not work for you all you have rest is defining the
variable in the config file manually.

cheers,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top