我想提出一个安装程序注册,并要检查是否WCF已经与IIS我怎么能检查是否WCF已经与IIS
4
A
回答
0
servicemodelreg.exe -lv
+0
如何以编程方式检查它 – 2010-03-10 13:54:46
1
检查登记用于IIS ScriptMaps中的.svc扩展。要做到这一点,您可以使用WIX自定义操作中的WMI,这些操作以Javascript,VBScript或C/C++实现。这里是一个例子在Javascript中:
// IsWcf.js
// ------------------------------------------------------------------
//
// detect if WCF is installed; suitable for use within a WIX Custom Action.
//
// Copyright 2010, Cheeso.
//
// Licensed under the MS Public License
// http://opensource.org/licenses/ms-pl.html
//
// To use this as a Custom Action in a WIX project, register it this way:
//
// <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
// <Fragment>
// <Binary Id="B.JavaScript" SourceFile="CustomActions.js" />
// <CustomAction Id="CA.DetectWcf"
// BinaryKey="B.JavaScript"
// JScriptCall="DetectWcf_CA"
// Execute="immediate"
// Return="check" />
// </Fragment>
// </Wix>
//
// And invoke it this way:
//
// <InstallUISequence>
// <Custom Action="CA.DetectWcf" After="CostFinalize" Overridable="yes">NOT Installed</Custom>
// </InstallUISequence>
//
//
// =======================================================
// http://msdn.microsoft.com/en-us/library/aa371254(VS.85).aspx
var MsiActionStatus = {
None : 0,
Ok : 1, // success
Cancel : 2,
Abort : 3,
Retry : 4, // aka suspend?
Ignore : 5 // skip remaining actions; this is not an error.
};
var MsgKind = {
Error : 0x01000000,
Warning : 0x02000000,
User : 0x03000000,
Log : 0x04000000
};
// Format a number as hex. Quantities over 7ffffff will be displayed properly.
function decimalToHexString(number) {
if (number < 0)
number = 0xFFFFFFFF + number + 1;
return number.toString(16).toUpperCase();
}
function LogMessage(s) {
LogMessage2(s,MsgKind.Log);
}
function LogMessage2(s,kind){
if (typeof Session !== "undefined") {
var record = Session.Installer.CreateRecord(0);
record.StringData(0) = "CustomActions: " + msg;
Session.Message(kind, record);
}
else {
WScript.echo(s);
}
}
function LogException(loc, exc) {
var s = "Exception {" + loc + "}: 0x" + decimalToHexString(exc.number) + " : " + exc.message;
if (typeof Session !== "undefined") {
var record = Session.Installer.CreateRecord(0);
record.StringData(0) = s;
Session.Message(MsgKind.Error + Icons.Critical + Buttons.btnOkOnly, record);
}
else {
LogMessage(s);
}
}
function stringEndsWith(subject, end) {
return (subject.match(end+"$") == end);
}
function DetectWcf_CA(website) {
try {
LogMessage("DetectWcf_CA() ENTER");
if (website == null) {
website = "W3SVC"; // default value
}
LogMessage("website name(" + website + ")");
var query = (website == "W3SVC")
? "SELECT * FROM IIsWebServiceSetting"
: "SELECT * FROM IIsWebServerSetting WHERE Name = '" + website + "'";
var iis = GetObject("winmgmts://localhost/root/MicrosoftIISv2");
var settings = iis.ExecQuery(query);
LogMessage("WMI Query results : " + typeof settings);
if (settings == null) {
LogMessage("Cannot query IIS.");
return MsiActionStatus.Abort;
}
var item;
if (settings.Count != 0) {
for(var e = new Enumerator(settings); !e.atEnd(); e.moveNext()) {
item = e.item();
}
}
var scriptMaps = item.ScriptMaps.toArray();
var isSvcMapPresent = false;
var svcMapIndex = -1;
for (var i=0; i<scriptMaps.length; i++) {
var map = scriptMaps[i];
for(var e = new Enumerator(map.Properties_); !e.atEnd(); e.moveNext()) {
item = e.item();
if (item.Name == "Extensions" && item.Value == ".svc" && svcMapIndex == -1) {
svcMapIndex = i;
}
else if (i == svcMapIndex && item.Name == "ScriptProcessor" && stringEndsWith(item.Value,"aspnet_isapi.dll")) {
isSvcMapPresent = true;
}
}
}
LogMessage("DetectWcf_CA(): Is WCF Present?: " + isSvcMapPresent);
// works in WIX Custom Action only:
if (typeof Session !== "undefined") {
Session.Property("ISWCF") = (isSvcMapPresent) ? "1" : "0";
}
LogMessage("DetectWcf_CA() EXIT (Ok)");
}
catch (exc1) {
LogException("DetectWcf_CA", exc1);
return MsiActionStatus.Abort;
}
return MsiActionStatus.Ok;
}
// actually run it, only if being invoked outside of WIX
if (typeof Session == "undefined") {
DetectWcf_CA("W3SVC") ;
}
相关问题
- 1. 我怎么能检查PHP
- 2. 检查'onload'是否已经被触发?
- 3. 检查magento是否已经运行cronjob
- 4. 检查cronjob是否已经运行
- 5. rake检查是否已经运行
- 6. 检查文件是否已经打开
- 7. 检查GLUT是否已经初始化?
- 8. 检查数据是否已经存在
- 9. 检查用户是否已经登录?
- 10. 检查表单是否已经存在
- 11. Rails,检查url是否已经存在
- 12. 检查jQuery“Fancybox”是否已经注册?
- 13. Codeigniter:我怎么知道模型是否已经加载?
- 14. 我怎么知道用户是否已经离开了页面?
- 15. 我怎么能检查对象是否存在于C++
- 16. 我怎么能检查双倍值是否溢出
- 17. 可能检查笔尖是否已经加载?
- 18. 检查图像是否已经缓存与jQuery
- 19. 检查电子邮件是否已经存在与JQuery
- 20. 如何检查我是否已经快速添加节点?
- 21. 我们可以检查intent.putExtras(key,value)是否已经完成?
- 22. 检查我是否已经插入特定记录
- 23. 我怎么能找到我的.RDA已经加载到R
- 24. 我怎么能进行打印上,我已经cretaed
- 25. 检查IIS是否安装?
- 26. 我们怎样才能检查一个用户是否已经在电报帐户或不使用PHP?
- 27. BLE - 我怎么能检查做广告
- 28. 我怎么能检查事件日历
- 29. 我有什么选择来检查IntentService是否已经在运行?
- 30. libmemcached - 检查我是否已连接
这将是一种方式。 – Cheeso 2010-03-10 13:31:02
我使用ServiceModelReg.exe注册到IIS – 2010-03-10 13:32:17