手机探索者开发实录—制作MobileX插件的安装包

手机探索者开发实录—制作MobileX插件的安装包

转载时请注明出处和作者联系方式
作者联系方式:李先静 <xianjimli at hotmail dot com>

制作安装包有很多方法,但我喜欢最简单的方法,所以选择了iexpress。它是Windows自带的,简单易用,当然功能也很简单,它把所有文件打包成一个EXE文件,运行时解压到一个临时目录,然后运行指定的程序,其它的事情都要自己做了。

VBScript也是我很喜欢的脚本,虽然我一年中也难得用它一次。但它非常容易上手,也不需要在IDE里开发,而且功能强大,操作COM组件真是得心应手。所以我决定用VBScript作为安装脚本,让安装程序在解压完成时调用。Install.vbs内容如下:

  1. 'Mobile Explorer for MobileX installer

  2. set shl = CreateObject("WScript.Shell")
  3. set fso = CreateObject("Scripting.FileSystemObject")
  4. set sha = CreateObject("Shell.Application")

  5. install_path = shl.ExpandEnvironmentStrings("%ProgramFiles%") + "/mobile_me"
  6. system_root = shl.ExpandEnvironmentStrings("%SystemRoot%") + "/system32"

  7. if fso.FolderExists(install_path) then
  8.     fso.DeleteFolder(install_path)
  9. end if

  10. fso.CreateFolder(install_path)

  11. set folder = fso.GetFolder("./")
  12. set files = folder.files

  13. for each file in files
  14.     file.Copy(install_path + "/" + file.name)
  15. next

  16. filenames = Split("libexpat.dll,mehost.dll,mobilex_me.dll"",")
  17. for x=0 to UBound(filenames)
  18.     set file = fso.GetFile(install_path + "/" + filenames(x))
  19.     file.Copy(system_root + "/" + filenames(x))
  20. next
  21. sha.ShellExecute  install_path + "/WceRndis.inf",  """""install", 1
  22. sha.ShellExecute  install_path + "/WceIS.inf""""""install", 1
  23. sha.ShellExecute  install_path + "/wceusbsh.inf""""""install", 1
  24. shl.Run "regsvr32 """ + system_root + """/mobilex_me.dll", , true


uninstall.vbs:

  1. 'Mobile Explorer for MobileX uninstaller

  2. set shl = CreateObject("WScript.Shell")
  3. set fso = CreateObject("Scripting.FileSystemObject")

  4. install_path = shl.ExpandEnvironmentStrings("%ProgramFiles%") + "/mobile_me"
  5. system_root = shl.ExpandEnvironmentStrings("%SystemRoot%") + "/system32"

  6. shl.Run "regsvr32 /u """ + system_root + """/mobilex_me.dll", , true

  7. On   Error   Resume   Next
  8. if fso.FolderExists(install_path) then
  9.     fso.DeleteFolder(install_path)
  10. end if

  11. filenames = Split("libexpat.dll,mehost.dll,mobilex_me.dll"",")
  12. for x=0 to UBound(filenames)
  13.     filename=system_root + "/" + filenames(x)
  14.     if fso.FileExists(filename) then
  15.         fso.DeleteFile(filename)
  16.     end if
  17. next
~~end~~

原文地址:https://www.cnblogs.com/zhangyunlin/p/6167618.html