disable/delete office click to run

run cmd as admin

C:\Windows\system32>sc stop “ClickToRunSvc”

SERVICE_NAME: ClickToRunSvc
TYPE : 10 WIN32_OWN_PROCESS
STATE : 1 STOPPED
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x0

C:\Windows\system32>sc config “ClickToRunSvc” start=disabled
[SC] ChangeServiceConfig SUCCESS

C:\Windows\system32>sc delete “ClickToRunSvc”
[SC] DeleteService SUCCESS

C:\Windows\system32>

backup /etc with tar

The following is an exemplary command of how to archive your system.

tar -cvpzf backup.tar.gz --exclude=/backup.tar.gz --one-file-system /etc

back.sh (backup with timestamp) – add to cron (sh /back.sh)

#!/bin/bash
DATE=$(date +%Y-%m-%d-%H%M%S)
BACKUP_DIR="/backup"
SOURCE="/etc"
tar -cvzpf $BACKUP_DIR/backup-$DATE.tar.gz $SOURCE

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.