Windows 变量、批处理 使用(转载+附)

(以下转载)

2005.12.09 第1版

Keywords: Windows XP | Microsoft Windows | Network administration/implementation
关键字:Windows XP | Microsoft Windows | 网络管理/实施

Takeaway:
Windows XP's environment variables control the behavior of batch files and programs, and also control the way Windows XP and the MS-DOS subsystem appears and works. Check out this list of environment variables, along with their descriptions.

概述:
Windows XP的环境变量控制了批处理文件和程序的行为,也控制了Windows XP和MS-DOS子系统的显示和工作方式。检阅这个环境变量列表,连同它们的描述。

《endurer注:1。check out v. 付帐后离开, ,检验, 合格, 及格
2。along with 连同...一起, 随同...一起》

 

Environment variables are used to control the behavior of batch files and programs in Windows XP; they also control the way Windows XP and the MS-DOS subsystem appears and works. To see a complete list of the environment variables that are active on a Windows XP system, follow these steps:
环境变量用于控制Windows XP里的批处理文件和程序的行为,也控制了Windows XP和MS-DOS子系统的显示和工作方式。要看在Windows XP系统中现行的完整环境变量列表,请按下列步骤操作:

Open a Command Prompt window.
打开一个命令提示符窗口。

Type Set and press [Enter].
输入Set命令并回车。

You'll see a list of the current environment variable settings. While some of them are familiar, such as PATH, and some are easy to figure out, such as COMPUTERNAME, others are more cryptic. Here's a sampling of Windows XP's environment variables:
你将看到当前环境变量设置列表。其中一些是熟悉的,如PATH,有一些容易领会,如COMPUTERNAME,其它的则较模糊。这是一个

《endurer注:1。figure out 合计为, 计算出, 解决, 断定, 领会到》

ALLUSERSPROFILE: Lists the location of the All Users Profile.
ALLUSERSPROFILE:列出所有用户Profile文件位置。

APPDATA: Lists the location where applications store data by default.
APPDATA: 列出应用程序数据的默认存放位置。

CD: Lists the current directory string.
CD: 列出当前目录。

CLIENTNAME: List the client's NETBIOS name when connected to terminal server session.
CLIENTNAME: 列出联接到终端服务会话时客户端的NETBIOS名。

CMDCMDLINE: Lists the command line used to start the current cmd.exe.
CMDCMDLINE: 列出启动当前cmd.exe所使用的命令行。

CMDEXTVERSION: Lists the version number of the current Command Processor Extensions.
CMDEXTVERSION: 命令出当前命令处理程序扩展版本号。

CommonProgramFiles: Lists the path to the Common Files folder.
CommonProgramFiles: 列出了常用文件的文件夹路径。

COMPUTERNAME: Lists the name of the computer.
COMPUTERNAME: 列出了计算机名。

COMSPEC: Lists the path to the command shell executable.
COMSPEC: 列出了可执行命令外壳(命令处理程序)的路径。

DATE: Lists the current date.
DATE: 列出当前日期。

ERRORLEVEL: Lists the error code of the most recently used command.
ERRORLEVEL: 列出了最近使用的命令的错误代码。

HOMEDRIVE: Lists the drive letter is connected to the user's home directory.
HOMEDRIVE: 列出与用户主目录所在的驱动器盘符。

HOMEPATH: Lists the full path of the user's home directory.
HOMEPATH: 列出用户主目录的完整路径。

HOMESHARE: Lists the network path to the user's shared home directory.
HOMESHARE: 列出用户共享主目录的网络路径。

LOGONSEVER: Lists the name of the domain controller that validated the current logon session.
LOGONSEVER: 列出有效的当前登录会话的域名控制器名。


NUMBER_OF_PROCESSORS: Lists the number of processors installed on the computer.
NUMBER_OF_PROCESSORS: 列出了计算机安装的处理器数。

OS: Lists the name of the operating system. (Windows XP and Windows 2000 list the operating system as Windows_NT.)
OS: 列出操作系统的名字。(Windows XP 和 Windows 2000 列为 Windows_NT.)


Path: Lists the search path for executable files.
Path: 列出了可执行文件的搜索路径。

PATHEXT: Lists the file extensions that the operating system considers to be executable.
PATHEXT: 列出操作系统认为可被执行的文件扩展名。

PROCESSOR_ARCHITECTURE: Lists the processor's chip architecture.
PROCESSOR_ARCHITECTURE: 列出了处理器的芯片架构。

PROCESSOR_IDENTFIER: Lists the description of the processor.
PROCESSOR_IDENTFIER: 列出了处理器的描述。

PROCESSOR_LEVEL: Lists the model number of the computer's processor.
PROCESSOR_LEVEL: 列出了计算机的处理器的型号。

