Python automatically installs rising anti-virus software _python

Source: Internet
Author: User
Tags sleep in python
When it is not available, or when reinstalling the system, it is convenient for us to reinstall the latest version.
But each installation will have to click several times Next button, but also to provide serial numbers, IDs and other information, I hate this duplication of work, simply write a small script, let him automatically install, so
I'll take a few minutes off during the installation.
The script uses the Python 2.3 + Com object, so your system must install Python2.3 or later
Mark Hammond ' s Win32all module must also be installed
(especially thanks to Mark Hammond, who developed the Super module Win32all and thanked the talented Python development team for creating the Magic Python language)
The script is easy to use, using risinginstall.py-c at the command line the first time it is run risinginstall.cfg
Set up the configuration file in the same directory, open it to modify the Sn,id,path,execpath, fill in the serial number, ID number, installation path,
And the directory where the installer is located and the name of the installation program
Then run the risinginstall.py directly.
Copy Code code as follows:

######################################################################
# 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"
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.