我正在VS2010中构建安装程序,并希望在卸载后运行脚本(删除许可证文件)。我发现JScript是Windows 7的脚本语言,并且实现了一个简单的脚本来删除目录(工作正常):
var wshShell = WScript.CreateObject("WScript.Shell");
var result = wshShell.Popup("Remove license?", 0, "Remove license?", 4);
if (result == 6) {
var license_dir = wshShell.ExpandEnvironmentStrings("%ProgramData%");
license_dir += "\\<my product>";
var fso;
fso = new ActiveXObject("Scripting.FileSystemObject");
if (fso.FolderExists(license_dir)) {
fso.DeleteFolder(license_dir, true);
} else {
WScript.Echo(license_dir + " didn't exist. Nothing removed.");
}
}
我的问题是,这是一种有效且(更重要的)可移植方式吗?