当前位置: 移动技术网 > IT编程>脚本编程>Python > Python 自动安装 Rising 杀毒软件

Python 自动安装 Rising 杀毒软件

2019年05月25日  | 移动技术网IT编程  | 我要评论

于娜遇车祸被死亡,斯诺克世锦赛2016赛程,1920x1080壁纸

不能使用时,或重新安装系统时,方便我们重新安装最新的版本.
但是每次安装都要点击好几次 next 按钮,同时还要提供序列号,id 等信息,我很讨厌这种重复工作,索性写一个小的脚本,让他自动安装,这样
我就可以,在安装时休息几分钟了
脚本使用了 python 2.3 + com 对象,所以你的系统必须安装python2.3或更高版本
同时必须安装 mark hammond's win32all 模块
(特别感谢mark hammond是他开发了超级模块win32all,同时向天才的python 开发团队表示感谢,是他们创造了神奇的 python 语言)
脚本的使用很简单,第一次运行时在命令行下使用 risinginstall.py -c risinginstall.cfg
在同目录下建立配置文件,打开它修改sn,id,path,execpath,分别填入 序列号,id号,安装路径,
以及安装程序所在的目录及安装程序名字
之后直接运行risinginstall.py 即可
复制代码 代码如下:

######################################################################
# create by wormchocolate
# risinginstall.py version beta 1
# 2005/02/22 19:17 pm
# test wscript.shell object's install rising-setup in python
######################################################################
import win32com.client,time,os,sys,configparser
wsh = win32com.client.dispatch("wscript.shell")
def installrising(configfilename="risinginstall.cfg"):
if os.path.exists(configfilename):
cfg = configparser.configparser()
cfg.read(configfilename)
try:
sn = cfg.get("install","sn")
id = cfg.get("install","id")
installpath = cfg.get("install","path")
execpath = cfg.get("install","execpath")
splashsec = int(cfg.get("program","splashsec"))
languagesec = int(cfg.get("program","languagesec"))
itemsec = int(cfg.get("program","itemsec"))
wshe = wsh.exec(execpath)
pid = wshe.processid
except:
print "configparser faile"
sys.exit(1)
if pid != "":
wsh.appactivate(pid)
time.sleep(splashsec)
wsh.sendkeys("{enter}")
time.sleep(languagesec)
wsh.sendkeys("%n")
#time.sleep(itemsec)
wsh.sendkeys("%a")
#time.sleep(itemsec)
wsh.sendkeys("%n")
#time.sleep(itemsec)
wsh.sendkeys(sn)
#time.sleep(itemsec)
wsh.sendkeys(id)
wsh.sendkeys("%n")
time.sleep(itemsec)
wsh.sendkeys("%s")
time.sleep(itemsec)
wsh.sendkeys("%n")
time.sleep(itemsec)
wsh.sendkeys("%n")
time.sleep(itemsec)
wsh.sendkeys(installpath)
wsh.sendkeys("%n")
time.sleep(itemsec)
wsh.sendkeys("%n")
wsh.sendkeys("%n")
else:
print "config file " + configfilename +" not found"
print "now auto create this config file dot't worry"
createcfg(configfilename)
installrising()
def createcfg(cfgname):
if cfgname != "":
print "createing config file : "+ cfgname + "..."
contents = ["[install]\n","sn=\n","id=\n","path=c:\\\\program files\\\\rising\\\\rav\n","execpath = c:\\\\rising17.06.exe\n" \
"\n[program]\n","splashsec=20\n","languagesec=2\n","itemsec=1\n"]
cfg = open(cfgname,"w+t",256)
cfg.writelines(contents)
cfg.close()
print cfgname + " create ok..."
#----- main -------------
if len(sys.argv) == 1 :
installrising()
elif len(sys.argv) == 2:
installrising(sys.argv[1])
elif len(sys.argv) == 3:
if sys.argv[1]=="-c" and sys.argv[2] != "":
createcfg(sys.argv[2])
print "config file: " + sys.argv[2] + " created ok..."
else:
print "parm error : \nexample : "+sys.argv[0]+" -c configfilename.cfg"
else:
print "script error"

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网