#To define a particular parameter, replace the 'parameterName' inside itsm.getParameter('parameterName') with that parameter's name
password=itsm.getParameter('DummyPassword')  ## password setup is based on policy requirement. the complex policy does not accept the simple password!

import _winreg

Key= r"SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" ## Here give the registry Key path. STRING
Sub_Key= "legalnoticecaption" ## Here give the sub Key of the registry. STRING
Field= _winreg.REG_SZ ##Here give the field of it
value = 'Warning' ##Mention the value
Sub_Key1= "legalnoticetext" ## Here give the sub Key of the registry. STRING
value1 = 'The machine has been lost/stolen and contact your system Administrator' ##Mention the value 

import os
from _winreg import *
try:
    Key=r"SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System"
    if not os.path.exists(Key):
        key = _winreg.CreateKey(HKEY_LOCAL_MACHINE,Key)
    Registrykey= OpenKey(HKEY_LOCAL_MACHINE,Key, 0,KEY_WRITE)
    _winreg.SetValueEx(Registrykey,Sub_Key,0,Field,value)
    CloseKey(Registrykey)
    Registrykey= OpenKey(HKEY_LOCAL_MACHINE,Key, 0,KEY_WRITE)
    _winreg.SetValueEx(Registrykey,Sub_Key1,0,Field,value1)
    CloseKey(Registrykey)
    print "Successfully created"
except WindowsError:
    print "Error"

import os
import subprocess
from subprocess import PIPE, Popen

gt=[]
gf=[]

try:
    wdir=os.environ['PROGRAMDATA']+'\temp'
    if not os.path.exists(workdir):
            os.mkdir(workdir)
except:
    wdir=os.environ['SYSTEMDRIVE']

fp=wdir+'\\users.txt'
cmd="wmic useraccount get name"
obj=subprocess.Popen(cmd, shell=True, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
out, err = obj.communicate()

with open(fp, 'w+') as dr:
    dr.write(out)

with open(fp, 'r+') as dr:
    for i in dr: None if 'Name' in i or 'DefaultAccount' in i or 'Guest' in i or 'Administrator' in i else gt.append(i.strip())

for i in filter(None, gt):
    obj = subprocess.Popen('net user "%s" "%s"'%(i, password), shell=True, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
    out, err = obj.communicate()
    print "Password changed successfully for the user : "+i if out else err

try:
    os.remove(fp)
except:
    pass

print "Restarting the Machine to apply changes"
os.popen("shutdown.exe -r")
