Forum Discussion
wrkmpls
Nov 18, 2020Copper Contributor
default app script
I am wanting to automate the association of one file type with its default app, using a Windows-10 PowerShell script. I can do it in Settings manually without difficulty, and my .au3 scripts run fine:
The path to the .exe is: C:\Users\{Username}\AppData\Local\Temp\sayit_shortcuts\SayItAutoIt.exe
However, if I run PS cmdlets to accomplish this, they don't give error messages but they also do not change the association. To test this, I first manually changed the above association in Settings to "Notepad"
To troubleshoot, I tried the native commands in CMD:
-----------------------------------------
ASSOCIATE THE EXTENSION WITH THE FILE TYPE:
C:\Users\wk>assoc au3=AutoIt3Script
au3=AutoIt3Script
CONFIRM:
C:\Users\wk>assoc .au3
.au3=AutoIt3Script
ASSOCIATE THE FILE TYPE WITH THE APPLICATION:
C:\Users\wk>ftype AutoIt3Script="C:\Users\wk\AppData\Local\Temp\sayit_shortcuts\SayItAutoIt.exe" "%1"
AutoIt3Script="C:\Users\wk\AppData\Local\Temp\sayit_shortcuts\SayItAutoIt.exe" "%1"
CONFIRM:
C:\Users\wk>ftype AutoIt3Script
AutoIt3Script="C:\Users\wk\AppData\Local\Temp\sayit_shortcuts\SayItAutoIt.exe" "%1"
-----------------------------------------
HOWEVER, my scripts do not run...instead they just open in Notepad because Settings has not changed:
When run in PS with these cmdlets, the same results are obtained (the association in Settings does not change from Notepad)
cmd /c assoc .au3=AutoItV3Script
cmd /c ftype AutoItV3Script="C:\Users\wk\AppData\Local\Temp\sayit_shortcuts\SayItAutoIt.exe" "%1"
Thank you for any suggestions.
- farismalaebSteel Contributor
Can you share your code,
I tried the code you wrote down and it works as expected.
are you running these commands from Powershell.
C:\windows\system32\cmd.exe /c assoc .....