PROCESSOR_REVISION: Lists the revision number of the processor.
PROCESSOR_REVISION: 列出了处理器的修订号。

ProgramFiles: Lists the path to the Program Files folder.
ProgramFiles: 列出了Program Files文件夹的路径。

PROMPT: Lists the command-prompt settings for the current interpreter.
PROMPT: 列出了当前命令解释器的命令提示设置。

RANDOM: Lists a random decimal number between 0 and 32767.
RANDOM: 列出界于0 和 32767之间的随机十进制数。

SESSIONNAME: Lists the connection and session names when connected to terminal server session.
SESSIONNAME: 列出连接到终端服务会话时的连接和会话名。

SYSTEMDRIVE: Lists the drive containing the Windows root directory.
SYSTEMDRIVE: 列出了Windows启动目录所在驱动器。

SYSTEMROOT: Lists the location of the Windows root directory.
SYSTEMROOT: 列出了Windows启动目录的位置。

TEMP and TMP: List default temporary directories for applications that are available to users who are currently logged on.

TEMP and TMP: 列出了当前登录的用户可用应用程序的默认临时目录。

TIME: Lists the current time.
TIME: 列出当前时间。

USERDOMAIN: Lists the name of the domain that contains the user's account.
USERDOMAIN: 列出了包含用户帐号的域的名字。

USERNAME: Lists the name of the user currently logged on.
USERNAME: 列出当前登录的用户的名字。

USERPROFILE: Lists the location of the profile for the current user.
USERPROFILE: 列出当前用户Profile文件位置。

WINDIR: Lists the location of the OS directory.
WINDIR: 列出操作系统目录的位置。

 

 

 

 

 

 

 

WINDOWS系统变量

ALLUSERSPROFILE=H:/Documents and Settings/All Users //所有用户的PROFILE路径
APPDATA=H:/Documents and Settings/Administrator/Application Data //当前用户的应用程序路径
ClusterLog=H:/WINDOWS/Cluster/cluster.log //集群日志路径
CommonProgramFiles=H:/Program Files/Common Files //应用程序公用的文件路径
COMPUTERNAME=E2003 //计算机名称
ComSpec=H:/WINDOWS/system32/cmd.exe //当前的命令解释器
HOMEDRIVE=H: //当前用户的主盘
HOMEPATH=/Documents and Settings/Administrator //当前用户的主目录
LOGONSERVER=/E2003 //登录的服务器
NUMBER_O_PROCESSORS=1 //当前计算机的处理器数字
OS=Windows_NT //当前系统的内核
Path=H:/Program Files/Support Tools/;H:/WINDOWS/system32; //学过DOS的都知道
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH //以前DOS下默认的是COM,EXE,BAT,现在已经有这么多了哟,以前都不知道,脚本都可以不打扩展名了
PROCESSOR_ARCHITECTURE=x86 //处理器架构
PROCESSOR_IDENTIFIER=x86 Family 15 Model 1 Stepping 3, GenuineIntel //处理器标识符
PROCESSOR_LEVEL=15 //没注意过,不知道有什么用
PROCESSOR_REVISION=0103 //版本?
ProgramFiles=H:/Program Files //应用程序的默认安装目录
PROMPT=$P$G //学过DOS的都知道
SESSIONNAME=Console //会话名称?
SystemDrive=H: //系统所在的盘符
SystemRoot=H:/WINDOWS //系统所在的目录
TEMP=H:/DOCUME~1/ADMINI~1/LOCALS~1/Temp //当前用户的临时目录
TMP=H:/DOCUME~1/ADMINI~1/LOCALS~1/Temp //同上
USERDNSDOMAIN=MCSE.COM //当前用户所在的域的DNS表示
USERDOMAIN=MCSE //NETBIOS表示
USERNAME=administrator //当前用户名
USERPROFILE=H:/Documents and Settings/Administrator //当前用户的配置文件目录
windir=H:/WINDOWS //windows所在的目录,总是跟systemroot一样

(以下转载)

