Hi, please refer this script to set default page to a specific address in google chrome
Edit parameters:
page="https://www.google.com" # Edit with your specific address which you want to set as a default page
this script has been scanned with virustotal.com and xcitium verdict cloud.
PYTHON SCRIPT FILE SHA1 VALUE - 0fde03668bd82827d7cc4c508e13c39baaaa1482
JSON FILE SHA1 VALUE - e896f9a41f85db1288e0e74f2a6996633d1d03cb
Note : Run as logged in user
page='"https://www.google.com"'#provide your default page here
import os
import ctypes
import getpass
import _winreg
def CheckApp(AppName):
import _winreg
import os
AppName = AppName.lower()
def DNDS(rtkey, pK, kA):
ln = []
lv = []
try:
oK = _winreg.OpenKey(rtkey, pK, 0, kA)
i = 0
while True:
try:
bkey = _winreg.EnumKey(oK, i)
vkey = os.path.join(pK, bkey)
oK1 = _winreg.OpenKey(rtkey, vkey, 0, kA)
try:
tls = []
DN, bla = _winreg.QueryValueEx(oK1, 'DisplayName')
DV, bla = _winreg.QueryValueEx(oK1, 'DisplayVersion')
_winreg.CloseKey(oK1)
ln.append(DN)
lv.append(DV)
except:
pass
i += 1
except:
break
_winreg.CloseKey(oK)
return zip(ln, lv)
except:
return zip(ln, lv)
rK = _winreg.HKEY_LOCAL_MACHINE
sK = r'SYSTEM\CurrentControlSet\Control\Session Manager\Environment'
openedKey = _winreg.OpenKey(rK, sK, 0, _winreg.KEY_READ)
arch, bla = _winreg.QueryValueEx(openedKey, 'PROCESSOR_ARCHITECTURE')
arch = str(arch)
_winreg.CloseKey(openedKey)
if arch == 'AMD64':
fList = DNDS(_winreg.HKEY_LOCAL_MACHINE, r'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall', _winreg.KEY_WOW64_32KEY | _winreg.KEY_READ)
fList.extend(DNDS(_winreg.HKEY_LOCAL_MACHINE, r'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall', _winreg.KEY_WOW64_64KEY | _winreg.KEY_READ))
fList.extend(DNDS(_winreg.HKEY_CURRENT_USER, r'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall', _winreg.KEY_WOW64_32KEY | _winreg.KEY_READ))
fList.extend(DNDS(_winreg.HKEY_CURRENT_USER, r'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall', _winreg.KEY_WOW64_64KEY | _winreg.KEY_READ))
else:
fList = DNDS(_winreg.HKEY_LOCAL_MACHINE, r'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall', _winreg.KEY_READ)
fList.extend(DNDS(_winreg.HKEY_CURRENT_USER, r'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall', _winreg.KEY_READ))
fList = set(fList)
lr = []
rs = 0
for i in fList:
a, b = i
if AppName in a.lower():
lr.append('success: {} is installed'.format(a))
lr.append('{:<25}{:5}'.format(a, b))
rs += 1
else:
rs += 0
if rs:
return True
return False
AppName='Google Chrome'
ck=CheckApp(AppName)
if ck:
print("Chrome Installed")
else:
raise Exception("Chrome is not installed in the system")
path='"C:\Program Files\Google\Chrome\Application\chrome.exe"'
kk=getpass.getuser()
drive=os.environ['SYSTEMDRIVE']
k = drive+"\\Users\\%s\\Desktop" %(kk)
sh1=os.path.join(k,r'Google Chrome.lnk')
sh="C:\Users\Public\Desktop\Google Chrome.lnk"
if os.path.exists(sh) or os.path.exists(sh1):
try:
os.remove(sh)
except:
os.remove(sh1)
vbs='''Set objShell = WScript.CreateObject("WScript.Shell")
allUsersDesktop = objShell.SpecialFolders("AllUsersDesktop")
usersDesktop = objShell.SpecialFolders("Desktop")
Set objShortCut = objShell.CreateShortcut(usersDesktop & "\Google Chrome.lnk")
objShortCut.TargetPath = %s
objShortCut.Description = "Run the Notepad."
objShortCut.WindowStyle = 1
objShortCut.Hotkey = "CTRL+SHIFT+F"
objShortCut.Description = "Shortcut Script"
objShortCut.WorkingDirectory = strDesktop
objShortCut.Arguments = %s
objShortCut.Save
''' %(path,page)
def runvbs(vbs):
workdir=os.environ['PROGRAMDATA']+r'\temp'
if not os.path.isdir(workdir):
os.mkdir(workdir)
with open(workdir+r'\temprun.vbs',"w") as f :
f.write(vbs)
print(os.popen('cscript.exe "'+workdir+r'\temprun.vbs"').read())
if os.path.isfile(workdir+r'\temprun.vbs'):
os.remove(workdir+r'\temprun.vbs')
runvbs(vbs)
Comments