First of all ,we must copy the ngen.exe and InstallUtil.exe to the windows service directory ,if we want to use the relative path
regist windows service Bat:
InstallUtil Test.exe //the name of the service
net start "Test" //start the service
unregist windows service Bat: InstallUtil -u WindowsServiceFileupload.exe
(1)
we double click the file,we can enter to the dos which could execute the command in the bat file
(2)
we use Process to start the bat file
there has a problem which the defualt directory is system32,so we must to point the abosulte path
%SystemRoot%\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe "D:/Test.exe"
then the code :
Process p = new Process();
p.StartInfo.FileName =batFilePath;
p.Start();
p.WaitForExit(30000); join the thread
But what I want to say is it's no use in the develping like up ways!
what we want is using the relative ,so there give you a effective way
Process p = new Process();
p.StartInfo.FileName = batFilePath;
p.StartInfo.WorkingDirectory = BasePath; //point to the base diectory path
p.Start();
p.WaitForExit(30000);
the bat file we also can write as follow which using the relative path
InstallUtil Test.exe //the name of the service
net start "Test" //start the service