0

I have the following script setup to change an environment variable (Mirus_Active_Directory) when I press Win+i. It works fine in Windows 7, but does not seem to work on Windows 10.

How can I modify the code to make it work with Windows 10?

Thanks

SetTitleMatchMode RegEx
return

#IfWinActive ahk_class ExploreWClass
    #i::
    SetPath()
    return
#IfWinActive ahk_class CabinetWClass
    #i::
        SetPath()
    return
#IfWinActive


; Opens the command shell 'cmd' in the directory browsed in Explorer.
; Note: expecting to be run when the active window is Explorer.
;
SetPath()
{
    ; This is required to get the full path of the file from the address bar
    WinGetText, full_path, A

    ; Split on newline (`n)
    StringSplit, word_array, full_path, `n
    ; Take the first element from the array
    full_path = %word_array1%   

    ; strip to bare address
    full_path := RegExReplace(full_path, "^Address: ", "")

    ; Just in case - remove all carriage returns (`r)
    StringReplace, full_path, full_path, `r, , all


    IfInString full_path, \
    {
        RegWrite, REG_SZ, HKEY_LOCAL_MACHINE, SYSTEM\CurrentControlSet\Control\Session Manager\Environment, Mirus_Active_Directory, %full_path%\
        RegWrite, REG_SZ, HKEY_LOCAL_MACHINE, SYSTEM\ControlSet001\Control\Session Manager\Environment, Mirus_Active_Directory, %full_path%\
    EnvUpdate
    }
}
  • Try to [run the script as adminisrator](https://stackoverflow.com/questions/43298908/how-to-add-administrator-privileges-to-autohotkey-script/43299069#43299069). – user3419297 Jun 12 '17 at 16:27
  • I've set AutoHotKey to run as admin, but it hasn't helped. – TechZombie Jun 14 '17 at 16:18

0 Answers0