最近对于批处理技术的探讨比较热,也有不少好的批处理程序发布,但是如果没有一定的相关知识恐怕不容易看懂和理解这些批处理文件,也就更谈不上自己动手编写了,古语云:“授人以鱼,不如授人以渔。”因为网上好像并没有一个比较完整的教材,所以抽一点时间写了这片<<简明批处理教程> >给新手朋友们.也献给所有为实现网络的自由与共享而努力的朋友们.
批处理文件是无格式的文本文件,它包含一条或多条命令。它的文件扩展名为 .bat 或 .cmd。在命令提示下键入批处理文件的名称,或者双击该批处理文件,系统就会调用Cmd.exe按照该文件中各个命令出现的顺序来逐个运行它们。使用批处理文件(也被称为批处理程序或脚本),可以简化日常或重复性任务。当然我们的这个版本的主要内容是介绍批处理在入侵中一些实际运用,例如我们后面要提到的用批处理文件来给系统打补丁、批量植入后门程序等。下面就开始我们批处理学习之旅吧。
一.简单批处理内部命令简介
1.Echo 命令
打开回显或关闭请求回显功能,或显示消息。如果没有任何参数,echo 命令将显示当前回显设置。
语法
echo [{on|off}] [message]
Sample:@echo off / echo hello world
在实际应用中我们会把这条命令和重定向符号(也称为管道符号,一般用> >> ^)结合来实现输入一些命令到特定格式的文件中.这将在以后的例子中体现出来。
2.@ 命令
表示不显示@后面的命令,在入侵过程中(例如使用批处理来格式化敌人的硬盘)自然不能让对方看到你使用的命令啦。
Sample:@echo off
@echo Now initializing the program,please wait a minite...
@format X: /q/u/autoset (format 这个命令是不可以使用/y这个参数的,可喜的是微软留了个autoset这个参数给我们,效果和/y是一样的。)
3.Goto 命令
指定跳转到标签,找到标签后,程序将处理从下一行开始的命令。
语法:goto label (label是参数,指定所要转向的批处理程序中的行。)
Sample:
if {%1}=={} goto noparms
if {%2}=={} goto noparms(如果这里的if、%1、%2你不明白的话,先跳过去,后面会有详细的解释。)
@Rem check parameters if null show usage
:noparms
echo Usage: monitor.bat ServerIP PortNumber
goto end
标签的名字可以随便起,但是最好是有意义的字母啦,字母前加个:用来表示这个字母是标签,goto命令就是根据这个:来寻找下一步跳到到那里。最好有一些说明这样你别人看起来才会理解你的意图啊。
4.Rem 命令
注释命令,在C语言中相当与/*--------*/,它并不会被执行,只是起一个注释的作用,便于别人阅读和你自己日后修改。
Rem Message
Sample:@Rem Here is the description.
5.Pause 命令
运行 Pause 命令时,将显示下面的消息:
Press any key to continue . . .
Sample:
@echo off
:begin
copy a:*.* d:/back
echo Please put a new disk into driver A
pause
goto begin
在这个例子中,驱动器 A 中磁盘上的所有文件均复制到d:/back中。显示的注释提示您将另一张磁盘放入驱动器 A 时,pause 命令会使程序挂起,以便您更换磁盘,然后按任意键继续处理。
6.Call 命令
从一个批处理程序调用另一个批处理程序,并且不终止父批处理程序。call 命令接受用作调用目标的标签。如果在脚本或批处理文件外使用 Call,它将不会在命令行起作用。
语法
call [[Drive:][Path] FileName [BatchParameters]] [:label [arguments]]
参数
[Drive:][Path] FileName
指定要调用的批处理程序的位置和名称。filename 参数必须具有 .bat 或 .cmd 扩展名。
7.start 命令
调用外部程序,所有的DOS命令和命令行程序都可以由start命令来调用。
入侵常用参数:
MIN 开始时窗口最小化
SEPARATE 在分开的空间内开始 16 位 Windows 程序
HIGH 在 HIGH 优先级类别开始应用程序
REALTIME 在 REALTIME 优先级类别开始应用程序
WAIT 启动应用程序并等候它结束
parameters 这些为传送到命令/程序的参数
执行的应用程序是 32-位 GUI 应用程序时,CMD.EXE 不等应用程序终止就返回命令提示。如果在命令脚本内执行,该新行为则不会发生。
8.choice 命令
choice 使用此命令可以让用户输入一个字符,从而运行不同的命令。使用时应该加/c:参数,c:后应写提示可输入的字符,之间无空格。它的返回码为1234……
如: choice /c:dme defrag,mem,end
将显示
defrag,mem,end[D,M,E]?
Sample:
Sample.bat的内容如下:
@echo off
choice /c:dme defrag,mem,end
if errorlevel 3 goto defrag (应先判断数值最高的错误码)
if errorlevel 2 goto mem
if errotlevel 1 goto end
:defrag
c:/dos/defrag
goto end
:mem
mem
goto end
:end
echo good bye
此文件运行后,将显示 defrag,mem,end[D,M,E]? 用户可选择d m e ,然后if语句将作出判断,d表示执行标号为defrag的程序段,m表示执行标号为mem的程序段,e表示执行标号为end的程序段,每个程序段最后都以goto end将程序跳到end标号处,然后程序将显示good bye,文件结束。

 

 

附:

获得一个参数pid:
set /p pid="dfdsaf:"

添加用户:
net user username /add

改变用户组:
net localgroup Group User /add

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值