Some Linux tools are placed in the file location under the Windows version

Source: Internet
Author: User

First explain the common variables under Windows (this is XP, Win7 and above C:\Documents and settings are actually C:\Users)

%systemdrive% the partition number where the operating system is located. such as C:

%SystemRoot% operating system root directory. such as C:\WINDOWS

%windir% operating system root directory. such as C:\WINDOWS

%allusersprofile% equivalent to C:\Documents and Settings\All Users C:\ProgramData

%appdata% equivalent to C:\Documents and Settings\ user Directory \application Data C:\Users\Guangshan\AppData\Roaming

%ProgramFiles% equivalent to C:\Program Files

%commonprogramfiles% equivalent to C:\Program files\common Files

%homedrive% the partition number where the operating system is located. such as: C:

%homepath% equivalent to \documents and Settings\ user directory \users\guangshan

%USERPROFILE% equivalent to C:\Documents and Settings\ user directory C:\Users\Guangshan

%homedrive% = c \ The partition where the system is currently started
%SystemRoot% = C:\WINDOWS The directory where the system is currently started
%windir% =%SystemRoot% = C:\WINDOWS The directory where the system is currently started
%USERPROFILE% = C:\Documents and settings\sihochina Current user data variable
%homepath% = C:\Documents and Settings\sihochina Current user environment variable
%system% = C:\WINDOWS\SYSTEM32

%allusersprofile%: Lists the location of all user profile files.
%appdata%: Lists the default storage location for application data.
%cd%: Lists the current directory.
%clientname%: Lists the NetBIOS name of the client when joining to a Terminal Services session.
%cmdcmdline%: Lists the command line used to start the current Cmd.exe.
%cmdextversion%: Command out the current command handler extension version number.
%commonprogramfiles%: Lists the folder paths for commonly used files.
%computername%: The computer name is listed.
%comspec%: Lists the path to the executable command shell (command handler).
%date%: Lists the current date.
%errorlevel%: Lists the error codes for the most recently used commands.
%homedrive%: Lists the drive letter that resides with the user's home directory.
%homepath%: Lists the full path to the user's home directory.
%homeshare%: Lists the network path of the user's shared home directory.
%logonsever%: Lists the name of the domain controller that is valid for the current logon session.
%number_of_processors%: Lists the number of processors installed on the computer.
%os%: Lists the name of the operating system. (Windows XP and Windows 2000 are listed as WINDOWS_NT.)
%Path%: Lists the search paths for the executable files.
%pathext%: Lists the file name extensions that the operating system thinks can be executed.
%processor_architecture%: Lists the processor's chip architecture.
%processor_identfier%: A description of the processor is listed.
%processor_level%: Lists the model number of the computer's processor.
%processor_revision%: The revision number of the processor is listed.
%ProgramFiles%: Lists the path to the Program Files folder.
%prompt%: Lists the command prompt settings for the current command interpreter.
%random%: Lists the random decimal numbers bounded between 0 and 32767.
%sessionname%: Lists the connection and session name when connecting to a Terminal Services session.
%systemdrive%: Lists the drive where the Windows startup directory resides.
%SYSTEMROOT%: The location of the Windows startup directory is listed.
%temp% and%TMP%: Lists the default temporary directories for applications that are currently logged on by the user.
%time%: Lists the current time.
%userdomain%: Lists the name of the domain that contains the user account.
%USERNAME%: Lists the name of the user who is currently logged on.
%USERPROFILE%: Lists the current user profile location.
%WINDIR%: Lists the location of the operating system directory.

