default app script

%3CLINGO-SUB%20id%3D%22lingo-sub-1901876%22%20slang%3D%22en-US%22%3Edefault%20app%20script%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1901876%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20wanting%20to%20automate%20the%20association%201%20file%20type%20with%20its%20default%20app%2C%20using%20a%20Windows-10%20PowerShell%20script.%26nbsp%3B%20I%20can%20do%20it%20in%20Settings%20manually%20without%20difficulty.%3C%2FP%3E%3CP%3EFile%20type%20%3D%20.au3%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20App%20%3D%20SayItAutoIt.exe%3C%2FP%3E%3CP%3EThe%20path%20to%20the%20.exe%20is%3A%26nbsp%3B%20C%3A%5CUsers%5C%7BUsername%7D%5CAppData%5CLocal%5CTemp%5Csayit_shortcuts%5CSayItAutoIt.exe%3C%2FP%3E%3CP%3EThis%20Powershell%20command%20line%20does%20nothing%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ecmd%20%2Fc%20ftype%20.au3%3D%24env%3AUSERPROFILE%20%2B%20%22%5CAppData%5CLocal%5CTemp%5Csayit_shortcuts%5CSayItAutoIt.exe%22%20%22%251%22%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20for%20any%20suggestions.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1901876%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EWindows%20PowerShell%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Occasional Visitor

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:

wrkmpls_0-1605796357125.png

 

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:

wrkmpls_1-1605797173388.png

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.

1 Reply

@wrkmpls 

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 .....