Solved Batch file for auto pause Windows Update on boot


EnvioX

Key Keeper
Member
Hello all

i try to create bat file and i use task scheduler to set auto suspend/pause status windows UPDATE only (store and defender def update from defender update still working).

but it's look something wrong that i can find the problem.

anyone here can help me how to make it work?

my primary goal are:

Everytime Laptop Reboot or first logon the script will run and pause windows update +7 days from the date that the script run

Fh2bkLlNbH.png


thankyou
 

Attachments

  • pendingupdate.bat
    1.4 KB · Views: 4

My Computer

System One

  • OS
    Windows 11 Pro 23h2 22631.2792
    Computer type
    Laptop
    Manufacturer/Model
    Toshiba Ultrabook Portege Z830 PT224L-01402S
    CPU
    Intel(R) Core(TM) i7-2677M CPU @ 1.80GHz
    Motherboard
    Portable PC (0x000003EC - 0x103CB030)
    Memory
    6,00 GB (5,90 GB usable)
    Graphics Card(s)
    Intel(R) HD Graphics 3000
    Sound Card
    USB Generic
    Monitor(s) Displays
    Built-in Laptop
    Screen Resolution
    1366x768
    Hard Drives
    Toshiba THNSNB128GMCJ 128GB PCI-E M-SATA INTERNAL Solid State Drive(SSD)
    Keyboard
    Using USB Port K120
    Mouse
    Using USB Port
    Internet Speed
    Broadband 50 Mb/s
    Browser
    Edge Stable Only
    Antivirus
    Microsoft Defender Only
    Other Info
    Screenshot Apps: Snipping Tools || I Try to use Everything from Microsoft Product
Have you tried manually changing those Registry Keys to find out if they have the expected effect?

Sometimes a change made through the user interface might change a Registry Key but the same change made directly in the Registry Key
- Might not be shown in the user interface,
- Might not have the expected effect,
- Might have the expected effect and be shown in the user interface.,
- Might have the expected effect even though it is not shown in the user interface.
The only way to find out is to try it.


All the best,
Denis
 

My Computer

System One

  • OS
    Windows 11 Home x64 Version 23H2 Build 22631.3447
Have you tried manually changing those Registry Keys to find out if they have the expected effect?

Sometimes a change made through the user interface might change a Registry Key but the same change made directly in the Registry Key
- Might not be shown in the user interface,
- Might not have the expected effect,
- Might have the expected effect and be shown in the user interface.,
- Might have the expected effect even though it is not shown in the user interface.
The only way to find out is to try it.


All the best,
Denis
it work if i changed it manually,

basically I took the added points when I pressed the suspend button for 1 week from the windows panel and I exported it. then i test via .reg file. and it works. but it doesn't work well when I want to put it in a batch file with the aim that every login then a suspend update will occur
 

My Computer

System One

  • OS
    Windows 11 Pro 23h2 22631.2792
    Computer type
    Laptop
    Manufacturer/Model
    Toshiba Ultrabook Portege Z830 PT224L-01402S
    CPU
    Intel(R) Core(TM) i7-2677M CPU @ 1.80GHz
    Motherboard
    Portable PC (0x000003EC - 0x103CB030)
    Memory
    6,00 GB (5,90 GB usable)
    Graphics Card(s)
    Intel(R) HD Graphics 3000
    Sound Card
    USB Generic
    Monitor(s) Displays
    Built-in Laptop
    Screen Resolution
    1366x768
    Hard Drives
    Toshiba THNSNB128GMCJ 128GB PCI-E M-SATA INTERNAL Solid State Drive(SSD)
    Keyboard
    Using USB Port K120
    Mouse
    Using USB Port
    Internet Speed
    Broadband 50 Mb/s
    Browser
    Edge Stable Only
    Antivirus
    Microsoft Defender Only
    Other Info
    Screenshot Apps: Snipping Tools || I Try to use Everything from Microsoft Product
This batch script makes a few wrong assumptions. Every month doesn't have the same days (31), and you forgot about leap years.

1. Using "date /t" can fail if someone has a different MM-DD or DD-MM date format. "wmic os get LocalDateTime" will always return the date in the same format, no matter what is your local date setting.

2. The correct way to do future (or past) dates is to convert to Julian format (based on absolute calendar days), add 7 days, and convert back to calendar date. I found a Stack Overflow answer which has the equations in BATCH.

3. This is much easier in another scripting language like PowerShell or VBScript, which have date functions.

Screenshot 2023-08-05 095235.png
 

Attachments

  • pendingupdate.bat
    1.9 KB · Views: 5

My Computer

System One

  • OS
    Windows 7
This batch script makes a few wrong assumptions. Every month doesn't have the same days (31), and you forgot about leap years.

1. Using "date /t" can fail if someone has a different MM-DD or DD-MM date format. "wmic os get LocalDateTime" will always return the date in the same format, no matter what is your local date setting.

2. The correct way to do future (or past) dates is to convert to Julian format (based on absolute calendar days), add 7 days, and convert back to calendar date. I found a Stack Overflow answer which has the equations in BATCH.

3. This is much easier in another scripting language like PowerShell or VBScript, which have date functions.

View attachment 66890
thankyou for your reply... yeah i just found about the date and the leap ^_^..... i just test it to run every day. not thinking about the month or year yet...
and thankyou for your script. i will test it.... (and thankyou for the link stackoverflow... i will test it... and i will update here soon...

about using ps1.... i never play ps1. but i will try convert the logic to ps1 after try your script
 

My Computer

System One

  • OS
    Windows 11 Pro 23h2 22631.2792
    Computer type
    Laptop
    Manufacturer/Model
    Toshiba Ultrabook Portege Z830 PT224L-01402S
    CPU
    Intel(R) Core(TM) i7-2677M CPU @ 1.80GHz
    Motherboard
    Portable PC (0x000003EC - 0x103CB030)
    Memory
    6,00 GB (5,90 GB usable)
    Graphics Card(s)
    Intel(R) HD Graphics 3000
    Sound Card
    USB Generic
    Monitor(s) Displays
    Built-in Laptop
    Screen Resolution
    1366x768
    Hard Drives
    Toshiba THNSNB128GMCJ 128GB PCI-E M-SATA INTERNAL Solid State Drive(SSD)
    Keyboard
    Using USB Port K120
    Mouse
    Using USB Port
    Internet Speed
    Broadband 50 Mb/s
    Browser
    Edge Stable Only
    Antivirus
    Microsoft Defender Only
    Other Info
    Screenshot Apps: Snipping Tools || I Try to use Everything from Microsoft Product
not working, i think the solution only play with powershell.....

i will need to learn ps then

thankyou to all

but if anyone know how to made it... please .... sent me the script, so i can learn from it
 

My Computer

System One

  • OS
    Windows 11 Pro 23h2 22631.2792
    Computer type
    Laptop
    Manufacturer/Model
    Toshiba Ultrabook Portege Z830 PT224L-01402S
    CPU
    Intel(R) Core(TM) i7-2677M CPU @ 1.80GHz
    Motherboard
    Portable PC (0x000003EC - 0x103CB030)
    Memory
    6,00 GB (5,90 GB usable)
    Graphics Card(s)
    Intel(R) HD Graphics 3000
    Sound Card
    USB Generic
    Monitor(s) Displays
    Built-in Laptop
    Screen Resolution
    1366x768
    Hard Drives
    Toshiba THNSNB128GMCJ 128GB PCI-E M-SATA INTERNAL Solid State Drive(SSD)
    Keyboard
    Using USB Port K120
    Mouse
    Using USB Port
    Internet Speed
    Broadband 50 Mb/s
    Browser
    Edge Stable Only
    Antivirus
    Microsoft Defender Only
    Other Info
    Screenshot Apps: Snipping Tools || I Try to use Everything from Microsoft Product

My Computer

System One

  • OS
    Windows 11 Pro 23h2 22631.2792
    Computer type
    Laptop
    Manufacturer/Model
    Toshiba Ultrabook Portege Z830 PT224L-01402S
    CPU
    Intel(R) Core(TM) i7-2677M CPU @ 1.80GHz
    Motherboard
    Portable PC (0x000003EC - 0x103CB030)
    Memory
    6,00 GB (5,90 GB usable)
    Graphics Card(s)
    Intel(R) HD Graphics 3000
    Sound Card
    USB Generic
    Monitor(s) Displays
    Built-in Laptop
    Screen Resolution
    1366x768
    Hard Drives
    Toshiba THNSNB128GMCJ 128GB PCI-E M-SATA INTERNAL Solid State Drive(SSD)
    Keyboard
    Using USB Port K120
    Mouse
    Using USB Port
    Internet Speed
    Broadband 50 Mb/s
    Browser
    Edge Stable Only
    Antivirus
    Microsoft Defender Only
    Other Info
    Screenshot Apps: Snipping Tools || I Try to use Everything from Microsoft Product
With all the hate and discontent that MS updates cause, and have for decades, why don't you just shut OFF updates?
Life would be so much simpler! When you get a bad update that takes down your computer, you'll wish you'd listened to me.

As a working PC tech, in my own business, I've taken many service calls on PC's that were totally disabled by an MS update.
I just won't allow them on any PC of mine (12), and I never have a problem from a BAD update.

Good luck,
TM :cool:
 

My Computer

System One

  • OS
    Win-11/Pro/64, Optimum 11 V5, 23H2 22631.3374
    Computer type
    PC/Desktop
    Manufacturer/Model
    Home Made w/Gigabyte mobo/DX-10
    CPU
    AMD FX 6350 Six Core
    Motherboard
    Gigabyte, DX-10, GA-78LMT-USB3
    Memory
    Crucial, 16 GB
    Graphics Card(s)
    NVIDEA GeForce 210, 1GB DDR3 Ram.
    Sound Card
    Onboard
    Monitor(s) Displays
    24" Acer
    Screen Resolution
    1280x800
    Hard Drives
    Crucial SSD 500GB, SanDisk 126GB SSD, Toshiba 1TB HD
    PSU
    EVGA 500 W.
    Case
    Pac Man, Mid Tower
    Cooling
    AMD/OEM
    Keyboard
    101 key, Backlit/ Mechanical Switches/
    Mouse
    Logitech USB Wireless M310
    Internet Speed
    Hughes Net speed varies with the weather
    Browser
    Firefox 64x
    Antivirus
    Windows Defender, Super Anti Spyware
    Other Info
    Given to me as DEAD, and irreparable.
    Rebuilt with Gigabyte mobo, AMD cpu, 16GB ram and 500GB Crucial SSD.
With all the hate and discontent that MS updates cause, and have for decades, why don't you just shut OFF updates?
Life would be so much simpler! When you get a bad update that takes down your computer, you'll wish you'd listened to me.

As a working PC tech, in my own business, I've taken many service calls on PC's that were totally disabled by an MS update.
I just won't allow them on any PC of mine (12), and I never have a problem from a BAD update.

Good luck,
TM :cool:
i use some APP that need ms store update. and i still use defender.... i can disable 100% winupdate/store/remove defender completly but i still use ms store and i trust to use defender.

i wont let security update from windows update :D because i think sometimes ms put some "tricky script on it to make lagging or else) (i hope im wrong) ( iwas 100% fanatic lightweight AV like panda,comodo,kav... but defender better )

and i will update windows if i think the update will work find with my unsupported w11 laptop (test on VHD boot not for daily.. after some weeks. i will update the real OS). ( i will backup with macrium first) at least threads and handles will decreased without broken the system ^_^

so when i get "deadly update" i can restore with easy way....
 

My Computer

System One

  • OS
    Windows 11 Pro 23h2 22631.2792
    Computer type
    Laptop
    Manufacturer/Model
    Toshiba Ultrabook Portege Z830 PT224L-01402S
    CPU
    Intel(R) Core(TM) i7-2677M CPU @ 1.80GHz
    Motherboard
    Portable PC (0x000003EC - 0x103CB030)
    Memory
    6,00 GB (5,90 GB usable)
    Graphics Card(s)
    Intel(R) HD Graphics 3000
    Sound Card
    USB Generic
    Monitor(s) Displays
    Built-in Laptop
    Screen Resolution
    1366x768
    Hard Drives
    Toshiba THNSNB128GMCJ 128GB PCI-E M-SATA INTERNAL Solid State Drive(SSD)
    Keyboard
    Using USB Port K120
    Mouse
    Using USB Port
    Internet Speed
    Broadband 50 Mb/s
    Browser
    Edge Stable Only
    Antivirus
    Microsoft Defender Only
    Other Info
    Screenshot Apps: Snipping Tools || I Try to use Everything from Microsoft Product

Latest Support Threads

Back
Top Bottom