原理也就是利用setup.dll啊,我只是進行了一下命令列自動化,有時要打幾次包,麻煩得很。
使用方法:
1. 下載附件,解壓到任一目錄
2. 將你要放安裝的所有資源檔和exe放入此目錄,修改make.py,將Provider和AppName改為自己的,這裡不能出現中文AppName為目錄。
3. 如果要改程式捷徑名,改config/config.txt中chinaname即可。
4. 命令列運行make.py,可以看到編譯成功的資訊
指令碼代碼如下:
#coding=utf-8import osimport os.pathworkpath = os.path.dirname(__file__)Provider = "talkweb" #公司名 不能為中文AppName = "test" #程式名 不能為中文SourceDisksNames = ""CopyFiles = ""SourceDisksFiles = ""DestinationDirs = ""Body = ""#cab工具目錄,mobile sdk5,6都行cab_tools = '"D:\Program Files\Microsoft Visual Studio 9.0\smartdevices\sdk\sdktools\cabwiz.exe"'f = open("template.inf")inf_content = f.read()f.close()nIndex = 1for root, dirs, files in os.walk(workpath): for name in files: if not name.endswith(".inf") and not name.endswith(".CAB") and not name.endswith(".py") : #1=,"Common1",,"C:\workspace\WindowsMobile\InstallCab\" SourceDisksNames += str(nIndex) + '=,\"Common'+str(nIndex)+'",,"'+root+'\\"'+"\n" SourceDisksFiles += '"' + name + '"' + "=" + str(nIndex) + "\n" #Files.Common1=0,"%InstallDir%\config" DestinationDirs += "Files.Common"+str(nIndex)+'=0,"%InstallDir%' if len(root[len(workpath):]) > 0 : DestinationDirs += root[len(workpath):] DestinationDirs += '"'+"\n" #[Files.Common74] #"SetupDLL.dll","SetupDLL.dll",,0 Body += "[Files.Common"+str(nIndex)+"]\n" Body += ('"%s","%s",,0') % (name,name) Body += "\n" nIndex += 1for x in xrange(nIndex): if x > 0: CopyFiles += "Files.Common"+str(x) if x != (nIndex-1): CopyFiles += ","if __name__ == "__main__": inf_content = inf_content.replace("{Provider}",Provider) inf_content = inf_content.replace("{AppName}",AppName) inf_content = inf_content.replace("{SourceDisksNames}",SourceDisksNames) inf_content = inf_content.replace("{CopyFiles}",CopyFiles) inf_content = inf_content.replace("{SourceDisksFiles}",SourceDisksFiles) inf_content = inf_content.replace("{DestinationDirs}",DestinationDirs) inf_content = inf_content.replace("{Body}",Body) open(AppName+".inf","w").write(inf_content) cmd = cab_tools + " "+AppName+".inf /err CabWiz.log" os.system(cmd)