トップ 履歴 一覧 カテゴリ ソース 検索 ヘルプ RSS ログイン

Win32/WindowsInf

INDEX

Windows INFファイル

Windows 95、Windows NT 4.0、及び Windows 98 には最初から セットアップエンジンが入っており、 INF ファイルというセットアップスクリプトを一つ作成し、それを実行するだけで あなたのアプリケーションを各場所へコピーしたり、レジストリに登録、ショートカットの作成、更にはアンインストール情報を登録し、コントロールパネルからアプリケーションをアンインストールすることも可能です。

Windows XP になってもINFファイル(とセットアップエンジン)自体は健在だか、インストーラは WindowsInstallor、バッチ処理は WindowsSprictHost などに変りつつある。なにより、INFファイルではロングファイル名を扱うことが出来ない。また、Program Files に対応する LDID も存在しない。

セッション名一覧

 Version section

INFファイルには必ず必要なセクション。Windows 用 INF の標準ヘッダー。もし、ヘッダーが $Chicago$ 以外の場合、Windows は、そのファイルを INFファイルとして扱わない。NT用の場合は、"$Windows NT$" と記述すべきみたいですが、"$Chicago$" でも問題なく動く。

[Version]
Signature="$Chicago$"

 Install sections

Copy File sections (CopyFiles)

Rename Files sections (RenFiles)

Delete Files sections (DelFiles)

Update .ini File sections (UpdateInis)

Update .ini Fields sections (UpdateIniFields)

Add Registry sections (AddReg)

Delete Registry sections (DelReg)

Add Ini File to Registry sections (Ini2Reg)

Update Config.sys sections (UpdateCfgSys)

Update Autoexec.bat sections (UpdateAutoBat)

 DestinationDirs section

 SourceDisksNames section

 SourceDisksFiles section

 Strings section

 Optional Components section

LDID一覧

元ネタ:http://hp.vector.co.jp/authors/VA006065/scripts/ldid.txt

LDID は Logical Disk IDentifier の略で CSIDL の前身みたいなもの。

.INF で指定したLDID、%00%〜%99% までが実際にどう展開されるかに付いての実験結果。なお %1% と %01% は、同じとのこと(00〜09まで)。

実験対象は Windows 95 (4.00.950) を C:\WIN95 にインストールしたもの。IE も Office もサービスパックも入れていない、殆ど素の OS 状態でテスト。実験用 INF は、C:\USR に入れて右クリック後、Install を選択して実行。

LDID 説明 結果
00 Null LDID %0%
01 Infを実行したフォルダ C:\USR
02 Win95 Setup時のみ有効 C:\WININST0.400
03 Uninstall C:\UNINSTAL.000
04 Backup C:\UNINSTAL.000
05 Infフォルダ C:\WIN95\INF
06 (なし) %6%
〜 【同じく(なし)なので省略】
09 (なし) %9%
10 Windowsフォルダ C:\WIN95
11 Windowsシステムフォルダ C:\WIN95\SYSTEM
12 IO Subsystemフォルダ C:\WIN95\SYSTEM\IOSUBSYS
13 DOS コマンドフォルダ C:\WIN95\COMMAND
14 Control Panel %14%
15 Printers %15%
16 Workgroup %16%
17 Inf フォルダ C:\WIN95\INF
18 Help フォルダ C:\WIN95\HELP
19 Administration C:\WIN95
20 Fonts フォルダ C:\WIN95\FONTS
21 Viewers フォルダ C:\WIN95\VIEWERS
22 VMM32 フォルダ C:\WIN95\SYSTEM\VMM32
23 Color フォルダ (*.ICM) C:\WIN95\SYSTEM\COLOR
24 Applications directory C:\
25 Shared directory C:\WIN95
26 Winboot C:\WIN95
27 Machine specific C:\
28 Host Winboot C:\WIN95
29 (なし) %29%
30 Boot drive のルート C:\
31 virtual boot drive root C:\
32 Old Windowsフォルダ C:\WINBOOT (環境依存?)
33 Old MS-DOSフォルダ (空文字) (環境依存?)
34 (なし) %34%
49 (なし) %49%
50 %windir%\system %50%
51 Spool directory %51%
52 Spool drivers directory %52%
53 User Profile directory %53%
54 Path to ntldr or OSLOADER.EXE %54%
55 (なし) %55%
99 (なし) %99%

