enable_disable=itsm.getParameter('parameterName') # 1 to stop windows update to win 11 ,0 to disable 
import ctypes
from subprocess import PIPE, Popen

def ecmd(command):
    class disable_file_system_redirection:
        _disable = ctypes.windll.kernel32.Wow64DisableWow64FsRedirection
        _revert = ctypes.windll.kernel32.Wow64RevertWow64FsRedirection
        def __enter__(self):
            self.old_value = ctypes.c_long()
            self.success = self._disable(ctypes.byref(self.old_value))
        def __exit__(self, type, value, traceback):
            if self.success:
                self._revert(self.old_value)

    with disable_file_system_redirection():
        obj = Popen(command, shell = True, stdout = PIPE, stderr = PIPE)
    out, err = obj.communicate()
    if err:
        return err
    else:
        return out
if enable_disable=="1":
    check=r'REG QUERY "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /s /f TargetReleaseVersion'
    strs=ecmd(check)
    #print strs
    #print type(strs)
    if "TargetReleaseVersion" in strs:
        print "Registry Entry is already Exist quitting..."
        pass
    else:
        print "Adding Registry Entries"
        command1=r'reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v TargetReleaseVersion ^ /t REG_DWORD /d 1 /f' #Please edit your comand here.
        command2=r'reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v TargetReleaseVersionInfo ^ /t REG_SZ /d 21H1 /f'
        print ecmd(command1)
        print ecmd(command2)
        #ecmd(r'shutdown -r')
else :
    command1=r'REG QUERY "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /s /f TargetReleaseVersion' #Please edit your comand here.
    strs=ecmd(command1)
    #print strs
    #print type(strs)
    if "TargetReleaseVersion" in strs:
        print "Deleting Registry Entries"
        cmd1=r'reg delete "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v TargetReleaseVersion /f'
        cmd2=r'reg delete "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v TargetReleaseVersionInfo /f'
        print ecmd(cmd1)
        print ecmd(cmd2)
    else:
        print "No Registry Entry quitting..."
        pass
    