$exePath = "C:\Program Files\EPSON Projector\Epson iProjection\EMP_MPP.exe" $folder = Split-Path -Path $exePath -Parent $batPath = Join-Path -Path $folder -ChildPath "Restart_EMP_MPP.bat" # 1. Generate the zero-UAC kill-and-relaunch .bat file $batContent = @" @echo off powershell -NoProfile -ExecutionPolicy Bypass -Command "Get-Process -Name 'EMP_MPP' -ErrorAction SilentlyContinue | ForEach-Object { `$_.Kill() }" timeout /t 1 /nobreak >nul start "" "$exePath" "@ Set-Content -Path $batPath -Value $batContent -Encoding ASCII -Force Write-Host "Created batch file: $batPath" -ForegroundColor Cyan # 2. Scan Desktop, OneDrive Desktop, and Start Menu folders and update shortcuts $shell = New-Object -ComObject WScript.Shell $dirs = @( [Environment]::GetFolderPath("Desktop"), [Environment]::GetFolderPath("CommonDesktopDirectory"), [Environment]::GetFolderPath("StartMenu"), [Environment]::GetFolderPath("CommonStartMenu"), "$env:USERPROFILE\OneDrive\Desktop" ) | Select-Object -Unique $updatedCount = 0 foreach ($dir in $dirs) { if (Test-Path $dir) { Get-ChildItem -Path $dir -Filter "*.lnk" -Recurse -ErrorAction SilentlyContinue | ForEach-Object { $lnk = $shell.CreateShortcut($_.FullName) if ($lnk.TargetPath -like "*Epson iProjection*" -or $_.Name -like "*iProjection*") { $lnk.TargetPath = $batPath $lnk.Arguments = "" $lnk.WorkingDirectory = $folder $lnk.IconLocation = "$exePath,0" $lnk.WindowStyle = 7 $lnk.Save() Write-Host "Updated shortcut: $($_.FullName)" -ForegroundColor Green $updatedCount++ } } } } if ($updatedCount -eq 0) { Write-Host "No matching shortcuts were found in standard Desktop or Start Menu paths." -ForegroundColor Yellow }