Advertisement
Guest User

Untitled

a guest
May 4th, 2015
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. <Component Id='c_WSService' Guid='*'>
  2. <File Id='f_WSService' Name='WSService.exe' Vital='yes' Source='..wssvrreleasewsservice.exe' />
  3. <ServiceInstall Id='WSService.exe' Name='WSService' DisplayName='[product name]' Type='ownProcess'
  4. Interactive='no' Start='auto' Vital='yes' ErrorControl='normal'
  5. Description='Provides local and remote access to [product name] search facilities.' />
  6. <ServiceControl Id='WSService.exe' Name='WSService' Start='install' Stop='both' Remove='uninstall' Wait='yes' />
  7. </Component>
  8.  
  9. sc stop {name of your service}
  10. sc start {name of your service}
  11.  
  12. '' This works. It leaves the MSI in a state that tells you to reboot the PC, but you really don't need to.
  13. Private Sub ProjectInstaller_BeforeInstall(sender As Object, e As System.Configuration.Install.InstallEventArgs) Handles Me.BeforeInstall
  14.  
  15. Dim sEchoMessage As String = String.Empty
  16. sEchoMessage &= " & ECHO ****************** Please be patient *******************************"
  17. sEchoMessage &= " & ECHO Pausing to stop and delete the previous version of the following service:"
  18. sEchoMessage &= " & ECHO " & ServiceInstaller1.ServiceName
  19. sEchoMessage &= " & ECHO -------------------------------------------------------------------------------"
  20. sEchoMessage &= " & ECHO After install is complete, you may see a message that says you need to reboot."
  21. sEchoMessage &= " & ECHO You may IGNORE this message - The service will be installed and running."
  22. sEchoMessage &= " & ECHO There is NO Reboot required."
  23. sEchoMessage &= " & ECHO *******************************************************************************"
  24.  
  25. RunCommandCom("sc stop " & ServiceInstaller1.ServiceName & " & sc delete " & ServiceInstaller1.ServiceName & sEchoMessage, 15000)
  26.  
  27. End Sub
  28.  
  29. Private Sub RunCommandCom(command As String, mSecSleepAfterExecution As Integer)
  30.  
  31. Using p As Process = New Process()
  32. Dim pi As ProcessStartInfo = New ProcessStartInfo()
  33. pi.Arguments = " /K " + command
  34. pi.FileName = "cmd.exe"
  35. p.StartInfo = pi
  36. p.Start()
  37. System.Threading.Thread.Sleep(mSecSleepAfterExecution)
  38. p.CloseMainWindow()
  39. End Using
  40.  
  41. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement