Install a service from command line (VB Express 2008)

扶醉桌前 提交于 2019-12-10 11:50:46

问题


I've been following a tutorial on http://michaelellerbeck.com/2009/01/12/creating-a-service-for-visual-basic-2008-express/ for creating a service using VB Express 2008. I got the first part working and managed to get the sample to install using InstallUtil, but the second part has you use a form with buttons to install and uninstall the service.

I'm wondering if there are instructions for installing the service from a command line so I could just change to a specific subdirectory and type "myservice /i" to install it or /u to uninstall it.

Any advice or tutorials to do this?


回答1:


In the example you have provided, the code that installs the service using the undocumented call:

Try
    System.Configuration.Install.ManagedInstallerClass.InstallHelper(New String() {”C:\Test\YourService1.exe”})
Catch ex As Exception
    MessageBox.Show(ex.ToString)
End Try

is placed in an event handler under a button. Well, there's nothing preventing you from executing this code directly.

To do that, just create a console application, and paste the code above into the entry point, Sub Main(). Then, create your executable.



来源:https://stackoverflow.com/questions/958891/install-a-service-from-command-line-vb-express-2008

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!