Created
August 7, 2022 02:36
-
-
Save favoyang/15dba8e30e78befbcfda94f461e104a8 to your computer and use it in GitHub Desktop.
The PowerShell script to restart TdxW processes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$processes = Get-Process TdxW | |
foreach($process in $processes) | |
{ | |
write-host Restarting: $process.MainWindowTitle | |
#Get the process details | |
$procID = $process.Id | |
$cmdline = (Get-WMIObject Win32_Process -Filter "Handle=$procID").CommandLine | |
# Kill and wait | |
$process.Kill() | |
$process.WaitForExit() | |
# Restart | |
$args = $cmdline.Split(' ') | |
if ($args[1]) | |
{ | |
Start-Process -FilePath $args[0] -ArgumentList $args[1] | |
} | |
else | |
{ | |
Start-Process -FilePath $args[0] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment