用 JavaScript 迁移目录

2019-06-03 14:03:08于海丽

    var currentName = prefix + VN_PATH; 
    SetSystemValue(currentName, userPath); 
    // 检测是否已经存在Path,如果不存在则设置 
    var regValue = new RegExp("%" + prefix + VN_PATH + "%","i"); 
    if(!regValue.test(GetSystemValue("Path"))) 
    { 
        SetSystemValue("Path",GetSystemValue("Path") + ";%" + prefix + VN_PATH + "%"); 
    } 


// 调试用函数 
function Debug(msg) 

    wsh = new ActiveXObject("WScript.Shell"); 
    wsh.Popup(msg); 


// 获取用户环境变量 
function GetUserValue(name,value) 

    wsh = new ActiveXObject("WScript.Shell"); 
    return wsh.Environment("user").Item(name); 

// 设置用户环境变量 
function SetUserValue(name,value) 

    wsh = new ActiveXObject("WScript.Shell"); 
    wsh.Environment("user").Item(name) = value; 

// 删除用户环境变量 
function RemoveUserValue(name) 

    wsh = new ActiveXObject("WScript.Shell"); 
    wsh.Environment("user").Remove(name) = value; 

// 获取系统环境变量 
function GetSystemValue(name,value) 

    wsh = new ActiveXObject("WScript.Shell"); 
    return wsh.Environment("system").Item(name); 

// 设置系统环境变量 
function SetSystemValue(name,value) 

    wsh = new ActiveXObject("WScript.Shell"); 
    wsh.Environment("system").Item(name) = value; 

// 删除系统环境变量 
function RemoveSystemValue(name) 

    wsh = new ActiveXObject("WScript.Shell"); 
    wsh.Environment("system").Remove(name) = value; 

   其中 Profile 为有价值的数据和文件 ,VolatileProfile 用过而无价值的数据和文件。这样,我们就可以清楚的知道,Profile 要保留,VolatileProfile 则可以经常清理。
   之后我还需要把 Desktop,My Document,Favorites文件夹迁移到 Profile 目录中,然后就开始安装数据库。