Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
2.5 KiB

  1. ' Wise for Windows Installer utility to recompile a installation
  2. ' For use with Windows Scripting Host, CScript.exe or WScript.exe
  3. ' Copyright (c) 1999, Wise Solutions, Inc.
  4. Option Explicit
  5. 'global variables
  6. Public Installer ' Wise for Windows Installer object
  7. Dim Args ' Command line arguments object
  8. Dim strSourceFile ' Source file to open (WSI)
  9. Dim strTargetFile ' Target file to save as (MSI)
  10. Dim I
  11. Dim nPos
  12. Dim WiseProperties ' Dictionary object to hold Wise properties
  13. Dim WiseMediaOptions ' Dictionary object to hold Wise media options
  14. Dim strProp
  15. Dim strMedia
  16. Dim propKeys
  17. Dim mediaKeys
  18. ' Parse command line arguments
  19. Set Args = Wscript.Arguments
  20. If Args.Count < 1 Then
  21. Wscript.Echo "Usage: CScript.exe " & Wscript.ScriptName & " <input WSI file> [/O <output MSI file>]"
  22. Wscript.Quit 1
  23. End If
  24. strSourceFile = Args.Item(0)
  25. Set WiseProperties = CreateObject("Scripting.Dictionary")
  26. Set WiseMediaOptions = CreateObject("Scripting.Dictionary")
  27. For I = 1 to Args.Count - 1 Step 2
  28. If UCase(Args.Item(I)) = "/O" Then strTargetFile = Args.Item(I+1)
  29. If UCase(Args.Item(I)) = "/P" Then
  30. strProp = Split(Args.Item(I+1), "=", 2, 1)
  31. If Len(strProp(0)) > 0 Then WiseProperties.Add strProp(0), strProp(1)
  32. End If
  33. If UCase(Args.Item(I)) = "/M" Then
  34. strMedia = Split(Args.Item(I+1), "=", 2, 1)
  35. If Len(strMedia(0)) > 0 Then WiseMediaOptions.Add strMedia(0), strMedia(1)
  36. End If
  37. Next
  38. If Len(strTargetFile) = 0 Then
  39. nPos = InStrRev(strSourceFile, ".")
  40. If nPos > 0 Then strTargetFile = Left(strSourceFile, nPos) & "msi"
  41. End If
  42. ' Connect to Wise for Windows Installer object
  43. Set installer = Wscript.CreateObject("WfWi.Document")
  44. Wscript.Echo "Opening " & strSourceFile
  45. installer.Open strSourceFile
  46. ' To set properties use the following code
  47. ' installer.SetProperty "PropertyName", "PropertyValue"
  48. If WiseProperties.Count > 0 Then
  49. propKeys = WiseProperties.Keys
  50. For I = 0 to WiseProperties.Count - 1
  51. Wscript.Echo "Setting property " & propKeys(I) & "=" & WiseProperties(propKeys(I))
  52. installer.SetProperty propKeys(I), WiseProperties(propKeys(I))
  53. Next
  54. End If
  55. ' To set the media options to control where the files are placed
  56. ' installer.SetMediaOption "File Location", "1"
  57. If WiseMediaOptions.Count > 0 Then
  58. mediaKeys = WiseMediaOptions.Keys
  59. For I = 0 to WiseMediaOptions.Count - 1
  60. Wscript.Echo "Setting media option " & mediaKeys(I) & "=" & WiseMediaOptions(mediaKeys(I))
  61. installer.SetMediaOption mediaKeys(I), WiseMediaOptions(mediaKeys(I))
  62. Next
  63. End If
  64. Wscript.Echo "Saving " & strTargetFile
  65. installer.Save strTargetFile
  66. Set installer = Nothing
  67. Wscript.Quit 0