コンピュータや音楽の事書いてます

msiファイル作成メモ

http://www.civil-design.net/free/coach/dev/wi/index.html
http://softwarefactory.jp/japan/developer/windowsinstaller/MSI0006.html

Visual Studioで「セットアップと配置」プロジェクトを作れば、setup.exeとmsiファイルが作成できるが、さらに細かい設定をmsiファイルに加えたい場合、orcaを使うと良い。

orca無しで出来る事


インストーラ実行時にスクリプトやexeを実行するなど、何か自動で行いたい事がある場合、Visual Studioでやる場合、

  1. setupプロジェクトを右クリック→表示→カスタム動作
  2. カスタム動作ウィンドウ内のインストールを右クリック→カスタム動作の追加
  3. プロパティウィンドウのSourcePathのところに、実行したいファイル
  4. CustomActionDataのところに、渡したいデータ。例えば、ここに [TARGETDIR] と書くとインストールPathが渡される

以下、インストール時にドライバとパワポ2010のアドインを自動インストールするvbsの例。

'msiファイル内の情報読み出し
instPath = Session.Property("CustomActionData")
'ドライバ インストール
ws.run """" & instPath & "\Driver.exe"""
'アドイン インストール
addinPath = instPath & "\addin.ppa"
if fso.FileExists(addinPath) then
    'errprint "アドイン存在確認OK"
    ws.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\PowerPoint\AddIns\名前\Path", addinPath, "REG_SZ"
    ws.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\PowerPoint\AddIns\名前\AutoLoad", 1, "REG_DWORD"
end if
orcaでやる場合(検証途中)

CustomActionテーブルに書く。( http://msdn.microsoft.com/en-us/library/aa372048 )
CustomActionのTypeはこれらを足した値

//C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Include\MsiDefs.h
enum msidbCustomActionType
{
	// executable types
	msidbCustomActionTypeDll              = 0x00000001,  // Target = entry point name
	msidbCustomActionTypeExe              = 0x00000002,  // Target = command line args
	msidbCustomActionTypeTextData         = 0x00000003,  // Target = text string to be formatted and set into property
	msidbCustomActionTypeJScript          = 0x00000005,  // Target = entry point name, null if none to call
	msidbCustomActionTypeVBScript         = 0x00000006,  // Target = entry point name, null if none to call
	msidbCustomActionTypeInstall          = 0x00000007,  // Target = property list for nested engine initialization

	// source of code
	msidbCustomActionTypeBinaryData       = 0x00000000,  // Source = Binary.Name, data stored in stream
	msidbCustomActionTypeSourceFile       = 0x00000010,  // Source = File.File, file part of installation
	msidbCustomActionTypeDirectory        = 0x00000020,  // Source = Directory.Directory, folder containing existing file
	msidbCustomActionTypeProperty         = 0x00000030,  // Source = Property.Property, full path to executable

	// return processing                  // default is syncronous execution, process return code
	msidbCustomActionTypeContinue         = 0x00000040,  // ignore action return status, continue running
	msidbCustomActionTypeAsync            = 0x00000080,  // run asynchronously
	
	// execution scheduling flags               // default is execute whenever sequenced
	msidbCustomActionTypeFirstSequence    = 0x00000100,  // skip if UI sequence already run
	msidbCustomActionTypeOncePerProcess   = 0x00000200,  // skip if UI sequence already run in same process
	msidbCustomActionTypeClientRepeat     = 0x00000300,  // run on client only if UI already run on client
	msidbCustomActionTypeInScript         = 0x00000400,  // queue for execution within script
	msidbCustomActionTypeRollback         = 0x00000100,  // in conjunction with InScript: queue in Rollback script
	msidbCustomActionTypeCommit           = 0x00000200,  // in conjunction with InScript: run Commit ops from script on success

	// security context flag, default to impersonate as user, valid only if InScript
	msidbCustomActionTypeNoImpersonate    = 0x00000800,  // no impersonation, run in system context
#if (_WIN32_MSI >= 150)
	msidbCustomActionTypeTSAware          = 0x00004000,  // impersonate for per-machine installs on TS machines
#endif // (_WIN32_MSI >= 150)

#if (_WIN32_MSI >= 150)
	// script requires 64bit process
	msidbCustomActionType64BitScript      = 0x00001000,  // script should run in 64bit process

	// don't record the contents of the Target field in the log file.
	msidbCustomActionTypeHideTarget       = 0x00002000,
#endif // (_WIN32_MSI >= 150)
};
Visual Studioで出来ない、orcaで出来る事

例)デスクトップなどに置くショートカットを、アドバタイズショートカットではなく、通常のものにする

  • OrcaMSIファイルを開き、PropertyテーブルにProperty「DISABLEADVTSHORTCUTS」、Value「1」の行を追加する