Jump to content

windows 10 how do i Restart and Install Updates


larksp
 Share

Recommended Posts

Windows 10 .... I have tried shutdown (6) force restart     this does Not install windows update but does restart
also tried cmd shutdown with \g with couple of other flags  again does not install the updates...

 

second question for windows 7 that for long time not found an answer for
this might be windows 7 bug as w10 and xp dont have this issue
*(Newly installed PC)* with updates as well

set power settings powercfg monitor timeout from 20 (default) to 0 ac and dc

normally this takes a few *restarts* before it will actually Work

ShellExecuteWait('powercfg.exe', '-change -monitor-timeout-ac 0', '', '', @SW_HIDE)
    ShellExecuteWait('powercfg.exe', '-change -monitor-timeout-dc 0', '', '', @SW_HIDE)
    ShellExecuteWait('powercfg.exe', '-change -standby-timeout-ac 0', '', '', @SW_HIDE)
    ShellExecuteWait('powercfg.exe', '-change -standby-timeout-dc 0', '', '', @SW_HIDE)


iv not tried the registry way as is hex and i dont know how

i do also set a screen saver just the picture slide show to 60mins

Edited by larksp
to add OS to first question
Link to comment
Share on other sites

You can modify to your liking and then export the power profile, and import later.

See powercfg parameters

POWERCFG -getactivescheme
POWERCFG -export "C:\Users\careca\Desktop\On.pow" 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635d
pause

you have to match the Id in the export cmd with the active one, else the file will be empty.

EDIT: Just letting you know i decided to start working in something to deal with these profiles, export is outputting files with zero bytes.

Here's what i got so far:

#Region ;Wrapper
;#RequireAdmin ;Disables Console
Local $Title = "Power Profiles"
#pragma compile(UPX, false)
#pragma compile(CompanyName, '')
#pragma compile(ProductVersion, 1.0)
#pragma compile(FileVersion, 1.0)
#pragma compile(x64, false)
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_UseX64=n
#AutoIt3Wrapper_ShowProgress=y
#AutoIt3Wrapper_Res_SaveSource=y
#AutoIt3Wrapper_Res_Fileversion=1.0
;#AutoIt3Wrapper_Icon=
;#AutoIt3Wrapper_Res_Icon_Add=
;#AutoIt3Wrapper_Outfile=
;#AutoIt3Wrapper_Res_Comment=
;#AutoIt3Wrapper_Res_Description=
#Autoit3Wrapper_Testing=y
#AutoIt3Wrapper_Run_Tidy=y
#AutoIt3Wrapper_Run_AU3Check=y
#AutoIt3Wrapper_Run_Debug_Mode=n
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=y
#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7
#EndRegion ;Wrapper
;=============================================================================
#Region ;FileInstall
Local $aProcessList = ProcessList(@AutoItPID)
If $aProcessList[0][1] >= 2 Then Exit
;=============================================================================
If StringInStr($cmdlineRaw, "/source") Then
    FileInstall("Power Profiles.au3", @ScriptDir & "\Power Profiles.au3", 1)
    Exit
EndIf
#EndRegion ;FileInstall
;=============================================================================
#Region ;Includes
#include <Misc.au3>
#include <File.au3>
#include <Array.au3>
#include <WinAPI.au3>
#include <String.au3>
#include <Timers.au3>
#include <GuiEdit.au3>
#include <GDIPlus.au3>
#include <WinAPIEx.au3>
#include <WinAPISys.au3>
#include <GuiButton.au3>
#include <Constants.au3>
#include <GuiSlider.au3>
#include <WinAPISys.au3>
#include <WinAPIMisc.au3>
#include <GuiToolTip.au3>
#include <GUIListBox.au3>
#include <GuiListView.au3>
#include <GuiStatusBar.au3>
#include <GUIConstants.au3>
#include <GuiImageList.au3>
#include <TrayConstants.au3>
#include <FileConstants.au3>
#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <APISysConstants.au3>
#include <MsgBoxConstants.au3>
#include <StaticConstants.au3>
#include <SliderConstants.au3>
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>
#include <ListViewConstants.au3>
#EndRegion ;Includes
;=============================================================================
#Region ;Opt
OnAutoItExitRegister("Quit")
Opt("TrayMenuMode", 1)
Opt("TrayIconHide", 0)
Opt("GUICoordMode", 1)
Opt("GUIResizeMode", 1)
Opt("TrayIconDebug", 1)
Opt("TrayAutoPause", 0)
Opt("MouseCoordMode", 2)
Opt("GUIOnEventMode", 1)
Opt("MustDeclareVars", 0)
Opt("GUIEventOptions", 1)
Opt("TrayOnEventMode", 1)
Opt("ExpandEnvStrings", 1)
Opt("WinTitleMatchMode", 2)
Opt("WinDetectHiddenText", 1)
#EndRegion ;Opt
;=============================================================================
#Region ;Vars ;Gui
Local $GUI, $totray, $restore, $exititem, $WinState
Global $getname, $begin, $dif, $Read, $Str, $Splt, $SpltStr
Global $ContextMenu, $Duplicate, $GetLTLV, $GetItemTxt, $NameP, $Save

$GUI = GUICreate($Title, 500, 300, -1, -1)
GUISetState()
TraySetState(1)
TraySetClick(16)
$WinState = 1

Local $ListView = GUICtrlCreateListView('GUID|Name', 10, 10, 480, 200)

GUICtrlCreateButton("Scan", 10, 220)
GUICtrlSetOnEvent(-1, "Read")

$ContextMenu = GUICtrlCreateContextMenu($ListView)
$Duplicate = GUICtrlCreateMenuItem("Duplicate", $ContextMenu, 1)
GUICtrlSetOnEvent(-1, "Duplicate")
GUICtrlCreateMenuItem("Active", $ContextMenu, 2)
GUICtrlSetOnEvent(-1, "Active")
GUICtrlCreateMenuItem("Delete profile", $ContextMenu, 3)
GUICtrlSetOnEvent(-1, "Delete")
GUICtrlCreateMenuItem("Export profile", $ContextMenu, 3)
GUICtrlSetOnEvent(-1, "Export")

GUISetIcon("C:\Windows\System32\imageres.dll,498")
TraySetIcon("C:\Windows\System32\imageres.dll,498")

TraySetOnEvent($TRAY_EVENT_PRIMARYDOUBLE, "Window")
GUISetOnEvent($GUI_EVENT_CLOSE, "Quit")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "Minimize")
GUISetOnEvent($GUI_EVENT_RESTORE, "Restore")

$totray = TrayCreateItem("Tray")
TrayItemSetOnEvent(-1, "ToTray")
$restore = TrayCreateItem("Restore")
TrayItemSetOnEvent(-1, "RestoreT")
$exititem = TrayCreateItem("Close")
TrayItemSetOnEvent(-1, "Quit")
#EndRegion ;Vars ;Gui
Read()
;=============================================================================
Do ;Loop
    Sleep(100)
Until GUIGetMsg() = $GUI_EVENT_CLOSE
;=============================================================================
Func Read()
    Clear()
    $getname = Run('cmd', '', @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD);@SW_HIDE
    $begin = TimerInit()
    Do
        $dif = TimerDiff($begin)
        $Read = StdoutRead($getname, True, False)
        $Str = StringInStr($Read, 'Microsoft', 1)
        Sleep(100)
        If $dif >= 3000 Then ExitLoop
    Until $Str <> 0
    StdinWrite($getname, "powercfg.exe /list" & @CRLF)
    $begin = TimerInit()
    Do
        $dif = TimerDiff($begin)
        $Read = StdoutRead($getname, True, False)
        $Read = StringTrimRight($Read, 24)
        $Str = StringInStr($Read, 'Existing Power Schemes', 1)
        $Splt = StringSplit($Read, 'Power Scheme GUID: ', 1)
        Sleep(100)
        If $dif >= 3000 Then ExitLoop
    Until $Str <> 0
    For $t = 2 To $Splt[0]
        $SpltStr = StringSplit($Splt[$t], ' (', 1)
        If StringInStr($SpltStr[2], '*', 1) Then
        GUICtrlCreateListViewItem($SpltStr[1]&'|'&'('&$SpltStr[2]&'<Active', $ListView)
        Else
        GUICtrlCreateListViewItem($SpltStr[1]&'|'&'('&$SpltStr[2], $ListView)
        EndIf
        GUICtrlSendMsg($ListView, $LVM_SETCOLUMNWIDTH, 0, -1)
        GUICtrlSendMsg($ListView, $LVM_SETCOLUMNWIDTH, 1, -1)
    Next
EndFunc
;=============================================================================
Func Duplicate()
$GetLTLV = _GUICtrlListView_GetNextItem($ListView, -1, 0, 8)
$GetItemTxt = _GUICtrlListView_GetItemText($ListView, $GetLTLV, 0)
Run('powercfg.exe /duplicatescheme '&$GetItemTxt)
Read()
EndFunc
;=============================================================================
Func Active()
$GetLTLV = _GUICtrlListView_GetNextItem($ListView, -1, 0, 8)
$GetItemTxt = _GUICtrlListView_GetItemText($ListView, $GetLTLV, 0)
Run('powercfg.exe /setactive '&$GetItemTxt)
Read()
EndFunc
;=============================================================================
Func Delete()
$GetLTLV = _GUICtrlListView_GetNextItem($ListView, -1, 0, 8)
$GetItemTxt = _GUICtrlListView_GetItemText($ListView, $GetLTLV, 0)
Run('powercfg.exe /delete '&$GetItemTxt)
Read()
EndFunc
;=============================================================================
Func Export()
$NameP = InputBox('Profile name', 'What should be the profile name?', 'MyProfile')
If Not @Error Then
$Save = FileSaveDialog('Profile Export', '', 'PowerProfiles (*.pow)', 2, $NameP)
If Not @Error Then
$GetLTLV = _GUICtrlListView_GetNextItem($ListView, -1, 0, 8)
$GetItemTxt = _GUICtrlListView_GetItemText($ListView, $GetLTLV, 0)
MsgBox(64, '', 'powercfg.exe /export "'&$Save&'" '&$GetItemTxt)
Run('powercfg.exe /export '&$Save&' '&$GetItemTxt)
EndIf
EndIf
EndFunc
;=============================================================================
Func Clear()
    _GUICtrlListView_DeleteAllItems($ListView)
