ひきこもりプログラマ

C++のこととか。

VBScript(オートメーション)でVisual SourceSafe内の不要ファイルリストを作る

2008-01-25 | Program
VBScriptを使ったSourceSafeオートメーションを見たら,超かんたんっぽかったので早速使わせていただきました。汚物は消毒だー!
Option Explicit
' 本来Visual SourceSafeに格納すべきではないのにされてしまっている
' Visual Studio中間ファイル類(とサイズ,ただし履歴ぶんは除く)を列挙します
' 注意1: cscript.exeから実行しないとStdOutハンドルは無効
' 注意2: VSSItem.SizeプロパティはVSS6.0非対応

Const VSSITEM_PROJECT = 0
Const VSSITEM_FILE = 1

Const SourceSafeIni = "\\YourServer\Shared\VSS\srcsafe.ini"
Const Username = "guest"
Const Password = ""

' 削除されたファイルもカウントするかどうか
Const IncludeDeleted = True

' 引数としてプロジェクトパスが渡せます
Dim RootPath
If 0 < WScript.Arguments.Length Then
	RootPath = WScript.Arguments(0)
Else
	RootPath = "$/"
End If

Dim GbgExp
Set GbgExp = new RegExp
GbgExp.Pattern = "(.pch$)|(.idb$)|(.obj$)|(.res$)|(.sbr$)|(.bsc$)|(.ilk$)|(.map$)|(.pdb$)|(.opt$)|(.suo$)|(.ncb$)|(.clw$)|(.aps$)"
' お好みでもっと増やしてください

Sub DispSize(ByVal Project)
	Dim item, items
	Set items = Project.Items(IncludeDeleted)
	For Each item in items
		If item.Type = VSSITEM_PROJECT Then
			DispSize(item)
		ElseIf item.Type = VSSITEM_FILE Then
			Dim matches
			Set matches = GbgExp.Execute(item.Name)
			If 0 < matches.Count Then
				Dim match
				For Each match In matches
					On Error Resume Next
					WScript.StdOut.WriteLine(item.Size & vbTab & item.Spec & vbTab & match)
				Next
			End If
		End If
	Next
End Sub

Dim SsDb
Set SsDb = CreateObject("SourceSafe")
SsDb.Open SourceSafeIni, Username, Password

Dim RootProj
Set RootProj = SsDb.VSSItem(RootPath)
DispSize(RootProj)

Windows Vista UACとWindows Installer

2008-01-08 | Program
InstallShield 12で作成したランチャ(setup.exe)をVistaで実行したとき,盾アイコンがついていないのにもかかわらずインストールがうまくいってしまいます。最初はWindows Vista Application Development Requirements for User Account Control Compatibilityに載っていた「ファイル名にinstallとかsetupとかupdateとかが含まれていると昇格する」処理のせいだと思っていたのですが,setup.exeをよく見るとmanifestが埋め込んであってrequestedExecutionLevelがasInvokerで指定してあります。これではファイル名チェックは走らないはずなのに。あれえ?

実はInstallShieldの[インストール情報]→[一般情報]→[概要情報ストリーム]で「管理者特権が必要」=「はい」となっていたので,Windows Installer 4.0が勝手に昇格してくれていたようです。Word Count Summary属性がどうとか。詳しくはMinimizing the Number of User Account Control Prompts During Installationを参照のこと。