disable windows10 updates powershell script

Run in PowerShell in Administrator mode:

Clear-Host

$WindowsUpdatePath = "HKLM:SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\"
$AutoUpdatePath = "HKLM:SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU"

If(Test-Path -Path $WindowsUpdatePath) {
    Remove-Item -Path $WindowsUpdatePath -Recurse
}

New-Item $WindowsUpdatePath -Force
New-Item $AutoUpdatePath -Force

Set-ItemProperty -Path $AutoUpdatePath -Name NoAutoUpdate -Value 1

Get-ScheduledTask -TaskPath "\Microsoft\Windows\WindowsUpdate\" | Disable-ScheduledTask

takeown /F C:\Windows\System32\Tasks\Microsoft\Windows\UpdateOrchestrator /A /R
icacls C:\Windows\System32\Tasks\Microsoft\Windows\UpdateOrchestrator /grant Administrators:F /T

Get-ScheduledTask -TaskPath "\Microsoft\Windows\UpdateOrchestrator\" | Disable-ScheduledTask

Stop-Service wuauserv
Set-Service wuauserv -StartupType Disabled

Write-Output "All Windows Updates were disabled"

headless ubuntu fsck waits for Y key during bootup

I have a headless Ubuntu 12.04 server in a datacenter 1500 miles away. Twice now on reboot the system decided it had to fsck. Unfortunately Ubuntu ran fsck in interactive mode, so I had to ask someone at my datacenter to go over, plug in a console, and press the Y key. How do I set it up so that fsck runs in non-interactive mode at boot time with the -y or -p (aka -a) flag?

For Ubuntu 15,16,17+ the FSCKFIX value setting is located in /lib/init/vars.sh

sudo nano /lib/init/vars.sh

change FSCKFIX=no to FSCKFIX=yes

Hard disk write protected USB external adapter

Command Prompt -> run as administrator

Microsoft Windows [Version 10.0.10240]
(c) 2015 Microsoft Corporation. All rights reserved.

C:\Windows\system32>diskpart

Microsoft DiskPart version 10.0.10240

Copyright (C) 1999-2013 Microsoft Corporation.
On computer: JACQUESWERK

DISKPART> list disk

  Disk ###  Status         Size     Free     Dyn  Gpt
  --------  -------------  -------  -------  ---  ---
  Disk 0    Online         1863 GB      0 B
  Disk 1    Online         1863 GB   497 GB
  Disk 2    Online           59 GB      0 B
  Disk 3    Online         1863 GB      0 B

DISKPART> select disk 3

Disk 3 is now the selected disk.

DISKPART> attributes disk clear readonly

Disk attributes cleared successfully.

DISKPART> exit

Leaving DiskPart...

C:\Windows\system32>

How to fix USB flash, SD memory card, CD disc & Pen drive write-protected error?

We use removable storage devices a lot on a Windows computer, and some of you should at least once encounter the issue of the disk malfunction, which is mostly about “the disk is write protected”. When Windows starts to write protect your disk, for example, a SanDisk 4GB USB flash drive, you can no longer use it anymore until you remove the write protection. And the fix methods are as follows.

Method 1. diskpart command

Step 1. Open administrative Command Prompt.

Step 2. Type these commands one by one and press Enter key after each:

  • diskpart
  • list disk
  • select disk # (# is the number of USB drive with which you’re getting the write-protected error and is plugged in)
  • attributes disk clear readonly

Step 3. You may now close Command Prompt and re-plug the USB drive and check if the issue is resolved, by dragging a file to the drive or trying to format in Windows Disk Management or EaseUS Partition Master coming in the later part.

Invoke UI Changes Across Threads on VB .Net

I need to do this all the time and don’t have the best memory in the world. Today, I decided that I looked this up one too many times so here’s my solution to this multithreading problem:

The Problem:

You try to modify UI components created in one thread in another thread. In VB, you can only make UI changes on the same thread that created it so you get a nice “Cross thread operation not valid” exception.

Here’s the wrong code:

thread = New System.Threading.Thread(AddressOf DoStuff)
thread.Start()
Private Sub DoStuff()
    'error occurs here'
    Me.Text = "Stuff"
End Sub

The Solution:

If you’re super lazy or you’re very sure of what your code is going to do, you can simply disable the exception with:

Private Sub DoStuff()
    Me.CheckForIllegalCrossThreadCalls = False
    Me.Text = "Stuff"
End Sub

This, of course, doesn’t prevent your code from making a mess. To do it properly, you need a delegate:

thread = New System.Threading.Thread(AddressOf DoStuff)
thread.Start()
Private Delegate Sub DoStuffDelegate()
Private Sub DoStuff()
    If Me.InvokeRequired Then
        Me.Invoke(New DoStuffDelegate(AddressOf DoStuff))
    Else
        Me.Text = "Stuff"
    End If
End Sub

Wildly simple right?

To understand what the code does, you need to understand what Invoke() does. It can be confusing to google Invoke() because Delegates and Controls have different implementations of Invoke(). In this case, we’re calling Invoke on a subclass of Control. That causes the method on the second thread which is going through DoStuff() to run a method on the first thread (which created the UI element).

Now if you need parameters, here’s another example where “ReallyLongProcess” is a subroutine that raises an event “Done” with a parameter “success”