Variable type description
%allusersprofile% returns the location of the "All users" profile locally.
%appdata% Local returns the location by default where the application stores data.
%cd% returns the current directory string locally.
%cmdcmdline% Local returns the exact command line used to start the current Cmd.exe.
The%cmdextversion% system returns the version number of the current command handler extension.
The%computername% system returns the name of the computer.
The%comspec% system returns the exact path to the command-line interpreter executable program.
The%date% system returns the current date. Use the same format as the date/t command. Generated by Cmd.exe. For more information about the date command, see Date.
The%errorlevel% system returns the error code for the previous command. Errors are usually indicated by a value other than 0.
The%homedrive% system returns the local workstation drive letter that is connected to the user's home directory. Set based on the value of the home directory. The user home directory is specified in Local Users and groups.
The%homepath% system returns the full path of the user's home directory. Set based on the value of the home directory. The user home directory is specified in Local Users and groups.
The%homeshare% system returns the network path of the user's shared home directory. Set based on the value of the home directory. The user home directory is specified in Local Users and groups.
%logonserver% Local returns the name of the domain controller that verifies the current logon session.
The%number_of_processors% system specifies the number of processors installed on the computer.
The%os% system returns the operating system name. Windows 2000 displays its operating system as WINDOWS_NT.
The%PATH% system specifies the search path for the executable file.
The%pathext% system returns a list of file name extensions that the operating system considers executable.
The%processor_architecture% system returns the chipset architecture of the processor. Value: x86 or IA64 (Itanium-based).
The%processor_identfier% system returns the processor description.
The%processor_level% system returns the model number of the processor installed on the computer.
The%processor_revision% system returns the version number of the processor.
%prompt% returns the command prompt settings for the current interpreter locally. Generated by Cmd.exe.
The%random% system returns any decimal digits from 0 to 32767. Generated by Cmd.exe.
The%systemdrive% system returns the drive that contains the Windows server operating system root (that is, the root directory of the systems).
The%SYSTEMROOT% system returns the location of the Windows server operating system root directory.
The%temp% and%TMP% systems and users return the default temporary directory used by applications that are available to the currently logged-on user. Some applications require TEMP, while other applications require TMP.
The%time% system returns the current time. Use the same format as the time/t command. Generated by Cmd.exe. For more information about the time command, see time.
%userdomain% Local returns the name of the domain that contains the user account.
%USERNAME% returns the name of the currently logged on user locally.
%USERPROFILE% Local Returns the location of the current user's profile.
The%WINDIR% system returns the location of the operating system directory.


%temp% =%userprofile%\local Settings\Temp = C:\Documents and Settings\sihochina\local settings\temp


There are also some system variables that represent a meaning, or an operation!

They are%0%1%2%3%4-%5, respectively ... Until%9 has a%*.

%0 This is a little special, there are a few layers of meaning, first of all, the meaning of%1-%9.

%1 returns the first parameter of a batch
%2 returns the second parameter of a batch
%3-%9 to push the class

Back to batch parameters? What the hell is a return method?

Let's look at this example and save the following code as test. BAT and put it under the C drive.

@echo off
Echo%1%2%3%4
Echo%1
Echo%2
echo%3
Echo%4

Enter CMD, enter CD c \
Then enter Test.bat I'm the first parameter I'm the second parameter I'm the third parameter I'm the fourth parameter

Notice the middle of the vacancies, and we'll see the result:

I'm the first parameter I'm the second parameter I'm the third parameter I'm the fourth parameter
I am the first parameter
I am the second parameter
I'm the third parameter.
I'm the fourth parameter.

Compare the code,%1 is I am the first parameter%2 is I am the second parameter
How to understand it!


These% 1 and%9 can allow batch processing to run with parameters, greatly improving batch processing capabilities!

There's another%*. His role is not very big, just return the parameter, but he is once return all parameters

The value of the input%1 is not determined by the


Example
@echo off
Echo%*

Also save as Test.bat to C-drive
Enter CMD, enter CD c \
Then enter Test.bat I'm the first parameter I'm the second parameter I'm the third parameter I'm the fourth parameter

You can see that he showed all the parameters at once.


Okay, now, let's start with the very special%0.


%0 This is not the value of the return parameter, he has two levels of meaning!

First layer meaning: Returns the absolute path of the batch

Example:
@echo off
Echo%0
Pause

Save as Test. BAT is running on the desktop and will show the following results
"C:\Documents and settings\administrator\ desktop \test.bat"

He prints out the path where the current batch is executing, which is the meaning of returning the absolute path to the batch process.

Second layer meaning: infinite loop execution bat

Example:
@echo off
NET user
%0

Saved as bat execution, he will loop through the Net user command indefinitely until you stop it manually.

These are some of the system variables in the batch, plus some variables, they also represent some functions
The for command is that the for variable has been said and is not spoken.


Now say the custom variable

So the name thinks, the custom variable is the variable that we give him the value.

To use a custom variable you have to use the SET command, see example.

@echo off
Set var= I am the value
Echo%var%
Pause

Save As Bat execution, we'll see CMD return a "I'm the Value"

var is the variable name, and the = number right is the value to be given to the variable.
This is the simplest way to set a variable.

If we want the user to manually enter the value of the variable instead of specifying it in the code, you can use the/p parameter of the SET command

Example:

@echo off
set/p var= Please enter the value of the variable
Echo%var%
Pause

var variable name = number to the right is the prompt, not the value of the variable
The value of the variable is entered by our own keyboard after we run it!

Some files located in directory under Linux under Win are:%userprofile% the user file root directory of the logged-on user

such as Npm,maven, etc.

http://www.daliane.com/npm_err_wu_fa_an_zhuang_ren_he_bao_de_jie_jue_ban_fa/

Http://stackoverflow.com/questions/25244512/bower-eperm-unlink-error

Some Linux tools are placed in the file location under the Windows version

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.