説明の太字は、SDKやMSDNで説明がある(公式なLDID)。結果の斜体は、存在しないフォルダ。

サンプルINFファイル

INFファイルの実行

INFファイルをコマンドライン等から実行するには次のようなコマンドで実行できます。

RUNDLL32 SETUPAPI.DLL,InstallHinfSection DefaultInstall 132 InfFilePath.inf

上記のコマンド中の InfFilePath.inf はINFファイルのショートファイル名をフルパスで記述する。また、DefaultInstall は実行するセッション名を指定する。別のセクション名(DefaultUninstall など)に変えればそのセクションを実行できます。

上記のコマンド中の 132 というマジックナンバーは下の表の "128" と "+4" を意味します。
mode 意味
0 システムが用意した .inf ファイル。
128 .inf ファイルがあるディレクトリをデフォルトのパスとして使用。
+0 常にコンピュータをリブートしない。
+1 常にコンピュータをリブートする
+2 常にユーザに確認をとってからリブートする。
+3 コンピュータをリブートする必要があればユーザの同意を得ずにリブートする。
+4 コンピュータをリブートする必要があればユーザに確認をとってからリブートする。

作成ツールとか

 Setup inf Maker 1.7 (Vector Soft Library)

インストール用セットアップ情報ファイル作成ツール

未整理分

INF Filehttp://sekida.dynsite.net/~yuuki/inf/

■Script言語(for Windows)http://hp.vector.co.jp/authors/VA006065/scripts/saruw.txthttp://hp.vector.co.jp/authors/VA006065/scripts/ldid.txthttp://hp.vector.co.jp/authors/VA006065/scripts/inf3.txthttp://hp.vector.co.jp/authors/VA006065/scripts/inf2.txthttp://hp.vector.co.jp/authors/VA006065/scripts/inf1.txt


Sample INF FileサンプルINFファイル

このINFファイルでは、以下のことがなされています。(私が参加している IE4 EX Project Team で作成した ViewEX の INF ファイルを基にしてサンプルに使用。一部訂正あり。)

ファイルを Windows, Windows\Web, Windows\Web\View, Windows\INF フォルダにコピーします。 レジストリに値を追加 (アプリケーションに必要な値、コントロールパネルで利用されるアンインストール情報、ファイル名を長いファイル名に変更するための値等)。 スタートメニューにリンクを追加。 変更を簡単に可能にするため、文字列(String)を使用。

[Version]
signature="$CHICAGO$"    ; Windows 95用ということを示す
SetupClass=BASE

[DefaultInstall]
CopyFiles    = Htt.CopyFiles, Other.CopyFiles, Inf.CopyFiles    ; コピーするファイル
AddReg        = ViewEX.AddReg, ViewEX.UninstReg, SampleRenameFiles    ; レジストリに追加
UpdateInis    = SampleAddLinks

[DefaultInstall.ntx86]    ; NTの場合、このセクションが実行される
CopyFiles    = Htt.CopyFiles, Other.CopyFiles, Inf.CopyFiles
AddReg        = ViewEX.AddReg, ViewEX.UninstRegNT, SampleRenameFiles
UpdateInis    = SampleAddLinks

[ViewEXInstall]
CopyFiles    = Htt.CopyFiles, Other.CopyFiles, Inf.CopyFiles
AddReg        = ViewEX.AddReg, ViewEX.UninstReg, SampleRenameFiles
UpdateInis    = SampleAddLinks

[DefaultUninstall]    ; ディフォルトアンインストール
DelFiles    = Htt.CopyFiles, Other.CopyFiles, Inf.CopyFiles
DelReg        = ViewEX.AddReg, ViewEX.UninstReg, SampleRemoveLFNs
UpdateInis    = SampleRemoveLinks

[DefaultUninstall.ntx86]   ; NT用のアンインストール情報
DelFiles    = Htt.CopyFiles, Other.CopyFiles, Inf.CopyFiles
DelReg        = ViewEX.AddReg, ViewEX.UninstRegNT, SampleRemoveLFNs
UpdateInis    = SampleRemoveLinks

[Inf.CopyFiles]
viewex.inf

