杉宫竹苑工作室

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 2196|回复: 0

使用Setup Factory修改Path变量的方法

[复制链接]
发表于 2016-8-28 19:35:28 | 显示全部楼层 |阅读模式

正式会员享受无限制浏览网站功能和高速网盘下载,赶快加入本站吧!

您需要 登录 才可以下载或查看,没有账号?立即注册

x
在Setup Factory中脚本如下:
  1. strPath = Registry.GetValue(HKEY_CURRENT_USER, "Environment", "path", true);

  2.   if strPath ~= "" then

  3.   strPath = String.Concat(strPath, ";");

  4.   end

  5.   strPathToAdd = SessionVar.Expand("%AppFolder%");

  6.   strPathToAdd = String.Concat(strPathToAdd,"file://MATLAB6p5//bin//win32");

  7.   -- 如果路径中无该位置,则加入

  8.   if String.Find(strPath,strPathToAdd) == -1 then

  9.   strPath = String.Concat(strPath, strPathToAdd);

  10.   Registry.SetValue(HKEY_CURRENT_USER, "Environment", "path", strPath, REG_SZ);

  11.   end
复制代码

这个是修改用户环境变量的,如果想要修改系统环境变量,可以修改\HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001
\Control\Session Manager\Environment\Path.
另附环境变量和注册表的对应关系:
环境变量分为两类:用户变量与系统变量,在注册表中都有对应的项。其中用户变量所在位置:
HKEY_CURRENT_USER\Environment;系统变量所在位置为:\HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001
\Control\Session Manager\Environment。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|手机版|Archiver|SgzyStudio

GMT+8, 2024-5-15 17:24 , Processed in 0.101035 second(s), 18 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表