开发者

How to move the windows service from my local PC onto virtual dedicated server

开发者 https://www.devze.com 2023-03-08 10:35 出处:网络
I have created windows services which perform some functions. Now I want开发者_如何学JAVA to install it on my dedicated virtual server.

I have created windows services which perform some functions.

Now I want开发者_如何学JAVA to install it on my dedicated virtual server.

I am able to connect to the server through remote desktop but I am not able to install the windows service as it is on my local PC.

How can I move the windows services from my PC to virtual dedicated server and install it there?


Converted from previous comment:

You have to copy the file containing the service over to the virtual pc and then install it there. You copy the file in the same way as you copy anything between computers (over network or similar)


In Visual Studio 2010 create a new Windows Service project.

Then create a Service Installer in that project. When deployed this will create the scripts.

http://msdn.microsoft.com/en-us/library/ddhy0byf.aspx

The project installer executable can be ran as explained here:

http://msdn.microsoft.com/en-us/library/sd8zc8ha.aspx

If you are not using Visual Studio, you can use powershell to install the windows service remotely.

example link : http://halr9000.com/article/444

# Creates a service using the Create Method of Win32_Service Class
# MSDN docs: http://msdn2.microsoft.com/en-us/library/aa389390.aspx
# Helpful example obtained from The PowerShell Guy
# http://thepowershellguy.com/blogs/posh/archive/2007/03/26/powershell-wmi-explorer-part-3.aspx

$computer = "." # this computer
$class = "Win32_Service"
$method = "Create"
$mc = [wmiclass]"\\$computer\ROOT\CIMV2:$class"
$inparams = $mc.PSBase.GetMethodParameters($method)
$inparams.DesktopInteract = $false
$inparams.DisplayName = "My Service"
$inparams.ErrorControl = 0
$inparams.LoadOrderGroup = $null
$inparams.LoadOrderGroupDependencies = $null
$inparams.Name = "myservice"
$inparams.PathName = "c:\program files\path\myservice.exe"
$inparams.ServiceDependencies = $null
$inparams.ServiceType = 16
$inparams.StartMode = "Automatic"
$inparams.StartName = $null # will start as localsystem builtin if null
$inparams.StartPassword = $null
0

精彩评论

暂无评论...
验证码 换一张
取 消