[Htt.CopyFiles]
Viewex.htt

[Other.CopyFiles]
sample.bmp
sample.exe

[SourceDisksNames]    ; アプリケーションの名前(セットアップ時、ダイアログに表示される)
55="View EX %Version%","",1

[SourceDisksFiles]    ; コピーされるファイルがある場所
Htt.copyfiles = 55
Other.CopyFiles = 55

[DestinationDirs]    ; ファイルのコピー先を指定
Inf.CopyFiles    = 17        ; INF folder にコピー
Htt.CopyFiles    = 10,Web    ; Windows\Web Folder にコピー
Other.CopyFiles    = 10,Web\ViewEX    ; Windows\Web\View Folder にコピー

[SampleAddLinks]   ;スタートメニューに SAMPLE.EXE へのショートカットを登録
setup.ini, progman.groups,, "Sample=%SampleFolder%" ;creates folder
setup.ini, Sample,, """%SampleDesc%"", %25%\ SAMPLE.EXE" ;creates link

[SampleRemoveLinks]    ;スタートメニューから SAMPLE.EXE へのショートカットを削除
setup.ini, progman.groups,, "Sample=%SampleFolder%" ;creates folder
setup.ini, Sample,, """%SampleDesc%""" ;deletes link

[SampleRenameFiles]    ; 8.3 のファイル名をロングファイルネームに変更
HKLM,Software\Microsoft\Windows\CurrentVersion\RenameFiles\Sample,,,"%24%\%PROGRAMF%\Sample"
HKLM,Software\Microsoft\Windows\CurrentVersion\RenameFiles\Sample,sample.bmp,,"Sample Bitmap.bmp" 

[SampleRemoveLFNs]    ; ロングファイルネームのファイルを削除
HKLM,Software\Microsoft\Windows\CurrentVersion\DeleteFiles\Sample,,,"%24%\%PROGRAMF%\Sample"
HKLM,Software\Microsoft\Windows\CurrentVersion\DeleteFiles\Sample,sample.bmp,,"Sample Bitmap.bmp" 

[ViewEX.AddReg]    ; レジストリに登録
HKCR,%ViewEX%\{FCE43061-3594-11D1-9FD7-444553540000},"PersistMoniker",,"%10%\Web\viewex.htt"
HKLM,%SMWCE%\{FCE43061-3594-11D1-9FD7-444553540000},"HelpText",,"選択されたアイテムのプレビューを表示します。"
HKLM,%SMWCE%\{FCE43061-3594-11D1-9FD7-444553540000},"MenuName",,"View EX(&X)"
HKLM,%SMWCE%\{FCE43061-3594-11D1-9FD7-444553540000},"TooltipText",,"View EX"
HKCR,.inf,"Content Type",,"text/plain"

[ViewEX.UninstReg]    ; レジストリから値を削除
HKLM,%SMWCU%\ViewEX
HKLM,%SMWCU%\ViewEX,DisplayName,,"IE4 EX-Toys (View EX %Version%) - %Delete%"
HKLM,%SMWCU%\ViewEX,UninstallString,, "%10%\rundll.exe setupx.dll,InstallHinfSection DefaultUninstall 132 %17%\viewex.inf"

[ViewEX.UninstRegNT]    ; NTの場合、アンインストール時にここが起動される
HKLM,%SMWCU%\ViewEX
HKLM,%SMWCU%\ViewEX,DisplayName,,"IE4 EX-Toys (View EX %Version%) - %Delete%"
HKLM,%SMWCU%\ViewEX,UninstallString,, "RunDll32.exe syssetup.dll,SetupInfObjectInstallAction DefaultUninstall 132 %17%\viewex.inf"

[Strings]    ; 文字列
ViewEX    = "Folder\shellex\ExtShellFolderViews"
SMWCU    = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
SMWCE    = "SOFTWARE\Microsoft\Windows\CurrentVersion\ExtShellViews"
Delete    = "ツールの削除"
Version    = "Ver1.21"
SampleFolder    ="サンプルフォルダ"
SampleDesc    ="サンプルアプリケーション"
PROGRAMF    ="Progra~1"

最終更新時間:2008年11月14日 17時30分00秒 指摘や意見などあればSandBoxのBBSへ。