Advertisement
mgis90

ChromeUpdates.ahk

Feb 10th, 2016
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;---------------------------------------------
  2. ; ChromeUpdates.ahk
  3. ; Enable or disable Google Chrome updates.
  4. ; adapted to AutoHotkey by Mgis
  5. ; based on SetChromeUpdates.ps1 version by Jared M. Smith 2015.04.xx
  6. ; https://gist.github.com/absynce/7667bd32e632e72f406f
  7. ;---------------------------------------------
  8. MsgBox,% 3+256,What to do?,Enable Chrome Updates? Choosing No will disable them.
  9. IfMsgBox,cancel
  10.     return
  11. IfMsgBox,yes
  12.     decision:=true
  13. IfMsgBox,no
  14.     decision:=false
  15.  
  16. if SetChromeUpdates(decision)
  17.     MsgBox,,Done,Settings applied successfully,3
  18. else
  19.     MsgBox,,Failed,Settings could not be applied,3
  20. return ;autoexec
  21.  
  22.  
  23. SetChromeUpdates(allowChromeUpdates:=false)
  24. {
  25.     if (!allowChromeUpdates)
  26.         updateText := "Disabling"
  27.     else
  28.         updateText := "Enabling"
  29.     ;no need for Enable/disable Chrome updates integer value
  30.     notAllowChromeUpdates := !allowChromeUpdates
  31.  
  32.     Log(updateText . " Google Chrome updates.")
  33.  
  34.     RegWrite, REG_DWORD, HKLM, SOFTWARE\Policies\Google,, %allowChromeUpdates%          ;this will set default value
  35.     RegWrite, REG_DWORD, HKLM, SOFTWARE\Policies\Google, Update, %allowChromeUpdates%   ;this will set Update value
  36.  
  37.     RegWrite, REG_DWORD, HKLM, SOFTWARE\Policies\Google\Update,, %allowChromeUpdates%   ;this will set default value
  38.     RegWrite, REG_DWORD, HKLM, SOFTWARE\Policies\Google\Update, AutoUpdateCheckPeriodMinutes, %allowChromeUpdates%
  39.     RegWrite, REG_DWORD, HKLM, SOFTWARE\Policies\Google\Update, DisableAutoUpdateChecksCheckboxValue, %notAllowChromeUpdates%
  40.     RegWrite, REG_DWORD, HKLM, SOFTWARE\Policies\Google\Update, Update{8A69D345-D564-463C-AFF1-A69D9E530F96}, %allowChromeUpdates%
  41.     RegWrite, REG_DWORD, HKLM, SOFTWARE\Policies\Google\Update, UpdateDefault, %allowChromeUpdates%
  42.  
  43.     Log("Added registry keys for " . updateText . " Google updates.")
  44.  
  45.     if (allowChromeUpdates) {
  46.         RunWait,%comspec% /c "net start gupdate",,hide
  47.         RunWait,%comspec% /c "net start gupdatem",,hide
  48.         Log("Attempted to start Google update services(s).")
  49.     } else {
  50.         RunWait,%comspec% /c "net stop gupdate",,hide
  51.         RunWait,%comspec% /c "net stop gupdatem",,hide
  52.         Log("Stopped Google update services(s).")
  53.     }
  54.     return true
  55. }
  56.  
  57.  
  58. Log(str)
  59. {
  60.     static s
  61.     s.=str . "`n"
  62.     ToolTip,%s%
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement