zoukankan      html  css  js  c++  java
  • HOWTO:安装包卸载时如何删除安装时写在系统环境变量中的内容

    在用InstallShield制作安装包时,有时我们会在脚本中通过操作注册表,配置系统环境变量,比如在Path中追加,但卸载时如何清除追加的路径变量,一直有些模糊。

    今天受网友启发,在InstallShield的帮助文档中找到了解决办法,代码如下:

    function OnBegin()  
        
    STRING svSearchPath;
    begin
        // Set up the search path to pass as a parameter to PathSet. 
        svSearchPath 
    = "C:\\DOS;C:\\WINDOWS;C:\\TEMP;" + 
                       
    "D:\\Program Files\\Kevin Wan\\InstallShield;" + 
                       
    "C:\\EXAMPLE\\SOURCE;D:\\WORK\\TEMP"

        // Initialize the path buffer. 
        
    PathSet (svSearchPath); 

        // Display the initial search path. 
        // Delete D:\Program Files\Kevin Wan\InstallShield from the path buffer.                      

        if (PathDelete ("Kevin Wan"PARTIAL<0then    

            MessageBox ("First call to PathDelete failed.", SEVERE); 
        endif

        // Get the search path from the path buffer; this call also releases 
        
    // the memory allocated for the path buffer. 

        PathGet (svSearchPath); 
        
    MessageBox(svSearchPath, INFORMATION);
    end;

    这里我将Sample添加到了事件响应函数OnBegin中,大家实际操作时可以写到卸载逻辑代码中。

    Sample中我删除了和Kevin Wan相关的路径,但也要注意,这里最好选择唯一标示的字符串,否则可能会把其他程序写入的路径变量也同时删除了。

    版权声明: 转载时请务必以超链接形式标明文章原始出处和作者信息  

  • 相关阅读:
    软件杯学习:python爬虫爬取新浪新闻并保存为csv格式
    操作系统实验1:时间片轮转和存储管理动态分区分配及回收
    软件测试
    实验6-使用TensorFlow完成线性回归
    实验一
    pycharm中设置anaconda环境
    架构之美读书笔记一
    2.1学习总结:决策树分类器
    python自学日记一
    爱甩卖网站正式上线啦
  • 原文地址:https://www.cnblogs.com/wanbinghong/p/1943406.html
Copyright © 2011-2022 走看看