├── Assets ├── Auto.png ├── Boot.png ├── Disable.png ├── LookUp.png ├── Manual.png ├── Menu.png ├── Registry.png ├── Search.png ├── Start.png ├── Stop.png ├── System.png └── WindowsLogo.ico ├── README.md └── ServiceManagerPlus.ps1 /Assets/Auto.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zoicware/ServiceManagerPlus/d76e19815863d6bf1503a0c3752e29a8a796f99b/Assets/Auto.png -------------------------------------------------------------------------------- /Assets/Boot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zoicware/ServiceManagerPlus/d76e19815863d6bf1503a0c3752e29a8a796f99b/Assets/Boot.png -------------------------------------------------------------------------------- /Assets/Disable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zoicware/ServiceManagerPlus/d76e19815863d6bf1503a0c3752e29a8a796f99b/Assets/Disable.png -------------------------------------------------------------------------------- /Assets/LookUp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zoicware/ServiceManagerPlus/d76e19815863d6bf1503a0c3752e29a8a796f99b/Assets/LookUp.png -------------------------------------------------------------------------------- /Assets/Manual.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zoicware/ServiceManagerPlus/d76e19815863d6bf1503a0c3752e29a8a796f99b/Assets/Manual.png -------------------------------------------------------------------------------- /Assets/Menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zoicware/ServiceManagerPlus/d76e19815863d6bf1503a0c3752e29a8a796f99b/Assets/Menu.png -------------------------------------------------------------------------------- /Assets/Registry.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zoicware/ServiceManagerPlus/d76e19815863d6bf1503a0c3752e29a8a796f99b/Assets/Registry.png -------------------------------------------------------------------------------- /Assets/Search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zoicware/ServiceManagerPlus/d76e19815863d6bf1503a0c3752e29a8a796f99b/Assets/Search.png -------------------------------------------------------------------------------- /Assets/Start.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zoicware/ServiceManagerPlus/d76e19815863d6bf1503a0c3752e29a8a796f99b/Assets/Start.png -------------------------------------------------------------------------------- /Assets/Stop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zoicware/ServiceManagerPlus/d76e19815863d6bf1503a0c3752e29a8a796f99b/Assets/Stop.png -------------------------------------------------------------------------------- /Assets/System.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zoicware/ServiceManagerPlus/d76e19815863d6bf1503a0c3752e29a8a796f99b/Assets/System.png -------------------------------------------------------------------------------- /Assets/WindowsLogo.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zoicware/ServiceManagerPlus/d76e19815863d6bf1503a0c3752e29a8a796f99b/Assets/WindowsLogo.ico -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Service Manager Plus 2 | 3 | Service Manager plus is a PowerShell desktop app with a WinForms GUI. With lots of inspiration from Nirsoft ServiWin, Service Manager Plus allows the user to control services and drivers without the issue of permissions errors. All commands in Service Manager Plus are ran with Trusted Installer privileges allowing advanced users to control locked services and drivers. 4 | 5 | ## Features 6 | 7 | - Quckly find any service using the search box by typing in either the service display name or internal name 8 | 9 | - Change service and driver start type by selecting the services/drivers and using the buttons in the header or by right clicking and using the context menu 10 | 11 | > **TIP Use Control or Shift to select multiple services/drivers** 12 | 13 | - Quickly stop services and drivers with the buttons in the header or using the right click context menu 14 | 15 | - Not sure what a service/driver does? Go straight to the Registry location by selecting a service and clicking `Open in Registry`. Quickly search the internet to find more information by right clicking on 1 or more services/drivers and click `Look Up` to search google with the service or driver name 16 | 17 | - To refresh the list of drivers or services use the `View Drivers` and `View Services` buttons on the top right 18 | 19 | - Export your services or drivers list as a REG file to save a configuration 20 | 21 | > **TIP By Searching some text the search results will be exported instead of the whole list** 22 | 23 | 24 | [![image](https://github.com/user-attachments/assets/276d2aaf-5813-4d28-8bd6-eb7672c62768)](https://youtu.be/FTy7sfCX83w) 25 | -------------------------------------------------------------------------------- /ServiceManagerPlus.ps1: -------------------------------------------------------------------------------- 1 | if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]'Administrator')) { 2 | Start-Process PowerShell.exe -ArgumentList ("-NoProfile -ExecutionPolicy Bypass -File `"{0}`"" -f $PSCommandPath) -Verb RunAs 3 | Exit 4 | } 5 | 6 | #set mode service by default 7 | $Global:Mode = 'service' 8 | 9 | function Get-DriverPlus { 10 | $drivers = Get-CimInstance -ClassName Win32_SystemDriver 11 | $driversList = [System.Collections.ArrayList]::new() 12 | $i = 0 13 | $totalDrivers = $drivers.Count 14 | foreach ($driver in $drivers) { 15 | $i++ 16 | $progressbar1.Value = $(($i / $totalDrivers) * 100) 17 | $driverPlus = [PSCustomObject]@{ 18 | DisplayName = $driver.DisplayName 19 | Name = $driver.Name 20 | Status = $driver.State 21 | StartType = $driver.StartMode 22 | BinaryPath = $driver.PathName 23 | } 24 | $driversList.Add($driverPlus) | Out-Null 25 | } 26 | return $driversList 27 | } 28 | 29 | 30 | function Get-ServicePlus { 31 | #Get all Services 32 | $services = Get-Service -Name * -ErrorAction SilentlyContinue 33 | $totalServices = $services.Count 34 | $svcWMI = Get-CimInstance -Class Win32_Service | Group-Object -Property Name -AsHashTable -AsString 35 | #use .net array list since .Add method is much faster than += 36 | $servicesPlus = [System.Collections.ArrayList]::new() 37 | $i = 0 38 | foreach ($service in $services) { 39 | $i++ 40 | #Write-Progress -Activity 'Getting Services' -Status "$([math]::Round(($i / $totalServices) * 100)) % Complete" -PercentComplete $(($i / $totalServices) * 100) 41 | $progressbar1.Value = $(($i / $totalServices) * 100) 42 | #Get the Binary Path 43 | $binPath = $svcWMI[$service.ServiceName].PathName 44 | #Get the Service Description 45 | $svcDesc = $svcWMI[$service.ServiceName] 46 | #Custom Object to fill Data Grid Table 47 | $servicePlus = [PSCustomObject]@{ 48 | DisplayName = $service.DisplayName 49 | Name = $service.ServiceName 50 | Status = $service.Status 51 | StartType = $service.StartType 52 | 'DependentService(s)' = ($service.ServicesDependedOn | ForEach-Object { $_.DisplayName }) -join ', ' 53 | BinaryPath = $binPath 54 | Description = $svcDesc.Description 55 | } 56 | 57 | $null = $servicesPlus.Add($servicePlus) 58 | } 59 | 60 | return $servicesPlus 61 | } 62 | 63 | #returns string array 64 | function Get-SelectedService { 65 | $selectedRows = $dataGridView.SelectedRows 66 | $serviceNames = @() 67 | foreach ($row in $selectedRows) { 68 | $cells = $row.Cells 69 | $serviceNames += $cells[1].Value 70 | } 71 | return $serviceNames 72 | } 73 | 74 | function Run-Trusted([String]$command) { 75 | 76 | Stop-Service -Name TrustedInstaller -Force -ErrorAction SilentlyContinue 77 | #get bin path to revert later 78 | $service = Get-WmiObject -Class Win32_Service -Filter "Name='TrustedInstaller'" 79 | $DefaultBinPath = $service.PathName 80 | #convert command to base64 to avoid errors with spaces 81 | $bytes = [System.Text.Encoding]::Unicode.GetBytes($command) 82 | $base64Command = [Convert]::ToBase64String($bytes) 83 | #change bin to command 84 | sc.exe config TrustedInstaller binPath= "cmd.exe /c powershell.exe -encodedcommand $base64Command" | Out-Null 85 | #run the command 86 | sc.exe start TrustedInstaller | Out-Null 87 | #set bin back to default 88 | sc.exe config TrustedInstaller binpath= "`"$DefaultBinPath`"" | Out-Null 89 | Stop-Service -Name TrustedInstaller -Force -ErrorAction SilentlyContinue 90 | 91 | } 92 | 93 | function Stop-SelectedService { 94 | param( 95 | [switch]$service, 96 | [switch]$driver 97 | ) 98 | if ($service) { 99 | $selectedServices = Get-SelectedService 100 | if (!($selectedServices)) { 101 | Write-Host 'No Service Selected...' 102 | } 103 | else { 104 | if ($selectedServices.Count -gt 1) { 105 | foreach ($serviceName in $selectedServices) { 106 | $command += "Stop-Service -Name $serviceName -Force; " 107 | } 108 | Run-Trusted -command $command 109 | } 110 | else { 111 | $command = "Stop-Service -Name $selectedServices -Force" 112 | Run-Trusted -command $command 113 | } 114 | } 115 | } 116 | else { 117 | #stop driver 118 | $selectedDrivers = Get-SelectedService 119 | if (!$selectedDrivers) { 120 | Write-Host 'No Driver Selected...' 121 | } 122 | else { 123 | if ($selectedDrivers -gt 1) { 124 | foreach ($driverName in $selectedDrivers) { 125 | $command += "Sc.exe stop $driverName; " 126 | } 127 | Run-Trusted -command $command 128 | } 129 | else { 130 | $command = "Sc.exe stop $selectedDrivers" 131 | Run-Trusted -command $command 132 | } 133 | } 134 | } 135 | 136 | } 137 | 138 | function Start-SelectedService { 139 | param ( 140 | [switch]$service, 141 | [switch]$driver 142 | ) 143 | if ($service) { 144 | $selectedServices = Get-SelectedService 145 | if (!($selectedServices)) { 146 | Write-Host 'No Service Selected...' 147 | } 148 | else { 149 | if ($selectedServices.Count -gt 1) { 150 | foreach ($serviceName in $selectedServices) { 151 | $command += "Start-Service -Name $serviceName; " 152 | } 153 | Run-Trusted -command $command 154 | } 155 | else { 156 | $command = "Start-Service -Name $selectedServices" 157 | Run-Trusted -command $command 158 | } 159 | } 160 | } 161 | else { 162 | #start driver 163 | $selectedDrivers = Get-SelectedService 164 | if (!$selectedDrivers) { 165 | Write-Host 'No Driver Selected...' 166 | } 167 | else { 168 | if ($selectedDrivers -gt 1) { 169 | foreach ($driverName in $selectedDrivers) { 170 | $command += "Sc.exe start $driverName; " 171 | } 172 | Run-Trusted -command $command 173 | } 174 | else { 175 | $command = "Sc.exe start $selectedDrivers" 176 | Run-Trusted -command $command 177 | } 178 | } 179 | } 180 | 181 | } 182 | 183 | function Set-Manual { 184 | param ( 185 | [switch]$driver, 186 | [switch]$service 187 | ) 188 | if ($service) { 189 | $selectedServices = Get-SelectedService 190 | if (!($selectedServices)) { 191 | Write-Host 'No Service Selected...' 192 | } 193 | else { 194 | if ($selectedServices.Count -gt 1) { 195 | foreach ($serviceName in $selectedServices) { 196 | $command += "Set-Service -Name $serviceName -StartupType Manual; " 197 | } 198 | Run-Trusted -command $command 199 | } 200 | else { 201 | $command = "Set-Service -Name $selectedServices -StartupType Manual" 202 | Run-Trusted -command $command 203 | } 204 | } 205 | } 206 | else { 207 | #set driver 208 | $selectedDrivers = Get-SelectedService 209 | if (!$selectedDrivers) { 210 | Write-Host 'No Driver Selected...' 211 | } 212 | else { 213 | if ($selectedDrivers.Count -gt 1) { 214 | foreach ($driverName in $selectedDrivers) { 215 | $command += "Sc.exe config $driverName start= demand; " 216 | } 217 | Run-Trusted -command $command 218 | } 219 | else { 220 | $command = "Sc.exe config $selectedDrivers start= demand" 221 | Run-Trusted -command $command 222 | } 223 | } 224 | 225 | } 226 | 227 | } 228 | 229 | function Set-Automatic { 230 | param( 231 | [switch]$driver, 232 | [switch]$service 233 | ) 234 | if ($service) { 235 | $selectedServices = Get-SelectedService 236 | if (!($selectedServices)) { 237 | Write-Host 'No Service Selected...' 238 | } 239 | else { 240 | if ($selectedServices.Count -gt 1) { 241 | foreach ($serviceName in $selectedServices) { 242 | $command += "Set-Service -Name $serviceName -StartupType Automatic; " 243 | } 244 | Run-Trusted -command $command 245 | } 246 | else { 247 | $command = "Set-Service -Name $selectedServices -StartupType Automatic" 248 | Run-Trusted -command $command 249 | } 250 | } 251 | } 252 | else { 253 | #set driver 254 | $selectedDrivers = Get-SelectedService 255 | if (!$selectedDrivers) { 256 | Write-Host 'No Driver Selected...' 257 | } 258 | else { 259 | if ($selectedDrivers.Count -gt 1) { 260 | foreach ($driverName in $selectedDrivers) { 261 | $command += "Sc.exe config $driverName start= auto; " 262 | } 263 | Run-Trusted -command $command 264 | } 265 | else { 266 | $command = "Sc.exe config $selectedDrivers start= auto" 267 | Run-Trusted -command $command 268 | } 269 | } 270 | 271 | } 272 | 273 | } 274 | 275 | function Set-Disabled { 276 | param( 277 | [switch]$driver, 278 | [switch]$service 279 | ) 280 | if ($service) { 281 | $selectedServices = Get-SelectedService 282 | if (!($selectedServices)) { 283 | Write-Host 'No Service Selected...' 284 | } 285 | else { 286 | if ($selectedServices.Count -gt 1) { 287 | foreach ($serviceName in $selectedServices) { 288 | $command += "Set-Service -Name $serviceName -StartupType Disabled; " 289 | } 290 | Run-Trusted -command $command 291 | } 292 | else { 293 | $command = "Set-Service -Name $selectedServices -StartupType Disabled" 294 | Run-Trusted -command $command 295 | } 296 | } 297 | } 298 | else { 299 | #set driver 300 | $selectedDrivers = Get-SelectedService 301 | if (!$selectedDrivers) { 302 | Write-Host 'No Driver Selected...' 303 | } 304 | else { 305 | if ($selectedDrivers.Count -gt 1) { 306 | foreach ($driverName in $selectedDrivers) { 307 | $command += "Sc.exe config $driverName start= disabled; " 308 | } 309 | Run-Trusted -command $command 310 | } 311 | else { 312 | $command = "Sc.exe config $selectedDrivers start= disabled" 313 | Run-Trusted -command $command 314 | } 315 | } 316 | } 317 | 318 | } 319 | 320 | 321 | function Set-System { 322 | #set driver 323 | $selectedDrivers = Get-SelectedService 324 | if (!$selectedDrivers) { 325 | Write-Host 'No Driver Selected...' 326 | } 327 | else { 328 | if ($selectedDrivers.Count -gt 1) { 329 | foreach ($driverName in $selectedDrivers) { 330 | $command += "Sc.exe config $driverName start= system; " 331 | } 332 | Run-Trusted -command $command 333 | } 334 | else { 335 | $command = "Sc.exe config $selectedDrivers start= system" 336 | Run-Trusted -command $command 337 | } 338 | } 339 | } 340 | 341 | function Set-Boot { 342 | #set driver 343 | $selectedDrivers = Get-SelectedService 344 | if (!$selectedDrivers) { 345 | Write-Host 'No Driver Selected...' 346 | } 347 | else { 348 | if ($selectedDrivers.Count -gt 1) { 349 | foreach ($driverName in $selectedDrivers) { 350 | $command += "Sc.exe config $driverName start= boot; " 351 | } 352 | Run-Trusted -command $command 353 | } 354 | else { 355 | $command = "Sc.exe config $selectedDrivers start= boot" 356 | Run-Trusted -command $command 357 | } 358 | } 359 | } 360 | 361 | 362 | Add-Type -AssemblyName System.Windows.Forms 363 | Add-Type -AssemblyName System.Drawing 364 | [System.Windows.Forms.Application]::EnableVisualStyles() 365 | 366 | # Create the form 367 | $form = New-Object System.Windows.Forms.Form 368 | $form.Text = 'Service Manager Plus' 369 | $form.BackColor = [System.Drawing.Color]::FromArgb(43, 43, 42) 370 | $form.WindowState = 'Maximized' 371 | try { 372 | $form.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon('Assets\WindowsLogo.ico') 373 | } 374 | catch { 375 | Write-Host 'Missing Asset (Title Icon)' -ForegroundColor Red 376 | } 377 | 378 | 379 | $Global:progressBar1 = New-Object System.Windows.Forms.ProgressBar 380 | $progressBar1.Location = New-Object System.Drawing.Point(500, 400) 381 | $progressBar1.Size = New-Object System.Drawing.Size(300, 25) 382 | $progressBar1.Style = 'Marquee' 383 | $progressBar1.Visible = $false 384 | $form.Controls.Add($progressBar1) 385 | 386 | $labelLoading = New-Object System.Windows.Forms.Label 387 | $labelLoading.Text = 'Loading' 388 | $labelLoading.ForeColor = 'White' 389 | $labelLoading.Location = New-Object System.Drawing.Point(350, 400) 390 | $labelLoading.AutoSize = $true 391 | $labelLoading.Font = New-Object System.Drawing.Font('Segoe UI', 13) 392 | $labelLoading.Visible = $false 393 | $form.Controls.Add($labelLoading) 394 | 395 | $openReg = New-Object System.Windows.Forms.Button 396 | $openReg.Text = 'Open in Registry' 397 | $openReg.Size = New-Object System.Drawing.Size(150, 28) 398 | try { 399 | $image = [System.Drawing.Image]::FromFile('Assets\Registry.png') 400 | #width,height 401 | $resizedImage = New-Object System.Drawing.Bitmap $image, 25, 19 402 | 403 | # Set the button image 404 | $openReg.Image = $resizedImage 405 | $openReg.ImageAlign = [System.Drawing.ContentAlignment]::MiddleLeft 406 | $openReg.TextImageRelation = [System.Windows.Forms.TextImageRelation]::ImageBeforeText 407 | } 408 | catch { 409 | Write-Host 'Missing Asset (Registry Icon)' -ForegroundColor Red 410 | } 411 | $openReg.ForeColor = 'White' 412 | $openReg.Location = New-Object System.Drawing.Point(280, 2) 413 | #add mouse over effect without using flat style 414 | $openReg.Add_MouseEnter({ 415 | $openReg.BackColor = [System.Drawing.Color]::FromArgb(64, 64, 64) 416 | }) 417 | 418 | $openReg.Add_MouseLeave({ 419 | $openReg.BackColor = [System.Drawing.Color]::FromArgb(43, 43, 42) 420 | }) 421 | $openReg.Add_Click({ 422 | $selected = Get-SelectedService 423 | if (!($selected)) { 424 | Write-Host 'No Service Selected...' 425 | } 426 | else { 427 | #close regedit if its open 428 | Stop-Process -Name regedit -Force -ErrorAction SilentlyContinue 429 | #open registry to first row selected 430 | #if array only has 1 item just use $selected 431 | if ($selected.Count -eq 1) { 432 | $Path = "HKLM\SYSTEM\ControlSet001\Services\$($selected)" 433 | } 434 | else { 435 | $Path = "HKLM\SYSTEM\ControlSet001\Services\$($selected[0])" 436 | } 437 | Set-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit' -Name Lastkey -Value $Path -Type String -Force 438 | Start-Process 'regedit.exe' 439 | } 440 | }) 441 | $form.Controls.Add($openReg) 442 | $openregtooltip = New-Object System.Windows.Forms.ToolTip 443 | $openregtooltip.Active | Out-Null 444 | $openregtooltip.SetToolTip($openReg, 'Open Service or Driver in Registry Editor') 445 | 446 | # Create the TextBox for search 447 | $searchBox = New-Object System.Windows.Forms.TextBox 448 | $searchBox.Location = New-Object System.Drawing.Point(60, 5) 449 | $searchBox.Size = New-Object System.Drawing.Size(150, 20) 450 | $form.Controls.Add($searchBox) 451 | 452 | # Add a TextChanged event to the TextBox 453 | $searchBox.add_TextChanged({ 454 | $dataTable.DefaultView.RowFilter = "DisplayName LIKE '%" + $searchBox.Text + "%' OR Name LIKE '%" + $searchBox.Text + "%'" 455 | }) 456 | 457 | # Create the PictureBox 458 | $pictureBox = New-Object System.Windows.Forms.PictureBox 459 | $pictureBox.Location = New-Object System.Drawing.Point(220, 5) 460 | $pictureBox.Size = New-Object System.Drawing.Size(30, 20) 461 | $pictureBox.SizeMode = [System.Windows.Forms.PictureBoxSizeMode]::Zoom 462 | $imagePath = 'Assets\Search.png' 463 | try { 464 | $image = [System.Drawing.Image]::FromFile($imagePath) 465 | } 466 | catch { 467 | Write-Host 'Missing Asset (Search Icon)' -ForegroundColor Red 468 | } 469 | $pictureBox.Image = $image 470 | $form.Controls.Add($pictureBox) 471 | 472 | 473 | # Create the DataGridView 474 | $Global:dataGridView = New-Object System.Windows.Forms.DataGridView 475 | $dataGridView.Location = New-Object System.Drawing.Point(-40, 30) 476 | $dataGridView.ReadOnly = $true 477 | $dataGridView.BackgroundColor = [System.Drawing.Color]::FromArgb(43, 43, 42) 478 | $dataGridView.ForeColor = 'White' 479 | $dataGridView.GridColor = [System.Drawing.Color]::FromArgb(64, 64, 64) 480 | $dataGridView.DefaultCellStyle.BackColor = [System.Drawing.Color]::FromArgb(43, 43, 42) 481 | $dataGridView.DefaultCellStyle.ForeColor = 'White' 482 | $dataGridView.DefaultCellStyle.SelectionBackColor = [System.Drawing.Color]::FromArgb(176, 176, 176) 483 | $dataGridView.DefaultCellStyle.SelectionForeColor = 'Black' 484 | $dataGridView.ColumnHeadersDefaultCellStyle.BackColor = [System.Drawing.Color]::FromArgb(64, 64, 64) 485 | $dataGridView.ColumnHeadersDefaultCellStyle.ForeColor = 'White' 486 | $dataGridView.RowHeadersDefaultCellStyle.BackColor = [System.Drawing.Color]::FromArgb(64, 64, 64) 487 | $dataGridView.RowHeadersDefaultCellStyle.ForeColor = 'White' 488 | $dataGridView.AlternatingRowsDefaultCellStyle.BackColor = [System.Drawing.Color]::FromArgb(64, 64, 64) 489 | $dataGridView.AlternatingRowsDefaultCellStyle.ForeColor = 'White' 490 | $dataGridView.ScrollBars = [System.Windows.Forms.ScrollBars]::Both 491 | $dataGridView.AllowUserToResizeColumns = $true 492 | $dataGridView.SelectionMode = [System.Windows.Forms.DataGridViewSelectionMode]::FullRowSelect 493 | 494 | $form.add_Resize({ 495 | # Adjust the DataGridView's size when the form is resized 496 | $dataGridView.Size = New-Object System.Drawing.Size(($form.Width + 25), ($form.Height - 70)) 497 | }) 498 | 499 | $form.Controls.Add($dataGridView) 500 | 501 | #add right click context menu 502 | $contextMenu = New-Object System.Windows.Forms.ContextMenuStrip 503 | $lookUpService = New-Object System.Windows.Forms.ToolStripMenuItem 504 | $lookUpService.Text = 'Look Up Service' 505 | try { 506 | $lookUpService.Image = [System.Drawing.Image]::FromFile('Assets\LookUp.png') 507 | } 508 | catch { 509 | Write-Host 'Missing Asset (Lookup Icon)' -ForegroundColor Red 510 | } 511 | $stop = New-Object System.Windows.Forms.ToolStripMenuItem 512 | $stop.Text = 'Stop' 513 | try { 514 | $stop.Image = [System.Drawing.Image]::FromFile('Assets\Stop.png') 515 | } 516 | catch { 517 | Write-Host 'Missing Asset (Stop Icon)' -ForegroundColor Red 518 | } 519 | $start = New-Object System.Windows.Forms.ToolStripMenuItem 520 | $start.Text = 'Start' 521 | try { 522 | $start.Image = [System.Drawing.Image]::FromFile('Assets\Start.png') 523 | } 524 | catch { 525 | Write-Host 'Missing Asset (Start Icon)' -ForegroundColor Red 526 | } 527 | $disable = New-Object System.Windows.Forms.ToolStripMenuItem 528 | $disable.Text = 'Disable' 529 | try { 530 | $disable.Image = [System.Drawing.Image]::FromFile('Assets\Disable.png') 531 | } 532 | catch { 533 | Write-Host 'Missing Asset (Disable Icon)' -ForegroundColor Red 534 | } 535 | $manual = New-Object System.Windows.Forms.ToolStripMenuItem 536 | $manual.Text = 'Manual' 537 | try { 538 | $manual.Image = [System.Drawing.Image]::FromFile('Assets\Manual.png') 539 | } 540 | catch { 541 | Write-Host 'Missing Asset (Manual Icon)' -ForegroundColor Red 542 | } 543 | $auto = New-Object System.Windows.Forms.ToolStripMenuItem 544 | $auto.Text = 'Automatic' 545 | try { 546 | $auto.Image = [System.Drawing.Image]::FromFile('Assets\Auto.png') 547 | } 548 | catch { 549 | Write-Host 'Missing Asset (Automatic Icon)' -ForegroundColor Red 550 | } 551 | $Global:system = New-Object System.Windows.Forms.ToolStripMenuItem 552 | $system.Text = 'System' 553 | $system.Visible = $false 554 | try { 555 | $system.Image = [System.Drawing.Image]::FromFile('Assets\System.png') 556 | } 557 | catch { 558 | Write-Host 'Missing Asset (System Icon)' -ForegroundColor Red 559 | } 560 | $Global:boot = New-Object System.Windows.Forms.ToolStripMenuItem 561 | $boot.Text = 'Boot' 562 | $boot.Visible = $false 563 | try { 564 | $boot.Image = [System.Drawing.Image]::FromFile('Assets\Boot.png') 565 | } 566 | catch { 567 | Write-Host 'Missing Asset (Boot Icon)' -ForegroundColor Red 568 | } 569 | $contextMenu.Items.Add($lookUpService) | Out-Null 570 | $contextMenu.Items.Add($stop) | Out-Null 571 | $contextMenu.Items.Add($start) | Out-Null 572 | $contextMenu.Items.Add($disable) | Out-Null 573 | $contextMenu.Items.Add($manual) | Out-Null 574 | $contextMenu.Items.Add($auto) | Out-Null 575 | $contextMenu.Items.Add($boot) | Out-Null 576 | $contextMenu.Items.Add($system) | Out-Null 577 | $dataGridView.ContextMenuStrip = $contextMenu 578 | 579 | # Handle the MouseDown event to show the context menu only when a row is selected 580 | $dataGridView.add_MouseDown({ 581 | param($sender, $e) 582 | if ($e.Button -eq [System.Windows.Forms.MouseButtons]::Right) { 583 | $hitTestInfo = $dataGridView.HitTest($e.X, $e.Y) 584 | if ($hitTestInfo.RowIndex -ge 0) { 585 | #$dataGridView.ClearSelection() 586 | $dataGridView.Rows[$hitTestInfo.RowIndex].Selected = $true 587 | $contextMenu.Show($dataGridView, $e.Location) 588 | } 589 | } 590 | }) 591 | 592 | $lookUpService.Add_Click({ 593 | $selectedServices = Get-SelectedService 594 | if ($selectedServices.Count -gt 1) { 595 | foreach ($service in $selectedServices) { 596 | Start-Process "https://www.google.com/search?q=$service" 597 | } 598 | } 599 | else { 600 | Start-Process "https://www.google.com/search?q=$selectedServices" 601 | } 602 | }) 603 | 604 | $stop.Add_Click({ 605 | Invoke-Expression -Command "Stop-SelectedService -$Mode" 606 | }) 607 | 608 | $start.Add_Click({ 609 | Invoke-Expression -Command "Start-SelectedService -$Mode" 610 | }) 611 | 612 | $manual.Add_Click({ 613 | Invoke-Expression -Command "Set-Manual -$Mode" 614 | }) 615 | 616 | $auto.Add_Click({ 617 | Invoke-Expression -Command "Set-Automatic -$Mode" 618 | }) 619 | 620 | $disable.Add_Click({ 621 | Invoke-Expression -Command "Set-Disabled -$Mode" 622 | }) 623 | 624 | $system.Add_Click({ 625 | Set-System 626 | }) 627 | 628 | $boot.Add_Click({ 629 | Set-Boot 630 | }) 631 | function addDriversToGrid { 632 | # Retrieve the driver data 633 | $driversPlus = Get-DriverPlus 634 | 635 | # Convert the data to a DataTable 636 | $Global:dataTable = New-Object System.Data.DataTable 637 | $columnNames = $driversPlus[0].PSObject.Properties.Name 638 | foreach ($name in $columnNames) { 639 | $dataTable.Columns.Add($name) | Out-Null 640 | } 641 | foreach ($driver in $driversPlus) { 642 | $row = $dataTable.NewRow() 643 | $rows = $driver.PSObject.Properties 644 | foreach ($r in $rows) { 645 | $row[$r.Name] = $driver.$($r.Name) 646 | } 647 | $dataTable.Rows.Add($row) | Out-Null 648 | } 649 | 650 | # Bind the DataTable to the DataGridView 651 | $dataGridView.DataSource = $dataTable 652 | 653 | #set autosize mode for each column 654 | $dataGridView.Columns['DisplayName'].AutoSizeMode = [System.Windows.Forms.DataGridViewAutoSizeColumnsMode]::AllCells 655 | $dataGridView.Columns['Name'].AutoSizeMode = [System.Windows.Forms.DataGridViewAutoSizeColumnsMode]::AllCells 656 | $dataGridView.Columns['Status'].AutoSizeMode = [System.Windows.Forms.DataGridViewAutoSizeColumnsMode]::AllCells 657 | $dataGridView.Columns['StartType'].AutoSizeMode = [System.Windows.Forms.DataGridViewAutoSizeColumnsMode]::AllCells 658 | $dataGridView.Columns['BinaryPath'].AutoSizeMode = [System.Windows.Forms.DataGridViewAutoSizeColumnsMode]::AllCells 659 | 660 | } 661 | 662 | 663 | function addServicesToGrid { 664 | # Retrieve the service data 665 | $servicesPlus = Get-ServicePlus 666 | 667 | # Convert the data to a DataTable 668 | $Global:dataTable = New-Object System.Data.DataTable 669 | $columnNames = $servicesPlus[0].PSObject.Properties.Name 670 | foreach ($name in $columnNames) { 671 | $dataTable.Columns.Add($name) | Out-Null 672 | } 673 | foreach ($service in $servicesPlus) { 674 | $row = $dataTable.NewRow() 675 | $rows = $service.PSObject.Properties 676 | foreach ($r in $rows) { 677 | $row[$r.Name] = $service.$($r.Name) 678 | } 679 | $dataTable.Rows.Add($row) | Out-Null 680 | } 681 | 682 | # Bind the DataTable to the DataGridView 683 | $dataGridView.DataSource = $dataTable 684 | 685 | #set autosize mode for each column 686 | $dataGridView.Columns['DisplayName'].AutoSizeMode = [System.Windows.Forms.DataGridViewAutoSizeColumnsMode]::None 687 | $dataGridView.Columns['Name'].AutoSizeMode = [System.Windows.Forms.DataGridViewAutoSizeColumnsMode]::None 688 | $dataGridView.Columns['Status'].AutoSizeMode = [System.Windows.Forms.DataGridViewAutoSizeColumnsMode]::None 689 | $dataGridView.Columns['StartType'].AutoSizeMode = [System.Windows.Forms.DataGridViewAutoSizeColumnsMode]::None 690 | $dataGridView.Columns['DependentService(s)'].AutoSizeMode = [System.Windows.Forms.DataGridViewAutoSizeColumnsMode]::None 691 | $dataGridView.Columns['BinaryPath'].AutoSizeMode = [System.Windows.Forms.DataGridViewAutoSizeColumnsMode]::None 692 | $dataGridView.Columns['Description'].AutoSizeMode = [System.Windows.Forms.DataGridViewAutoSizeColumnsMode]::AllCells 693 | 694 | #set custom width 695 | $dataGridView.Columns['DisplayName'].Width = 230 696 | $dataGridView.Columns['Name'].Width = 170 697 | $dataGridView.Columns['Status'].Width = 80 698 | $dataGridView.Columns['StartType'].Width = 80 699 | $dataGridView.Columns['DependentService(s)'].Width = 200 700 | $dataGridView.Columns['BinaryPath'].Width = 200 701 | 702 | } 703 | addServicesToGrid 704 | 705 | # Create the label 706 | $label = New-Object System.Windows.Forms.Label 707 | $label.Text = 'Set Service:' 708 | $label.ForeColor = 'White' 709 | $label.Location = New-Object System.Drawing.Point(470, 5) 710 | $label.AutoSize = $true 711 | $label.Font = New-Object System.Drawing.Font('Segoe UI', 10) 712 | $form.Controls.Add($label) 713 | 714 | $refreshGrid = New-Object System.Windows.Forms.Button 715 | $refreshGrid.Text = 'View Services' 716 | $refreshGrid.Size = New-Object System.Drawing.Size(90, 30) 717 | $refreshGrid.Location = New-Object System.Drawing.Point(50, 2) 718 | $refreshGrid.ForeColor = 'White' 719 | $refreshGrid.Add_Click({ 720 | #$dataGridView.Rows.Clear() 721 | $dataGridView.Columns.Clear() 722 | $dataGridView.Refresh() 723 | $boot.Visible = $false 724 | $system.Visible = $false 725 | $progressBar1.Visible = $true 726 | $labelLoading.Visible = $true 727 | addServicesToGrid 728 | $labelLoading.Visible = $false 729 | $progressBar1.Visible = $false 730 | $dataGridView.Refresh() 731 | $dataGridView.ClearSelection() 732 | 733 | }) 734 | $refreshGrid.Add_MouseEnter({ 735 | $refreshGrid.BackColor = [System.Drawing.Color]::FromArgb(64, 64, 64) 736 | }) 737 | 738 | $refreshGrid.Add_MouseLeave({ 739 | $refreshGrid.BackColor = [System.Drawing.Color]::FromArgb(43, 43, 42) 740 | }) 741 | $refreshGrid.Anchor = [System.Windows.Forms.AnchorStyles]::Top -bor [System.Windows.Forms.AnchorStyles]::Right 742 | $form.Controls.Add($refreshGrid) 743 | $viewServicestooltip = New-Object System.Windows.Forms.ToolTip 744 | $viewServicestooltip.Active | Out-Null 745 | $viewServicestooltip.SetToolTip($refreshGrid, 'Refreshes Service List') 746 | 747 | $viewDrivers = New-Object System.Windows.Forms.Button 748 | $viewDrivers.Text = 'View Drivers' 749 | $viewDrivers.Size = New-Object System.Drawing.Size(90, 30) 750 | $viewDrivers.Location = New-Object System.Drawing.Point(150, 2) 751 | $viewDrivers.ForeColor = 'White' 752 | $viewDrivers.Add_Click({ 753 | $Global:Mode = 'driver' 754 | $system.Visible = $true 755 | $boot.Visible = $true 756 | #$dataGridView.Rows.Clear() 757 | $dataGridView.Columns.Clear() 758 | $dataGridView.Refresh() 759 | $progressBar1.Visible = $true 760 | $labelLoading.Visible = $true 761 | addDriversToGrid 762 | $labelLoading.Visible = $false 763 | $progressBar1.Visible = $false 764 | $dataGridView.Refresh() 765 | $dataGridView.ClearSelection() 766 | 767 | }) 768 | $viewDrivers.Add_MouseEnter({ 769 | $viewDrivers.BackColor = [System.Drawing.Color]::FromArgb(64, 64, 64) 770 | }) 771 | 772 | $viewDrivers.Add_MouseLeave({ 773 | $viewDrivers.BackColor = [System.Drawing.Color]::FromArgb(43, 43, 42) 774 | }) 775 | $viewDrivers.Anchor = [System.Windows.Forms.AnchorStyles]::Top -bor [System.Windows.Forms.AnchorStyles]::Right 776 | $form.Controls.Add($viewDrivers) 777 | $viewdriverstooltip = New-Object System.Windows.Forms.ToolTip 778 | $viewdriverstooltip.Active | Out-Null 779 | $viewdriverstooltip.SetToolTip($viewDrivers, 'Refreshes Driver List') 780 | 781 | 782 | $exportMenu = New-Object System.Windows.Forms.Button 783 | $exportMenu.Size = New-Object System.Drawing.Size(40, 30) 784 | $exportMenu.Location = New-Object System.Drawing.Point(3, 2) 785 | $exportMenu.ForeColor = 'White' 786 | $exportMenu.FlatStyle = [System.Windows.Forms.FlatStyle]::Flat 787 | $exportMenu.FlatAppearance.BorderSize = 0 788 | #$exportMenu.FlatAppearance.MouseOverBackColor = [System.Drawing.Color]::FromArgb(62, 62, 64) 789 | #$exportMenu.FlatAppearance.MouseDownBackColor = [System.Drawing.Color]::FromArgb(27, 27, 28) 790 | try { 791 | $image = [System.Drawing.Image]::FromFile('Assets\Menu.png') 792 | 793 | $resizedImage = New-Object System.Drawing.Bitmap $image, 25, 19 794 | 795 | # Set the button image 796 | $exportMenu.Image = $resizedImage 797 | $exportMenu.ImageAlign = [System.Drawing.ContentAlignment]::MiddleCenter 798 | } 799 | catch { 800 | Write-Host 'Missing Asset (Menu Icon)' -ForegroundColor Red 801 | } 802 | 803 | $exportMenu.Add_Click({ 804 | $exportContextMenu.Show($exportMenu, 0, $exportMenu.Height) 805 | }) 806 | $form.Controls.Add($exportMenu) 807 | $exportMenutooltip = New-Object System.Windows.Forms.ToolTip 808 | $exportMenutooltip.Active | Out-Null 809 | $exportMenutooltip.SetToolTip($exportMenu, 'Export Services or Drivers in REG Format') 810 | 811 | 812 | $exportContextMenu = New-Object System.Windows.Forms.ContextMenuStrip 813 | $form.ContextMenuStrip = $exportContextMenu 814 | # Add menu items to the context menu strip 815 | $exportServices = New-Object System.Windows.Forms.ToolStripMenuItem 816 | $exportServices.Text = 'Export Services' 817 | $exportContextMenu.Items.Add($exportServices) | Out-Null 818 | $exportServices.Add_Click({ 819 | $folderBrowser = New-Object System.Windows.Forms.FolderBrowserDialog 820 | $folderBrowser.Description = 'Select a Destination' 821 | $folderBrowser.RootFolder = [System.Environment+SpecialFolder]::Desktop 822 | $folderBrowser.ShowNewFolderButton = $true 823 | 824 | # Show the dialog and get the selected folder 825 | $result = $folderBrowser.ShowDialog() 826 | 827 | if ($result -eq [System.Windows.Forms.DialogResult]::OK) { 828 | $selectedFolder = $folderBrowser.SelectedPath 829 | } 830 | #build reg file 831 | $key = 'HKLM\SYSTEM\ControlSet001\Services' 832 | $header = 'Windows Registry Editor Version 5.00' 833 | New-Item -Path $selectedFolder -Name 'ServicesBackup.reg' -Force | Out-Null 834 | Add-Content -Path "$selectedFolder\ServicesBackup.reg" -Value $header -Force 835 | $regContent = '' 836 | foreach ($row in $dataGridView.Rows) { 837 | $name = $row.Cells[1].Value 838 | if ($null -ne $name) { 839 | $startValue = Get-ItemPropertyValue -Path "registry::$key\$name" -Name 'Start' 840 | $regContent += "[$key\$name] `n" + "`"Start`"=dword:0000000$($startValue)`n `n" 841 | } 842 | } 843 | Add-Content -Path "$selectedFolder\ServicesBackup.reg" -Value $regContent -Force 844 | }) 845 | 846 | $exportDrivers = New-Object System.Windows.Forms.ToolStripMenuItem 847 | $exportDrivers.Text = 'Export Drivers' 848 | $exportContextMenu.Items.Add($exportDrivers) | Out-Null 849 | $exportDrivers.Add_Click({ 850 | $folderBrowser = New-Object System.Windows.Forms.FolderBrowserDialog 851 | $folderBrowser.Description = 'Select a Destination' 852 | $folderBrowser.RootFolder = [System.Environment+SpecialFolder]::Desktop 853 | $folderBrowser.ShowNewFolderButton = $true 854 | 855 | # Show the dialog and get the selected folder 856 | $result = $folderBrowser.ShowDialog() 857 | 858 | if ($result -eq [System.Windows.Forms.DialogResult]::OK) { 859 | $selectedFolder = $folderBrowser.SelectedPath 860 | } 861 | #build reg file 862 | $key = 'HKLM\SYSTEM\ControlSet001\Services' 863 | $header = 'Windows Registry Editor Version 5.00' 864 | New-Item -Path $selectedFolder -Name 'DriversBackup.reg' -Force | Out-Null 865 | Add-Content -Path "$selectedFolder\DriversBackup.reg" -Value $header -Force 866 | $regContent = '' 867 | foreach ($row in $dataGridView.Rows) { 868 | $name = $row.Cells[1].Value 869 | if ($null -ne $name) { 870 | $startValue = Get-ItemPropertyValue -Path "registry::$key\$name" -Name 'Start' 871 | $regContent += "[$key\$name] `n" + "`"Start`"=dword:0000000$($startValue)`n `n" 872 | } 873 | } 874 | Add-Content -Path "$selectedFolder\DriversBackup.reg" -Value $regContent -Force 875 | }) 876 | 877 | $stopService = New-Object System.Windows.Forms.Button 878 | $stopService.Text = 'Stop Service' 879 | $stopService.Size = New-Object System.Drawing.Size(90, 30) 880 | $stopService.Location = New-Object System.Drawing.Point(860, 2) 881 | $stopService.ForeColor = 'White' 882 | $stopService.Add_Click({ 883 | Invoke-Expression -Command "Stop-SelectedService -$Mode" 884 | }) 885 | $stopService.Add_MouseEnter({ 886 | $stopService.BackColor = [System.Drawing.Color]::FromArgb(64, 64, 64) 887 | }) 888 | 889 | $stopService.Add_MouseLeave({ 890 | $stopService.BackColor = [System.Drawing.Color]::FromArgb(43, 43, 42) 891 | }) 892 | $form.Controls.Add($stopService) 893 | $stopServicetooltip = New-Object System.Windows.Forms.ToolTip 894 | $stopServicetooltip.Active | Out-Null 895 | $stopServicetooltip.SetToolTip($stopService, 'Stop Selected Service(s) or Driver(s)') 896 | 897 | $startService = New-Object System.Windows.Forms.Button 898 | $startService.Text = 'Start Service' 899 | $startService.Size = New-Object System.Drawing.Size(90, 30) 900 | $startService.Location = New-Object System.Drawing.Point(950, 2) 901 | $startService.ForeColor = 'White' 902 | $startService.Add_Click({ 903 | Invoke-Expression -Command "Start-SelectedService -$Mode" 904 | }) 905 | $startService.Add_MouseEnter({ 906 | $startService.BackColor = [System.Drawing.Color]::FromArgb(64, 64, 64) 907 | }) 908 | 909 | $startService.Add_MouseLeave({ 910 | $startService.BackColor = [System.Drawing.Color]::FromArgb(43, 43, 42) 911 | }) 912 | $form.Controls.Add($startService) 913 | $startServicetooltip = New-Object System.Windows.Forms.ToolTip 914 | $startServicetooltip.Active | Out-Null 915 | $startServicetooltip.SetToolTip($startService, 'Start Selected Service(s) or Driver(s)') 916 | 917 | 918 | # Create the buttons 919 | $manualButton = New-Object System.Windows.Forms.Button 920 | $manualButton.Text = 'Manual' 921 | $manualButton.Size = New-Object System.Drawing.Size(90, 30) 922 | $manualButton.Location = New-Object System.Drawing.Point(550, 2) 923 | $manualButton.ForeColor = 'White' 924 | $manualButton.Add_MouseEnter({ 925 | $manualButton.BackColor = [System.Drawing.Color]::FromArgb(64, 64, 64) 926 | }) 927 | 928 | $manualButton.Add_MouseLeave({ 929 | $manualButton.BackColor = [System.Drawing.Color]::FromArgb(43, 43, 42) 930 | }) 931 | $form.Controls.Add($manualButton) 932 | $manualButtontooltip = New-Object System.Windows.Forms.ToolTip 933 | $manualButtontooltip.Active | Out-Null 934 | $manualButtontooltip.SetToolTip($manualButton, 'Set Selected Service(s) or Driver(s) to Manual') 935 | 936 | $automaticButton = New-Object System.Windows.Forms.Button 937 | $automaticButton.Text = 'Automatic' 938 | $automaticButton.Size = New-Object System.Drawing.Size(90, 30) 939 | $automaticButton.Location = New-Object System.Drawing.Point(650, 2) 940 | $automaticButton.ForeColor = 'White' 941 | $automaticButton.Add_MouseEnter({ 942 | $automaticButton.BackColor = [System.Drawing.Color]::FromArgb(64, 64, 64) 943 | }) 944 | 945 | $automaticButton.Add_MouseLeave({ 946 | $automaticButton.BackColor = [System.Drawing.Color]::FromArgb(43, 43, 42) 947 | }) 948 | $form.Controls.Add($automaticButton) 949 | $automaticButtontooltip = New-Object System.Windows.Forms.ToolTip 950 | $automaticButtontooltip.Active | Out-Null 951 | $automaticButtontooltip.SetToolTip($automaticButton, 'Set Selected Service(s) or Driver(s) to Automatic') 952 | 953 | $disabledButton = New-Object System.Windows.Forms.Button 954 | $disabledButton.Text = 'Disabled' 955 | $disabledButton.Size = New-Object System.Drawing.Size(90, 30) 956 | $disabledButton.Location = New-Object System.Drawing.Point(750, 2) 957 | $disabledButton.ForeColor = 'White' 958 | $disabledButton.Add_MouseEnter({ 959 | $disabledButton.BackColor = [System.Drawing.Color]::FromArgb(64, 64, 64) 960 | }) 961 | 962 | $disabledButton.Add_MouseLeave({ 963 | $disabledButton.BackColor = [System.Drawing.Color]::FromArgb(43, 43, 42) 964 | $disabledButtontooltip.Hide($disabledButton) 965 | }) 966 | $form.Controls.Add($disabledButton) 967 | $disabledButtontooltip = New-Object System.Windows.Forms.ToolTip 968 | $disabledButtontooltip.Active | Out-Null 969 | $disabledButtontooltip.SetToolTip($disabledButton, 'Set Selected Service(s) or Driver(s) to Disabled') 970 | 971 | 972 | $manualButton.Add_Click({ 973 | Invoke-Expression -Command "Set-Manual -$Mode" 974 | }) 975 | 976 | $automaticButton.Add_Click({ 977 | Invoke-Expression -Command "Set-Automatic -$Mode" 978 | }) 979 | 980 | $disabledButton.Add_Click({ 981 | Invoke-Expression -Command "Set-Disabled -$Mode" 982 | }) 983 | 984 | 985 | #remove first row selection 986 | $form.Add_Shown({ 987 | $dataGridView.ClearSelection() 988 | }) 989 | 990 | # Show the form 991 | [void]$form.ShowDialog() 992 | --------------------------------------------------------------------------------