search
HomeWeb Front-endJS TutorialMigrate directories with JavaScript_javascript tips

In the past two days, I have used a virtual machine to install the system, and I am going to use a virtual machine to separate the development environment and the database. The ideas are as follows:
1. The development environment is the Host
2. The Guest is the database server, and each server is an independent The virtual machine
database includes Oracle 9i, SQL Server 2005, and MySQL
However, when installing the system, you also need to set environment variables to reduce system disk usage and increase performance. This requires migrating some directories on the system disk. For example, IE temporary directory, temporary folder, Applocation Data; in addition, we also need to move important folders to other partitions to avoid important data (MyDocument, Favorites, Programs) when an accident occurs on the system disk or when we want to restore it. configuration, etc.) are not affected.
Manually modifying environment variables and registry values ​​is too troublesome, because I have to modify them every time I install the system. This time I have had enough, and I feel bad. Okay, I'll write a script and get it done for you!
BAT cannot set system environment variables. In addition, VBScript and JScript are available. The advantage of VBScript is that it has a dialog box, but JScript does not (alert, etc. can only be used in web pages), and JScript's code is clearer. , and it is powerful and can use functions such as regular expressions.
So, I wrote the following script, please see the code:

Copy the code The code is as follows :
//******************************************************************** 
// Copymiddle 2006 Zealic,All middle keeped. 
//******************************************************************** 
//** 环境变量名 
//** 设置环境变量名,这些值影响环境变量的名字,建议不要修改 
var VN_PATH        = "PATH"; 
var VN_PROFILE        = "PROFILE"; 
var VN_PROFILE_USER    = "PROFILE_USER"; 
var VN_VOLATILE_PROFILE    = "VOLATILE_PROFILE"; 
var VN_TEMP        = "TEMP"; 


//******************************************************************** 
//** 设置 

var m_Prefix        = "GUEST_"; 
var m_UserName        = "Zealic"; 
var m_Profile        = "D:\\Profile"; 
var m_VoltProfile    = "F:\\VolatileProfile"; 
var m_UserPath        = "C:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727;"  
                + "D:\\Java\\JRE\\Currently\\bin"; 

//调用函数以设置 
SetEnvironment(m_Prefix,m_UserName,m_Profile,m_VoltProfile,m_UserPath); 


//******************************************************************** 
//** 函数定义 

// 设置环境变量 
//     prefix         : 环境变量名的前缀 
//     userName    : 用户名 
//     profile        : 重要文件目录 
//     voltProfile    : 非重要文件目录 
//     userPath    : 用户 Path,设置该值以进行快捷运行程序 
function SetEnvironment(prefix,userName,profile,voltProfile,userPath) 

    //开始设置 
    var currentName; 
    //=========================== 
    // 设置系统重要目录 
    currentName = prefix + VN_PROFILE; 

    SetSystemValue(currentName, profile); 

    // 设置设置用户重要目录 
    currentName = prefix + VN_PROFILE_USER; 
    SetSystemValue(currentName, "%" + prefix + VN_PROFILE + "%\\" + userName); 

    // 设置设置系统非重要目录 
    currentName = prefix + VN_VOLATILE_PROFILE; 
    SetSystemValue(currentName, voltProfile); 

    // 设置设置用户非重要目录 
    currentName = prefix + "VOLATILE_PROFILE_USER"; 
    SetSystemValue(currentName, "%" + prefix + VN_VOLATILE_PROFILE + "%" + "\\" + userName); 

    // 设置临时目录 
    currentName = prefix + "TEMP"; 
    SetSystemValue(currentName, "%" + prefix + VN_VOLATILE_PROFILE + "%" + "\\Temporary"); 

    //设置TEMP变量 
    var temp = "%" + prefix + VN_TEMP + "%"; 
    SetUserValue("TMP", temp); 
    SetUserValue("TEMP", temp); 
    SetSystemValue("TMP", temp); 
    SetSystemValue("TEMP", temp); 

    // 设置 Path 和 自定义 Path 连接 
    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") ";%" 접두사 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( 이름,값)
{
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이 자주 정리될 수 있다는 것을 명확하게 알 수 있습니다.
그 후에도 데스크톱, 내 문서, 즐겨찾기 폴더를 프로필 디렉터리로 마이그레이션한 다음 데이터베이스 설치를 시작해야 합니다.
그런데 오늘은 늦었으니 내일 얘기하자~~~
내일은 JScript를 이용하여 레지스트리를 운영하여 시스템의 일부 디렉터리를 Profile 및 VolatileProfile 디렉터리로 마이그레이션할 예정입니다.
http://www.cnblogs.com/zealic/archive/2006/11/07/552433.html
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
JavaScript in Action: Real-World Examples and ProjectsJavaScript in Action: Real-World Examples and ProjectsApr 19, 2025 am 12:13 AM

JavaScript's application in the real world includes front-end and back-end development. 1) Display front-end applications by building a TODO list application, involving DOM operations and event processing. 2) Build RESTfulAPI through Node.js and Express to demonstrate back-end applications.

JavaScript and the Web: Core Functionality and Use CasesJavaScript and the Web: Core Functionality and Use CasesApr 18, 2025 am 12:19 AM

The main uses of JavaScript in web development include client interaction, form verification and asynchronous communication. 1) Dynamic content update and user interaction through DOM operations; 2) Client verification is carried out before the user submits data to improve the user experience; 3) Refreshless communication with the server is achieved through AJAX technology.