EndFunc   ;==>Clear
;=============================================================================
#Region ;Window Operations
Func Window()
    If $WinState = 0 Then
        GUISetState(@SW_SHOW, $GUI)
        $WinState = 1
    Else
        GUISetState(@SW_HIDE, $GUI)
        $WinState = 0
    EndIf
EndFunc   ;==>Window
;=============================================================================
Func ToTray()
    TrayItemSetState($totray, $TRAY_UNCHECKED)
    GUISetState(@SW_HIDE)
    $WinState = 0
EndFunc   ;==>ToTray
;=============================================================================
Func RestoreT()
    TrayItemSetState($restore, $TRAY_UNCHECKED)
    GUISetState(@SW_SHOW)
    $WinState = 1
EndFunc   ;==>RestoreT
;=============================================================================
Func Minimize()
    WinSetState($GUI, '', @SW_MINIMIZE)
EndFunc   ;==>Minimize
;=============================================================================
Func Restore()
    WinSetState($GUI, '', @SW_RESTORE)
EndFunc   ;==>Restore
;=============================================================================
Func Quit()
    Exit
EndFunc   ;==>Quit
#EndRegion ;Window Operations
;=============================================================================

Work in progress, more functions to add, but i think, for the actual tweak in the settings themselves, i'll leave windows do it.

Edited by careca
Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

Added import, now all works, check context menu for operations.

All this just to show it's possible to export a profile with all definitions you want.

I noticed that in order to do some operations i needed #requireadmin

maybe if you add that to your code, it works and you don't need to do anything else.

Edited by careca
Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

i had a look at the code and at least I can learn from it... so that's good..

as my issue is after I have reinstalled a Windows 7...... i change setting rebooting and change setting rebooting till the monitor-timeout works
(windows 10 and xp did not have this issue SO FAR as I have noticed)
in windows "Control Panel\Hardware and Sound\Power Options\Edit Plan Settings"   It does Display as Never but still turns Screen off after 20mins

1) first copy/dup the (High Performance) to its own guid              2) give it a name            3) change the settings
Maybe First changing the settings of (High Performance) then copy/dup  (only the monitor timeout from 20mins to 0 (Never)

i would have to test that on fresh installed pc's next week sometime to see if that works  (might take awhile)
Also your option export a working POW profile and then import
(this may take a while to see if either works as i reinstalled w7 computers)

Link to comment
Share on other sites

Is there a cmd to install the updates? i was thinking you could write a script that would run the updates uppon next start.

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

i been using https://msdn.microsoft.com/en-us/library/windows/desktop/aa387102(v=vs.85).aspx

but an autoit version taken from that i then added in reg to start program after reboot and not ask for admin  so it will carry on with downloading updates and rebooting works for windows 7 shutdown(6)  when finished removes start up and re enables ask for admin

in windows 10 it reboots but does not install as it reboots....  The code   =    shutdown (6)         ----   as in force a restart

i also tried open cmd and typed in few of the dos shutdown commands after doing      shutdown ?    to find the switches  as in shutdown /r /t 01 or what ever

ps i do most windows update with wsus but it does not get them all   

in windows 10 when i click the power it gives shutdown restart and 2 extra restart and install or shutdown and install.. was hoping for just a simple dos or autoit command that could just restart and install

i am still googling for an answer :)

Edited by larksp
Link to comment
Share on other sites

setting the SCHEME_MIN monitor timeout before DUPLICATESCHEME seemed to work so far anyway 2 pc tested more next week....

no luck on the win10 restart with updates.. but maybe my w10 pc windows update date settings are messed up.. i did not see

HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU .. but then is it on all w10 ill have to check with another i guess

Link to comment
Share on other sites

Mine has that key. and inside there is: NoAutoRebootWithLoggedOnUsers - DWORD - 1

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

monitor timeout still working well so i guess that problem is fixed .. thanks Careca for the Help.

i did have to reinstall that computer the windows 10 updates was missing stuff from all over the place..
I have not had any windows 10  computers to test out weather shutdown(6) will update and restart..
If it does not i guess setting schedule them some how  and restarting would

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...