Its used to configure a clients software, however we have to run a different per depending on the version of windows ( winXP, win7, win8 and win8.1, win10)
Can a script be created to discover the OS version and then download the correct reg file and run it
Hi @Tetrash ,
Please refer the following json file for your requested script.
Please configure parameters with necessary inputs before running the script.
Thank You
Hello @Tetrash
I’m able to download the JSON file from Vicky’s post just fine. Please make sure that you are logged in to the C1 forums before making any attempt to download any file attachments.
Just in case though, you can create a new Procedure in the ITSM and copy+paste the code below.
#In Parameter URL_XP provide the download url for Windows XP reg file
#In Parameter REGFILE_XP provide the reg file name that is going to be runned on Windows XP
#In Parameter URL_7 provide the download url for Windows 7 reg file
#In Parameter REGFILE_7 provide the reg file name that is going to be runned on Windows 7
#In Parameter URL_8 provide the download url for Windows 8 reg file
#In Parameter REGFILE_8 provide the reg file name that is going to be runned on Windows 8
#In Parameter URL_8_1 provide the download url for Windows 8.1 reg file
#In Parameter REGFILE_8_1 provide the reg file name that is going to be runned on Windows 8.1
#In Parameter URL_10 provide the download url for Windows 10 reg file
#In Parameter REGFILE_10 provide the reg file name that is going to be runned on Windows 10
URL_XP=itsm.getParameter('URL_XP')
REGFILE_XP=itsm.getParameter('REGFILE_XP')
URL_7=itsm.getParameter('URL_7')
REGFILE_7=itsm.getParameter('REGFILE_7')
URL_8=itsm.getParameter('URL_8')
REGFILE_8=itsm.getParameter('REGFILE_8')
URL_81=itsm.getParameter('URL_8_1')
REGFILE_81=itsm.getParameter('REGFILE_8_1')
URL_10=itsm.getParameter('URL_10')
REGFILE_10=itsm.getParameter('REGFILE_10')
import os
import time
import platform
import ssl
import subprocess
import shutil
import platform
def Download(src_path, URL,fp):
import urllib2
request = urllib2.Request(URL, headers={'User-Agent' : "Magic Browser"})
try:
gcontext = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
parsed = urllib2.urlopen(request,context=gcontext)
except:
parsed = urllib2.urlopen(request)
if not os.path.exists(src_path):
os.makedirs(src_path)
with open(fp, 'wb') as f:
while True:
chunk=parsed.read(100*1000*1000)
if chunk:
f.write(chunk)
else:
break
return fp
def reg(URLL,filename):
Folder=os.environ['TEMP']+r"\Noproblem"
if not os.path.exists(Folder):
os.mkdir(Folder)
fileName=filename
src_path=Folder
fp = os.path.join(src_path, fileName)
URL=URLL
Excutable_path=Download(Folder, URL,fp)
time.sleep(20)
output=Folder+"\\"+"regedit.exe /S"+" "+fileName
process=subprocess.Popen(output, shell=True, stdout=subprocess.PIPE)
result=process.communicate()[0]
print "Regfiles Updated Successfully"
try:
shutil.rmtree(Folder)
except:
pass
osver=platform.release()
if osver=='7':
reg(URL_7,REGFILE_7)
elif osver=='8':
reg(URL_8,REGFILE_8)
elif osver=='8.1':
reg(URL_81,REGFILE_81)
elif osver=='10':
reg(URL_10,REGFILE_10)
else:
reg(URL_XP,REGFILE_XP)