For months I've been trying to run a script on user login that defaults Adobe Reader 11 as the default viewer for pdf files. The problem is that every time you reboot or login to an account, Windows 10 forces Edge Browser as the default pdf viewer. There is absolutely no fix for this atm. I've tried Group Policy's File Association XML, .bat, .cmd, .vbs, powershell scripts involving reg edits and file type associations using ftype, but no avail. Windows 10 is a mess. The only real way to switch the default pdf viewer during a login session is via the control panel. And so I turn to AutoIt to automate this on every client machine (more than 100) upon their account login to solve this.
I'm halfway through the solution with:
#include <MsgBoxConstants.au3>
#include <GUIListView.au3>
Opt("WinTitleMatchMode", 4)
run("explorer.exe shell:::{17cd9488-1228-4b2f-88ce-4298e93e0966} -Microsoft.DefaultPrograms\pageDefaultProgram")
sleep(4000)
$hWnd = ControlGetHandle("Set Default Programs","","SysListView321")
;need a case, if, or loop to go through the first 10 indexes
;and select the index number matching selection text of "Adobe Reader XI"
;example, select 3rd item in the list (index starts with 0)
_GUICtrlListView_SetItemSelected($hWnd, 2)
;only the index number matching the required selection text should be selected
sleep(1000)
;lines below not working... need to select button "Set this program as default"
$hWnd = ControlGetHandle("Set Default Programs","[CLASS:Button; INSTANCE:1]")
ControlClick("Button", "&Set this program as default")
The script opens up the "Set Default Programs" windows in Control Panel, then handles the selection item box on the left. I'm able to select items based on their index number, however this is not good to use directly it will be different between each computer. Some computers have Adobe Reader 11 as the third, others as the first.
Does anyone know what scripting is required to select an item based upon the text it contains? Maybe via a loop, if statement, or case statement which filters the first 10 index numbers and passes a true value or sets the index value to select for the item containing the desired text. That way the correct item is selected.
Lastly, I wasn't able to hit the button "Set this program as default". I'm still very new...
Thank you so much.