Powershell script that will create shortcuts for client and service executables and to run all of them in one go it will also create a batch file.
It also takes care of launching the IIS express to host the webservice.
param(
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string]$SolutionFileDirectoryPath,
[AllowNull()]
[string]
$ShortcutTargetLocation
)
$SolutionFileDirectoryPath=$SolutionFileDirectoryPath.TrimStart('"')
$SolutionFileDirectoryPath=$SolutionFileDirectoryPath.TrimEnd('"')
$PathExists = Test-Path $SolutionFileDirectoryPath
if ($pathexists -eq $false)
{
write-host "missing or wrong parameters:"
write-host "-solutionfiledirectorypath directory path of solution file in source code(without trailing slash - \)"
write-host "-shortcuttargetlocation target location of services shortcut and batch file. Default location is current executable path of powershell script."
return
}
If($ShortcutTargetLocation -eq $null -or $ShortcutTargetLocation -eq "")
{
write-host "-ShortcutTargetLocation Target location of services shortcut and batch file. Default location is current path"
$ShortcutTargetLocation =$(Get-Location)
}
Else
{
$PathExists = Test-Path $ShortcutTargetLocation
If ($PathExists -eq $False)
{
write-host "missing parameter:"
write-host "-ShortcutTargetLocation Specified target path of services shortcut and batch file doesn't exist. Default location is current path"
return
}
}
$ShortcutTargetPath = Join-Path -Path $SolutionFileDirectoryPath -ChildPath "DCX.DPE.AKVService\bin\SQLExpress\DCX.DPE.Service.AKV.exe"
$ShortcutLocation = Join-Path -Path $ShortcutTargetLocation -ChildPath "DCX.DPE.Service.AKV.exe.lnk”
$WScriptShell = New-Object -ComObject WScript.Shell
$Shortcut = $WScriptShell.CreateShortcut($ShortcutLocation)
$Shortcut.TargetPath = $ShortcutTargetPath
$Shortcut.Arguments = "/c"
$Shortcut.Save()
$ShortcutTargetPath = Join-Path -Path $SolutionFileDirectoryPath -ChildPath "DCX.DPE.AKVService\bin\SQLExpress\DCX.DPE.Service.AKV.exe"
$ShortcutLocation = Join-Path -Path $ShortcutTargetLocation -ChildPath "DCX.DPE.Service.AKV.exe.lnk”
$WScriptShell = New-Object -ComObject WScript.Shell
$Shortcut = $WScriptShell.CreateShortcut($ShortcutLocation)
$Shortcut.TargetPath = $ShortcutTargetPath
$Shortcut.Arguments = "/c"
$Shortcut.Save()
$ShortcutTargetPath = Join-Path -Path $SolutionFileDirectoryPath -ChildPath "DCX.DPE.Service.Creta\bin\SQLExpress\DCX.DPE.Service.Creta.exe"
$ShortcutLocation = Join-Path -Path $ShortcutTargetLocation -ChildPath "DCX.DPE.Service.Creta.lnk”
$WScriptShell = New-Object -ComObject WScript.Shell
$Shortcut = $WScriptShell.CreateShortcut($ShortcutLocation)
$Shortcut.TargetPath = $ShortcutTargetPath
$Shortcut.Arguments = "/c"
$Shortcut.Save()
$ShortcutTargetPath = Join-Path -Path $SolutionFileDirectoryPath -ChildPath "DCX.DPE.Service.OpenItems\bin\SQLExpress\DCX.DPE.Service.OpenItems.exe"
$ShortcutLocation = Join-Path -Path $ShortcutTargetLocation -ChildPath "DCX.DPE.Service.OpenItems.exe.lnk”
$WScriptShell = New-Object -ComObject WScript.Shell
$Shortcut = $WScriptShell.CreateShortcut($ShortcutLocation)
$Shortcut.TargetPath = $ShortcutTargetPath
$Shortcut.Arguments = "/c"
$Shortcut.Save()
$ShortcutTargetPath = Join-Path -Path $SolutionFileDirectoryPath -ChildPath "DCX.DPE.Service.Qgroup\bin\SQLExpress\DCX.DPE.Service.Qgroup.exe"
$ShortcutLocation = Join-Path -Path $ShortcutTargetLocation -ChildPath "DCX.DPE.Service.Qgroup.exe.lnk”
$WScriptShell = New-Object -ComObject WScript.Shell
$Shortcut = $WScriptShell.CreateShortcut($ShortcutLocation)
$Shortcut.TargetPath = $ShortcutTargetPath
$Shortcut.Arguments = "/c"
$Shortcut.Save()
$ShortcutTargetPath = Join-Path -Path $SolutionFileDirectoryPath -ChildPath "DCX.DPE.Service.SoftwareManagement\bin\SQLExpress\DCX.DPE.Service.SoftwareManagement.exe"
$ShortcutLocation = Join-Path -Path $ShortcutTargetLocation -ChildPath "DCX.DPE.Service.SoftwareManagement.exe.lnk”
$WScriptShell = New-Object -ComObject WScript.Shell
$Shortcut = $WScriptShell.CreateShortcut($ShortcutLocation)
$Shortcut.TargetPath = $ShortcutTargetPath
$Shortcut.Arguments = "/c"
$Shortcut.Save()
$ShortcutTargetPath = Join-Path -Path $SolutionFileDirectoryPath -ChildPath "DCX.DPE.Service.Workflow\bin\SQLExpress\DCX.DPE.Service.Workflow.exe"
$ShortcutLocation = Join-Path -Path $ShortcutTargetLocation -ChildPath "DCX.DPE.Service.Workflow.exe.lnk”
$WScriptShell = New-Object -ComObject WScript.Shell
$Shortcut = $WScriptShell.CreateShortcut($ShortcutLocation)
$Shortcut.TargetPath = $ShortcutTargetPath
$Shortcut.Arguments = "/c"
$Shortcut.Save()
$ShortcutTargetPath = Join-Path -Path $SolutionFileDirectoryPath -ChildPath "DCX.DPE.Client\bin\SQLExpress\DCX.DPE.Client.exe"
$ShortcutLocation = Join-Path -Path $ShortcutTargetLocation -ChildPath "DCX.DPE.Client.exe.lnk”
$WScriptShell = New-Object -ComObject WScript.Shell
$Shortcut = $WScriptShell.CreateShortcut($ShortcutLocation)
$Shortcut.TargetPath = $ShortcutTargetPath
$Shortcut.Save()
$ShortcutTargetPath = Join-Path -Path $SolutionFileDirectoryPath -ChildPath "DCX.DPE.Client\bin\SQLExpress\DCX.DPE.Client.exe"
$ShortcutLocation = Join-Path -Path $ShortcutTargetLocation -ChildPath "DCX.DPE.Client.exe - PMULLAN.lnk”
$WScriptShell = New-Object -ComObject WScript.Shell
$Shortcut = $WScriptShell.CreateShortcut($ShortcutLocation)
$Shortcut.TargetPath = $ShortcutTargetPath
$Shortcut.Arguments = "APAC\PMULLAN"
$Shortcut.Save()
$BatFile = Join-Path -Path $ShortcutTargetLocation -ChildPath "LaunchDPEServices.bat"
If (Test-Path $BatFile) { Del $BatFile } #> #>
$BatchFileContent ="cd `"C:\Program Files (x86)\IIS Express\`"
start iisexpress /config:`"$(Join-Path -Path $SolutionFileDirectoryPath -ChildPath ".vs\DPE\config\applicationhost.config")`" /site:DCX.DPE.Web
cd /d `"$ShortcutTargetLocation`"
start `"DPE-AKVService`" /b `"DCX.DPE.Service.AKV.exe.lnk`"
start `"DPE-OpenItemService`" /b `"DCX.DPE.Service.OpenItems.exe.lnk`"
start `"DPE-WorkflowService`" /b `"DCX.DPE.Service.Workflow.exe.lnk`"
start `"DPE-QGroupService`" /b `"DCX.DPE.Service.Qgroup.exe.lnk`"
start `"DPE-SwMgmntService`" /b `"DCX.DPE.Service.SoftwareManagement.exe.lnk`""
Set-Content -Path $BatFile -Value $BatchFileContent -Encoding ASCII
write-host "Output files generated at `"$ShortcutTargetLocation`""
It also takes care of launching the IIS express to host the webservice.
param(
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string]$SolutionFileDirectoryPath,
[AllowNull()]
[string]
$ShortcutTargetLocation
)
$SolutionFileDirectoryPath=$SolutionFileDirectoryPath.TrimStart('"')
$SolutionFileDirectoryPath=$SolutionFileDirectoryPath.TrimEnd('"')
$PathExists = Test-Path $SolutionFileDirectoryPath
if ($pathexists -eq $false)
{
write-host "missing or wrong parameters:"
write-host "-solutionfiledirectorypath directory path of solution file in source code(without trailing slash - \)"
write-host "-shortcuttargetlocation target location of services shortcut and batch file. Default location is current executable path of powershell script."
return
}
If($ShortcutTargetLocation -eq $null -or $ShortcutTargetLocation -eq "")
{
write-host "-ShortcutTargetLocation Target location of services shortcut and batch file. Default location is current path"
$ShortcutTargetLocation =$(Get-Location)
}
Else
{
$PathExists = Test-Path $ShortcutTargetLocation
If ($PathExists -eq $False)
{
write-host "missing parameter:"
write-host "-ShortcutTargetLocation Specified target path of services shortcut and batch file doesn't exist. Default location is current path"
return
}
}
$ShortcutTargetPath = Join-Path -Path $SolutionFileDirectoryPath -ChildPath "DCX.DPE.AKVService\bin\SQLExpress\DCX.DPE.Service.AKV.exe"
$ShortcutLocation = Join-Path -Path $ShortcutTargetLocation -ChildPath "DCX.DPE.Service.AKV.exe.lnk”
$WScriptShell = New-Object -ComObject WScript.Shell
$Shortcut = $WScriptShell.CreateShortcut($ShortcutLocation)
$Shortcut.TargetPath = $ShortcutTargetPath
$Shortcut.Arguments = "/c"
$Shortcut.Save()
$ShortcutTargetPath = Join-Path -Path $SolutionFileDirectoryPath -ChildPath "DCX.DPE.AKVService\bin\SQLExpress\DCX.DPE.Service.AKV.exe"
$ShortcutLocation = Join-Path -Path $ShortcutTargetLocation -ChildPath "DCX.DPE.Service.AKV.exe.lnk”
$WScriptShell = New-Object -ComObject WScript.Shell
$Shortcut = $WScriptShell.CreateShortcut($ShortcutLocation)
$Shortcut.TargetPath = $ShortcutTargetPath
$Shortcut.Arguments = "/c"
$Shortcut.Save()
$ShortcutTargetPath = Join-Path -Path $SolutionFileDirectoryPath -ChildPath "DCX.DPE.Service.Creta\bin\SQLExpress\DCX.DPE.Service.Creta.exe"
$ShortcutLocation = Join-Path -Path $ShortcutTargetLocation -ChildPath "DCX.DPE.Service.Creta.lnk”
$WScriptShell = New-Object -ComObject WScript.Shell
$Shortcut = $WScriptShell.CreateShortcut($ShortcutLocation)
$Shortcut.TargetPath = $ShortcutTargetPath
$Shortcut.Arguments = "/c"
$Shortcut.Save()
$ShortcutTargetPath = Join-Path -Path $SolutionFileDirectoryPath -ChildPath "DCX.DPE.Service.OpenItems\bin\SQLExpress\DCX.DPE.Service.OpenItems.exe"
$ShortcutLocation = Join-Path -Path $ShortcutTargetLocation -ChildPath "DCX.DPE.Service.OpenItems.exe.lnk”
$WScriptShell = New-Object -ComObject WScript.Shell
$Shortcut = $WScriptShell.CreateShortcut($ShortcutLocation)
$Shortcut.TargetPath = $ShortcutTargetPath
$Shortcut.Arguments = "/c"
$Shortcut.Save()
$ShortcutTargetPath = Join-Path -Path $SolutionFileDirectoryPath -ChildPath "DCX.DPE.Service.Qgroup\bin\SQLExpress\DCX.DPE.Service.Qgroup.exe"
$ShortcutLocation = Join-Path -Path $ShortcutTargetLocation -ChildPath "DCX.DPE.Service.Qgroup.exe.lnk”
$WScriptShell = New-Object -ComObject WScript.Shell
$Shortcut = $WScriptShell.CreateShortcut($ShortcutLocation)
$Shortcut.TargetPath = $ShortcutTargetPath
$Shortcut.Arguments = "/c"
$Shortcut.Save()
$ShortcutTargetPath = Join-Path -Path $SolutionFileDirectoryPath -ChildPath "DCX.DPE.Service.SoftwareManagement\bin\SQLExpress\DCX.DPE.Service.SoftwareManagement.exe"
$ShortcutLocation = Join-Path -Path $ShortcutTargetLocation -ChildPath "DCX.DPE.Service.SoftwareManagement.exe.lnk”
$WScriptShell = New-Object -ComObject WScript.Shell
$Shortcut = $WScriptShell.CreateShortcut($ShortcutLocation)
$Shortcut.TargetPath = $ShortcutTargetPath
$Shortcut.Arguments = "/c"
$Shortcut.Save()
$ShortcutTargetPath = Join-Path -Path $SolutionFileDirectoryPath -ChildPath "DCX.DPE.Service.Workflow\bin\SQLExpress\DCX.DPE.Service.Workflow.exe"
$ShortcutLocation = Join-Path -Path $ShortcutTargetLocation -ChildPath "DCX.DPE.Service.Workflow.exe.lnk”
$WScriptShell = New-Object -ComObject WScript.Shell
$Shortcut = $WScriptShell.CreateShortcut($ShortcutLocation)
$Shortcut.TargetPath = $ShortcutTargetPath
$Shortcut.Arguments = "/c"
$Shortcut.Save()
$ShortcutTargetPath = Join-Path -Path $SolutionFileDirectoryPath -ChildPath "DCX.DPE.Client\bin\SQLExpress\DCX.DPE.Client.exe"
$ShortcutLocation = Join-Path -Path $ShortcutTargetLocation -ChildPath "DCX.DPE.Client.exe.lnk”
$WScriptShell = New-Object -ComObject WScript.Shell
$Shortcut = $WScriptShell.CreateShortcut($ShortcutLocation)
$Shortcut.TargetPath = $ShortcutTargetPath
$Shortcut.Save()
$ShortcutTargetPath = Join-Path -Path $SolutionFileDirectoryPath -ChildPath "DCX.DPE.Client\bin\SQLExpress\DCX.DPE.Client.exe"
$ShortcutLocation = Join-Path -Path $ShortcutTargetLocation -ChildPath "DCX.DPE.Client.exe - PMULLAN.lnk”
$WScriptShell = New-Object -ComObject WScript.Shell
$Shortcut = $WScriptShell.CreateShortcut($ShortcutLocation)
$Shortcut.TargetPath = $ShortcutTargetPath
$Shortcut.Arguments = "APAC\PMULLAN"
$Shortcut.Save()
$BatFile = Join-Path -Path $ShortcutTargetLocation -ChildPath "LaunchDPEServices.bat"
If (Test-Path $BatFile) { Del $BatFile } #> #>
$BatchFileContent ="cd `"C:\Program Files (x86)\IIS Express\`"
start iisexpress /config:`"$(Join-Path -Path $SolutionFileDirectoryPath -ChildPath ".vs\DPE\config\applicationhost.config")`" /site:DCX.DPE.Web
cd /d `"$ShortcutTargetLocation`"
start `"DPE-AKVService`" /b `"DCX.DPE.Service.AKV.exe.lnk`"
start `"DPE-OpenItemService`" /b `"DCX.DPE.Service.OpenItems.exe.lnk`"
start `"DPE-WorkflowService`" /b `"DCX.DPE.Service.Workflow.exe.lnk`"
start `"DPE-QGroupService`" /b `"DCX.DPE.Service.Qgroup.exe.lnk`"
start `"DPE-SwMgmntService`" /b `"DCX.DPE.Service.SoftwareManagement.exe.lnk`""
Set-Content -Path $BatFile -Value $BatchFileContent -Encoding ASCII
write-host "Output files generated at `"$ShortcutTargetLocation`""
No comments:
Post a Comment