DanysysTeam / PS-SFTA

PowerShell Set File Type Association
253 stars 53 forks source link

Get-PTA don't seem to work #4

Closed mikhoul closed 3 years ago

mikhoul commented 3 years ago

Hi,

I register FTP protocole with Brave and from the return it seem to work BUT when I go in the settings App to confirm that Brave is now handling the FTP protocol there is no application assigned to the FTP protocol ?

Note: It's also the same with others protocols I try to assign to Brave browser.

image

Is it a bug or I do something wrong ? 🤔

Regards :octocat:

mikhoul commented 3 years ago

Same thing happen with Set-FTA and .txt extension:

image

Note: It's on Windows 10 20H2 64bit

If you need more information just ask me.

Regards :octocat:

Danyfirex commented 3 years ago

Hello @mikhoul does it not work with any file type? Could you try with .pdf and some known application ID.

Regards

mikhoul commented 3 years ago

Hello @mikhoul does it not work with any file type?

It seem to work with some application like VLC but it's confusing to know which apps work and which app don't work.

It's look like some app don't always use the same "AppUserModelID", they add some dynamic suffix at the end of the AppID like Brave.

Other like 7-Zip even in non-portable mode don't register themselve so you can't use AppID

Right Now for Brave the Brave ID for me is BraveHTML.4REM7IDKMEVI3XQNOHIXWXUYFE .

image

The way appID and files associations are handled doesn't seem consistent at all, some app installer use a way, another use other means and on the Top of that MSFT reset sometime the Files association settings. 😵

So when I use the usual ID Set-FTA BraveHTML .website -v it don't work it change the Icon and remove the original application and set it to "unknow app"

Look here to understand better, Only the Icon is changed and the default app is removed and changed to unknow.

image

If I use Set-FTA BraveHTML.4REM7IDKMEVI3XQNOHIXWXUYFE .website -v it work:

image

From my experimentation last night to register a protocol with Brave the best way for is: Register-FTA "C:\Users\Utilisateur\AppData\Local\BraveSoftware\Brave-Browser\Application\brave.exe" ftp -v


For App that we are 100% sure of the APP ID and thet the ID is static we could use SetFTA but for app that don't have appID, have Dynamic ID generated by Windows or have ID suffix that change every few months it's better to register them with Register-FTA sinice it will always point to the exe,


It would be great if we could use Env Variables since we could use it portable batch files, we would not have to care for the root Win Installation Folder or User folder.

Being able to use %PROGRAMFILES%, %PROGRAMFILES(X86)%, %LOCALAPPDATA% and %HOMEPATH% would be a must for portable batch files.

Register-FTA "C:\Users\Utilisateur\AppData\Local\BraveSoftware\Brave-Browser\Application\brave.exe" ftp -v = WORK

Register-FTA "%LOCALAPPDATA%\BraveSoftware\Brave-Browser\Application\brave.exe" ftp -v -= DON'T WORK

It could be a PowerShell function that could internally translate the variables in "real path" to write to the registry.

Maybe @faraq2 would be interested by this discussion since it integrate SFTA.ps1 in his Sophia script.

Best Regards :octocat:

farag2 commented 3 years ago

Maybe @faraq2

@farag2 :)

Danyfirex commented 3 years ago

SFTA was written with the intention that each person knows the id of the application to be used. In case you don't know it, you need to research what id it uses. The code does what it should do, if you need more compatibility you must create your own additional function to find the correct id of the application, because it would be difficult to add complementary functions for a large number of applications (although it may be possible to add some known or maybe some functions to try to achieve it). But for now I don't want to modify the main concept of the code. I think it is better for each person to add their complementary function. Regarding environment variables PowerShell supports environment variables in this form $env:LOCALAPPDATA so I think it is not necessary to add what you suggest, anyway if you need to run from batch files you can do it this way to support batch's environment variables.

powershell -ExecutionPolicy Bypass -command ". .\SFTA.ps1; Register-FTA  -ProgramPath '%programfiles(x86)%\SumatraPDF-3.1.2\SumatraPDF.exe' -Extension '.pdf'"

Regards

farag2 commented 3 years ago

But according to https://github.com/DanysysTeam/PS-SFTA/blob/5c7623043add4ffe23af0e807609989add0e2d1a/SFTA.ps1#L108 you cannot test if path exists via

Test-Path -Path "%programfiles(x86)%"

PowerShell doesnt cannot interpret the batch syntax.

Danyfirex commented 3 years ago

@farag2 I know about that. but I think @mikhoul was asking about supporting batch environment variables as I wrote above. anyway If you will work with only PowerShell $env: is the way to go.

mikhoul commented 3 years ago

if you need to run from batch files you can do it this way to support batch's environment variables.

Thanks it will work this way for batch files. :octocat: