I created a .bat file called Wordperfect.bat to call the .ps1 file.
Code: Select all
powershell.exe -noprofile -NoExit -command "&{start-process powershell -ArgumentList '-NoExit -noprofile -file \"%~dpn0.ps1\"' -verb RunAs}"
Code: Select all
$compname = $(hostname)
$service = Get-Service msiserver -Computername $compname
$service | Set-Service -StartupType Manual
$service | Start-Service
pause
do{
Start-Sleep -seconds 3
$service.Refresh()
}
until($service.Status -eq 'Running')
pause
Code: Select all
Set-Service : Service 'Windows Installer (msiserver)' cannot be configured due to the following error: Access is denied
At C:\Dnload\9xAddons\Wordperfect.ps1:3 char:12
+ $service | Set-Service -StartupType Manual
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : PermissionDenied: (System.ServiceProcess.ServiceController:ServiceController) [Set-Servi
ce], ServiceCommandException
+ FullyQualifiedErrorId : CouldNotSetService,Microsoft.PowerShell.Commands.SetServiceCommand
I think I'm running the .ps1 with Run as Administrator
How can I change it to make sure it's in Manual mode and make sure it's started?