win10 设置侧载默认程序之借尸还魂 —— ahk 命令行转接脚本,ahk成为命令行拨号员

最近发现无法设置explorer的默认打开方式了,原来能设置成某一路径,使用绿色软件或者portable很方便,现在只能从安装好的程序中选择。这难道是微软在推广应用商店的举措?

反正编辑器里的聊天机器人说是的,我就相信了:

win10 设置侧载默认程序之借尸还魂 —— ahk 命令行转接脚本,ahk成为命令行拨号员_第1张图片

win10 设置侧载默认程序之借尸还魂 —— ahk 命令行转接脚本,ahk成为命令行拨号员_第2张图片

以前能选择路径的,现在只能选安装好的程序。

怎么办的,辛辛苦苦开发出来的媒体播放器,上传商店还要交700年费……

聊天机器人给出的解决方案是这样的:

 However, this behavior can be disabled by modifying a registry key.

To disable this behavior, you can follow these steps:

Open the Registry Editor by pressing Windows + R, typing "regedit", and pressing Enter.
Navigate to the following key: HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\CloudContent
If the "CloudContent" key does not exist, create it by right-clicking on the "Windows" key, selecting "New", and then selecting "Key". Name the new key "CloudContent".
Create a new DWORD value under the "CloudContent" key by right-clicking on the key, selecting "New", and then selecting "DWORD (32-bit) Value". Name the new value "DisableWindowsConsumerFeatures".
Double-click on the "DisableWindowsConsumerFeatures" value and set its data to 1.
Close the Registry Editor and restart your computer.
After following these steps, you should be able to set side-loaded EXE programs as the default program without being prompted to use the Microsoft Store. However, please note that modifying the registry can be dangerous and may cause system instability if done incorrectly. Make sure to back up your registry before making any changes.

修改注册表,没试过成不成功。

其实可以利用ahk“借尸还魂”之法,将已安装的程序干掉,变成自己的程序。方法如下:

  1. 写一个ahk脚本,功能是,接收命令行参数,并以相同参数启动自己的player.exe

  2. 将ahk脚本编译成run.exe。

  3. 将将媒体文件默认发开方式设置成potplyer

  4. 干掉potplayer.exe,用run.exe替换,将run.exe重命名为potplayer.exe!

这个ahk脚本也是问机器人得到的,一行没改:

; Get the command line arguments
CommandLine := DllCall("GetCommandLine", "str")
DllCall("ole32\CoInitialize", "ptr", 0)
VarSetCapacity(Args, 32768, 0)
DllCall("shell32\CommandLineToArgvW", "wstr", CommandLine, "ptr", &Args)
Loop % A_Args.Length()
{
    Arg := A_Args[A_Index]
    If InStr(Arg, " ")
    {
        Arg := Chr(34) . Arg . Chr(34)
    }
    Arguments .= Arg . " "
}
; 消息(Arguments)


; Launch D:/play.exe with the same arguments
Run, D:\Code\FigureOut\Textrument\plugins\DirectUILib\WODPlayer\bin\WODPlayer.exe %Arguments%


你可能感兴趣的:(编译奇兵,microsoft,windows,ahk)