When it is not available or when reinstalling the system, it is convenient for us to reinstall the latest version.
But each installation has to click several times Next button, but also to provide serial numbers, ID and other information, I hate this duplication of work, simply write a small script, let him install automatically, so
I'll be able to take a few minutes off during the installation.
The script uses Python 2.3 + Com objects, so your system must have Python2.3 or later installed
The 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 magical Python language)
The use of scripts is simple, using risinginstall.py-c at the command line the first time you run Risinginstall.cfg
In the same directory to create a configuration file, open it to modify Sn,id,path,execpath, respectively, fill in the serial number, ID number, installation path,
And the directory where the installer is located and the name of the installation program
You can then run risinginstall.py directly
The code is 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"