Understanding the JavaScript Engine: Implementation DetailsUnderstanding the JavaScript Engine: Implementation DetailsApr 17, 2025 am 12:05 AM

Understanding how JavaScript engine works internally is important to developers because it helps write more efficient code and understand performance bottlenecks and optimization strategies. 1) The engine's workflow includes three stages: parsing, compiling and execution; 2) During the execution process, the engine will perform dynamic optimization, such as inline cache and hidden classes; 3) Best practices include avoiding global variables, optimizing loops, using const and lets, and avoiding excessive use of closures.

Python vs. JavaScript: The Learning Curve and Ease of UsePython vs. JavaScript: The Learning Curve and Ease of UseApr 16, 2025 am 12:12 AM

Python is more suitable for beginners, with a smooth learning curve and concise syntax; JavaScript is suitable for front-end development, with a steep learning curve and flexible syntax. 1. Python syntax is intuitive and suitable for data science and back-end development. 2. JavaScript is flexible and widely used in front-end and server-side programming.

Python vs. JavaScript: Community, Libraries, and ResourcesPython vs. JavaScript: Community, Libraries, and ResourcesApr 15, 2025 am 12:16 AM

Python and JavaScript have their own advantages and disadvantages in terms of community, libraries and resources. 1) The Python community is friendly and suitable for beginners, but the front-end development resources are not as rich as JavaScript. 2) Python is powerful in data science and machine learning libraries, while JavaScript is better in front-end development libraries and frameworks. 3) Both have rich learning resources, but Python is suitable for starting with official documents, while JavaScript is better with MDNWebDocs. The choice should be based on project needs and personal interests.

From C/C   to JavaScript: How It All WorksFrom C/C to JavaScript: How It All WorksApr 14, 2025 am 12:05 AM

The shift from C/C to JavaScript requires adapting to dynamic typing, garbage collection and asynchronous programming. 1) C/C is a statically typed language that requires manual memory management, while JavaScript is dynamically typed and garbage collection is automatically processed. 2) C/C needs to be compiled into machine code, while JavaScript is an interpreted language. 3) JavaScript introduces concepts such as closures, prototype chains and Promise, which enhances flexibility and asynchronous programming capabilities.

JavaScript Engines: Comparing ImplementationsJavaScript Engines: Comparing ImplementationsApr 13, 2025 am 12:05 AM

Different JavaScript engines have different effects when parsing and executing JavaScript code, because the implementation principles and optimization strategies of each engine differ. 1. Lexical analysis: convert source code into lexical unit. 2. Grammar analysis: Generate an abstract syntax tree. 3. Optimization and compilation: Generate machine code through the JIT compiler. 4. Execute: Run the machine code. V8 engine optimizes through instant compilation and hidden class, SpiderMonkey uses a type inference system, resulting in different performance performance on the same code.

Beyond the Browser: JavaScript in the Real WorldBeyond the Browser: JavaScript in the Real WorldApr 12, 2025 am 12:06 AM

JavaScript's applications in the real world include server-side programming, mobile application development and Internet of Things control: 1. Server-side programming is realized through Node.js, suitable for high concurrent request processing. 2. Mobile application development is carried out through ReactNative and supports cross-platform deployment. 3. Used for IoT device control through Johnny-Five library, suitable for hardware interaction.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool