I want a desktop shortcut that runs three device-management commands in order: enable my GPU device, wait for that operation to finish, disable it, and then enable it again. I already have separate shortcuts that run the enable and disable commands successfully, but I cannot combine them into one sequential shortcut. The device instance ID is `PCIVEN_1002&DEV_73DF&SUBSYS_52101849&REV_C56&399090B&0&00000019`. My GPU regularly crashes, and cycling the device this way is the only workaround that currently helps.
2 Answers
Put the commands in a PowerShell script instead of trying to chain separate shortcut targets. Save this as something like `Reset-GPU.ps1`:
```powershell
$id = 'PCIVEN_1002&DEV_73DF&SUBSYS_52101849&REV_C56&399090B&0&00000019'
Enable-PnpDevice -InstanceId $id -Confirm:$false
Start-Sleep -Seconds 2
Disable-PnpDevice -InstanceId $id -Confirm:$false
Start-Sleep -Seconds 2
Enable-PnpDevice -InstanceId $id -Confirm:$false
```
Then create a shortcut with `powershell.exe` as the program and this as the argument:
```text
-ExecutionPolicy Bypass -File "C:PathToReset-GPU.ps1"
```
The pauses are optional, but they give Windows time to finish each device change before the next command runs. The shortcut may need to run with administrator privileges because these cmdlets modify hardware devices.
A batch file can also launch one PowerShell command, but a `.ps1` script is cleaner for this. If you use a batch file, call PowerShell once and place the commands in a single `-Command` block. Also make sure the instance ID uses normal ampersands (`&`), not the HTML text `&`, and quote the ID exactly as shown. Run the shortcut as administrator or the enable/disable operations may fail.

That makes sense. I was trying to put the full PowerShell executable command on every line instead of putting the commands inside one script.