Question

  • Creator
    Topic
  • #4086466

    How to use PowerShell to switch default app (from pre-determined list)?

    by panes-rubrics ·

    I frequently switch App to open PDFs and wish for shortcut. Without Admin Right, can PowerShell Script change default App from pre-determined list:

    (1) Open PowerShell Window
    (2) Show current Default
    (3) Press Enter if OK
    (4) Press Spacebar (non-graphical interface) to show next App in List
    (5) Press Enter to change Default
    (6) Above Script to show in Windows 10 Taskbar

    As-Is, because Word is my only Enterprise Translation tool for PDF, it is very cumbersome for Word (when not default App) to open PDF.

    Note: irrelevant link removed by moderator.

    • This topic was modified 1 year, 7 months ago by Avatar photokees_b.
    • This topic was modified 1 year, 7 months ago by Avatar photokees_b.

You are posting a reply to: How to use PowerShell to switch default app (from pre-determined list)?

The posting of advertisements, profanity, or personal attacks is prohibited. Please refer to our Community FAQs for details. All submitted content is subject to our Terms of Use.

All Answers

  • Author
    Replies
    • #4086660
      Avatar photo

      Reply To: How to use PowerShell to switch default app (from pre-determined list)?

      by kees_b ·

      In reply to How to use PowerShell to switch default app (from pre-determined list)?

      To choose the not default app to open the file I use right click>Open with in File Explorer to select the program I want to use. It lets me choose from a list. I don’t see the need for a more cumbersome way like you propose.

      • This reply was modified 1 year, 7 months ago by Avatar photokees_b.
      • This reply was modified 1 year, 7 months ago by Avatar photokees_b.
    • #4086755

      Reply To: How to use PowerShell to switch default app (from pre-determined list)?

      by JosephMack26 ·

      In reply to How to use PowerShell to switch default app (from pre-determined list)?

      You can use PowerShell to switch the default app from a predetermined list by using the Set-ItemProperty cmdlet to modify the registry keys that control file associations. Here’s an example script to set the default app for a particular file type:

      $extension = “.txt” # Change this to the file extension you want to modify
      $appPath = “C:\Windows\System32\notepad.exe” # Change this to the path of the app you want to set as default

      # Set the default app for the file extension
      Set-ItemProperty -Path “HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\$extension\UserChoice” -Name “ProgId” -Value “Applications\$appPath”

      # Refresh the shell to apply the changes
      $null = (New-Object -ComObject Shell.Application).Namespace(0).ParseName(“file.$extension”).InvokeVerb(“OpenWith”)
      Note: This script modifies the registry, so be sure to back up your registry or create a system restore point before running it.

      In this script, replace the $extension variable with the file extension you want to modify (e.g., “.txt”, “.docx”, etc.). Replace the $appPath variable with the path to the app you want to set as default (e.g., “C:\Program Files\Microsoft Office\root\Office16\WINWORD.EXE” for Microsoft Word).

      The script uses the Set-ItemProperty cmdlet to modify the “ProgId” value of the file extension’s UserChoice key in the registry. This value specifies the default app for the file type. The script then uses the New-Object cmdlet to create a Shell.Application object and refreshes the shell to apply the changes. This ensures that the changes take effect immediately.

      Once you run this script, the specified app should become the default app for the file type you specified.

Viewing 1 reply thread