#$plink       = "D:\wyc\Environment\plink\plink.exe"
#$pscp        = "D:\wyc\Environment\plink\pscp.exe"
#$userHost    = "wyc@192.168.1.79"
#$password    = "123"
#$serviceName = "FirstDriver"
#$src = "D:\proj\build\vs2022_debug\kernel_helloworld\kernel_helloworld.sys"
#$remote_dst = "C:/psc/kernel_helloworld.sys"

param(
    [Parameter(Mandatory = $true)]
    [string]$Plink,

    [Parameter(Mandatory = $true)]
    [string]$Pscp,

    [Parameter(Mandatory = $true)]
    [string]$UserHost,

    [Parameter(Mandatory = $true)]
    [string]$Password,

    [Parameter(Mandatory = $true)]
    [string]$ServiceName,

    [Parameter(Mandatory = $true)]
    [string]$Source,

    [Parameter(Mandatory = $true)]
    [string]$RemoteDst
)


. "$PSScriptRoot\base.legacy"
$ret = Invoke-RemoteCmd "sc.exe stop $serviceName"
$ret = Invoke-RemoteCmd "sc.exe delete $serviceName"
$ret = Invoke-RemoteCopy $Source "${UserHost}:/${RemoteDst}"
$ret = Invoke-RemoteCmd "sc.exe create $serviceName binPath= `"c:\psc\kernel_helloworld.sys`" type= kernel"
$ret = Invoke-RemoteCmd "sc.exe start $serviceName"

Write-Host "exit code: $ret"