AddHandler Me.Done, AddressOf WorkFinished
thread = new System.Threading.Thread(AddressOf ReallyLongProcess)
thread.Start()
Private Delegate Sub DoStuffDelegate(ByRef success as Boolean)
Private Sub DoStuff(ByRef success as Boolean)
    If Me.InvokeRequired Then
        Me.Invoke(New DoStuffDelegate(AddressOf DoStuff), success)
    Else
        If success Then
            'do stuff
        Else
            'do stuff
        End If
    End If
End Sub

Vb.net 2015 working sample:
Add button,add progressbar

Imports System.Threading
Public Class Form1
    Private trd As Thread


    Private Sub ThreadTask()
        Dim stp As Integer
        Dim newval As Integer
        Dim rnd As New Random()
        Me.CheckForIllegalCrossThreadCalls = False
        Do
            stp = ProgressBar1.Step * rnd.Next(-1, 2)
            newval = ProgressBar1.Value + stp
            If newval > ProgressBar1.Maximum Then
                newval = ProgressBar1.Maximum
            ElseIf newval < ProgressBar1.Minimum Then
                newval = ProgressBar1.Minimum
            End If

            ProgressBar1.Value = newval

            Thread.Sleep(100)
        Loop
    End Sub

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
     

        trd = New Thread(AddressOf ThreadTask)
        trd.IsBackground = True
        trd.Start()
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        MessageBox.Show("This is the main thread")
    End Sub
End Class

Windows 10 Disable wsappx

 

HKEY_LOCAL_MACHINE\SYSTEM\ControlSet00x\Services\AppXSVC
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet00x\Services\ClipSVC
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet00x\Services\WSService

Change the “Start” REG_DWORD value from:
0x00000003 (3)
to
0x00000004 (4)
on each of those, then reboot.

old windows7 style volume control

Open Registry Editor. and navigate to the following Registry key:

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\MTCUVC

Next, in the right pane you will see a 32-bit DWORD value named EnableMtcUvc. In case you do not see it, create it. Its default value is 1. Change it to 0.

How to enable c$ admin share on Windows 10 and Server 2016

  1. From the computer you’d like to enable the admin share, click Start or Cortana and immediately type “cmd“. From the list of results, right-click Command Prompt and select Run as administrator.
  2. Copy and paste the following command into the Command Prompt window and hit enter.
REG ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\system /v LocalAccountTokenFilterPolicy /t REG_DWORD /d 1 /f

How to Make Windows Photo Viewer Your Default Image Viewer on Windows 10

Copy the following code into notepad and save it as a .reg file then merge it.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Applications\photoviewer.dll]

[HKEY_CLASSES_ROOT\Applications\photoviewer.dll\shell]

[HKEY_CLASSES_ROOT\Applications\photoviewer.dll\shell\open]
"MuiVerb"="@photoviewer.dll,-3043"

[HKEY_CLASSES_ROOT\Applications\photoviewer.dll\shell\open\command]
@=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,72,00,75,00,\
6e,00,64,00,6c,00,6c,00,33,00,32,00,2e,00,65,00,78,00,65,00,20,00,22,00,25,\
00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,00,46,00,69,00,6c,00,65,00,73,00,\
25,00,5c,00,57,00,69,00,6e,00,64,00,6f,00,77,00,73,00,20,00,50,00,68,00,6f,\
00,74,00,6f,00,20,00,56,00,69,00,65,00,77,00,65,00,72,00,5c,00,50,00,68,00,\
6f,00,74,00,6f,00,56,00,69,00,65,00,77,00,65,00,72,00,2e,00,64,00,6c,00,6c,\
00,22,00,2c,00,20,00,49,00,6d,00,61,00,67,00,65,00,56,00,69,00,65,00,77,00,\
5f,00,46,00,75,00,6c,00,6c,00,73,00,63,00,72,00,65,00,65,00,6e,00,20,00,25,\
00,31,00,00,00

[HKEY_CLASSES_ROOT\Applications\photoviewer.dll\shell\open\DropTarget]
"Clsid"="{FFE2A43C-56B9-4bf5-9A79-CC6D4285608A}"

[HKEY_CLASSES_ROOT\Applications\photoviewer.dll\shell\print]

[HKEY_CLASSES_ROOT\Applications\photoviewer.dll\shell\print\command]
@=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,72,00,75,00,\
6e,00,64,00,6c,00,6c,00,33,00,32,00,2e,00,65,00,78,00,65,00,20,00,22,00,25,\
00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,00,46,00,69,00,6c,00,65,00,73,00,\
25,00,5c,00,57,00,69,00,6e,00,64,00,6f,00,77,00,73,00,20,00,50,00,68,00,6f,\
00,74,00,6f,00,20,00,56,00,69,00,65,00,77,00,65,00,72,00,5c,00,50,00,68,00,\
6f,00,74,00,6f,00,56,00,69,00,65,00,77,00,65,00,72,00,2e,00,64,00,6c,00,6c,\
00,22,00,2c,00,20,00,49,00,6d,00,61,00,67,00,65,00,56,00,69,00,65,00,77,00,\
5f,00,46,00,75,00,6c,00,6c,00,73,00,63,00,72,00,65,00,65,00,6e,00,20,00,25,\
00,31,00,00,00

[HKEY_CLASSES_ROOT\Applications\photoviewer.dll\shell\print\DropTarget]
"Clsid"="{60fd46de-f830-4894-a628-6fa81bc0190d}"