HOWTO:如果制作卸载时需要确认密码的安装包
2010-09-15 15:59 Kevin.Wan 阅读(3435) 评论(0) 编辑 收藏 举报版权声明: 可以任意转载,转载时请务必以超链接形式标明文章原始出处和作者信息。
很早之前记得有朋友问到如何让自己的安装包在目标机上卸载时,进行密码确认,避免本机其他用户误卸载程序。
卸载需要密码确认,那自然是在安装时由用户设置卸载密码,代码如下:
代码
1 function OnBegin()
2 string szQuestion, szDefault, svResult, svValue;
3 begin
4 // TODO: Perform custom initialization steps, check requirements, etc.
5
6 if (!MAINTENANCE) then
7 // set variable value during first time install
8 szQuestion = "Please enter your uninstall password";
9 szDefault = "Default";
10 AskText ( szQuestion , szDefault , svResult );
11
12 //set the variable using the TextSub object
13 TextSub.Value("MyVar") = svResult;
14 else
15 // retrieve value during maintenance setup
17 svValue = TextSub("MyVar");
18
19 szQuestion = "Please enter your uninstall password";
20 szDefault = "";
21 AskText ( szQuestion , szDefault , svResult );
22
23 if ( StrCompare(svResult,svValue) != 0 ) then
24 MessageBox("Uninstall password is invalid, please contact with your adminstrator.", SEVERE);
25 abort;
26 endif;
27 endif;
28 end;
2 string szQuestion, szDefault, svResult, svValue;
3 begin
4 // TODO: Perform custom initialization steps, check requirements, etc.
5
6 if (!MAINTENANCE) then
7 // set variable value during first time install
8 szQuestion = "Please enter your uninstall password";
9 szDefault = "Default";
10 AskText ( szQuestion , szDefault , svResult );
11
12 //set the variable using the TextSub object
13 TextSub.Value("MyVar") = svResult;
14 else
15 // retrieve value during maintenance setup
17 svValue = TextSub("MyVar");
18
19 szQuestion = "Please enter your uninstall password";
20 szDefault = "";
21 AskText ( szQuestion , szDefault , svResult );
22
23 if ( StrCompare(svResult,svValue) != 0 ) then
24 MessageBox("Uninstall password is invalid, please contact with your adminstrator.", SEVERE);
25 abort;
26 endif;
27 endif;
28 end;
还有一种情况,就是安装时不提示设置密码,将密码直接通过硬编码的方式设置到安装包中,这种主要是避免用户随意卸载,当然卸载口令掌握在该软件的Vendor手中。
将上述代码稍作修改就可以做到,记得没错的话,这种安装包在杀毒软件Norton的安装包中见过,不过好像是企业重新打包添加进去的。
万炳宏(Kevin Wan)
Avizo/Amira技术交流,欢迎加我微信:13911850365或QQ:17842153