Skip to content

Instantly share code, notes, and snippets.

@favoyang
Created August 7, 2022 02:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save favoyang/15dba8e30e78befbcfda94f461e104a8 to your computer and use it in GitHub Desktop.
Save favoyang/15dba8e30e78befbcfda94f461e104a8 to your computer and use it in GitHub Desktop.
The PowerShell script to restart TdxW processes
$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