文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>using BAT to setup windows service

using BAT to setup windows service

时间:2011-02-24  来源:FtpCsharp

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

相关阅读 更多 +
排行榜 更多 +
方块枪战战场安卓版

方块枪战战场安卓版

飞行射击 下载
战斗火力射击安卓版

战斗火力射击安卓版

飞行射击 下载
空中防御战安卓版

空中防御战安卓版

飞行射击 下载