转载时请注明出处和作者联系方式
作者联系方式:李先静 <xianjimli at hotmail dot com>
制作安装包有很多方法,但我喜欢最简单的方法,所以选择了iexpress。它是Windows自带的,简单易用,当然功能也很简单,它把所有文件打包成一个EXE文件,运行时解压到一个临时目录,然后运行指定的程序,其它的事情都要自己做了。
VBScript也是我很喜欢的脚本,虽然我一年中也难得用它一次。但它非常容易上手,也不需要在IDE里开发,而且功能强大,操作COM组件真是得心应手。所以我决定用VBScript作为安装脚本,让安装程序在解压完成时调用。Install.vbs内容如下:
- 'Mobile Explorer for MobileX installer
- set shl = CreateObject("WScript.Shell")
- set fso = CreateObject("Scripting.FileSystemObject")
- set sha = CreateObject("Shell.Application")
- install_path = shl.ExpandEnvironmentStrings("%ProgramFiles%") + "/mobile_me"
- system_root = shl.ExpandEnvironmentStrings("%SystemRoot%") + "/system32"
- if fso.FolderExists(install_path) then
- fso.DeleteFolder(install_path)
- end if
- fso.CreateFolder(install_path)
- set folder = fso.GetFolder("./")
- set files = folder.files
- for each file in files
- file.Copy(install_path + "/" + file.name)
- next
- filenames = Split("libexpat.dll,mehost.dll,mobilex_me.dll", ",")
- for x=0 to UBound(filenames)
- set file = fso.GetFile(install_path + "/" + filenames(x))
- file.Copy(system_root + "/" + filenames(x))
- next
- sha.ShellExecute install_path + "/WceRndis.inf", "", "", "install", 1
- sha.ShellExecute install_path + "/WceIS.inf", "", "", "install", 1
- sha.ShellExecute install_path + "/wceusbsh.inf", "", "", "install", 1
- shl.Run "regsvr32 """ + system_root + """/mobilex_me.dll", , true
uninstall.vbs:
- 'Mobile Explorer for MobileX uninstaller
- set shl = CreateObject("WScript.Shell")
- set fso = CreateObject("Scripting.FileSystemObject")
- install_path = shl.ExpandEnvironmentStrings("%ProgramFiles%") + "/mobile_me"
- system_root = shl.ExpandEnvironmentStrings("%SystemRoot%") + "/system32"
- shl.Run "regsvr32 /u """ + system_root + """/mobilex_me.dll", , true
- On Error Resume Next
- if fso.FolderExists(install_path) then
- fso.DeleteFolder(install_path)
- end if
- filenames = Split("libexpat.dll,mehost.dll,mobilex_me.dll", ",")
- for x=0 to UBound(filenames)
- filename=system_root + "/" + filenames(x)
- if fso.FileExists(filename) then
- fso.DeleteFile(filename)
- end if
- next