dan*_*die 281 windows command-line-interface windows-command-prompt
此 Wiki 的目的是促进使用命令打开常用应用程序,而无需多次单击鼠标 - 从而节省监控和排除 Windows 机器故障的时间。
回答条目需要指定
命令的快捷方式
spl*_*tne 121
一个鲜为人知的是
getmac
Run Code Online (Sandbox Code Playgroud)
它显示您的网络适配器的MAC 地址。

Tor*_*oro 65
在命令提示符中键入:
C:\> start .
Run Code Online (Sandbox Code Playgroud)
它会在 Windows 资源管理器中打开当前目录。
dan*_*die 51
远程桌面连接
mstsc.exe
Run Code Online (Sandbox Code Playgroud)
打开:

K. *_*ley 45
我经常使用的列表:
Fro*_*rud 41
shutdown.exe
Run Code Online (Sandbox Code Playgroud)
允许您关闭或重新启动机器。您甚至可以使用以下命令重新启动远程机器
shutdown -m \\server -t 0 -r
Run Code Online (Sandbox Code Playgroud)
它甚至带有图形用户界面
shutdown -i
Run Code Online (Sandbox Code Playgroud)
你可以中止关机
shutdown -a
Run Code Online (Sandbox Code Playgroud)
Nic*_*aux 34
(本身并不是一个真正的命令,而是一种到达那里的方法。)
对于那些发现自己经常去开始>运行>“cmd”的人,你可以减少一些步骤。
假设您想获取您的 IP 地址。你通常会去开始>运行>“cmd”[输入]然后......
ipconfig [enter]
Run Code Online (Sandbox Code Playgroud)
现在,去...
开始>运行>“cmd /k ipconfig”
这将运行 cmd 和命令“ipconfig”,并保持窗口打开。因此,如果我想快速获取我的 MAC 地址(物理地址),我会这样做:
cmd /k ipconfig /all
Run Code Online (Sandbox Code Playgroud)
...全部来自运行菜单中的一行。
所有礼貌波士顿马克
Jos*_*ern 28
被遗忘的艺术:DOS 字符串操作!
set mydate=%date:~10,4%_%date:~4,2%_%date:~7,2%
echo %mydate%
Run Code Online (Sandbox Code Playgroud)
输出将为YYYY_MM_DD.
将其复制并粘贴到 .bat 文件中,您会大吃一惊!这对于创建备份或任何时间/日期系列的目录和文件特别有用。
一个例子:
@echo off
:: Yes, this looks bad, but it works, it sets the file veriable mydate to YYYY_MM_DD.
set mydate=%date:~10,4%_%date:~4,2%_%date:~7,2%
echo Backing up DC1:
:: start a new backup session, the /M switch is for the type of bakcup being performed, type ntbackup /? for more info
start /wait ntbackup backup \\DC1\c$ /j "DC1 Backup" /f "C:\BAK\DC1\DC1_%mydate%.bkf" /M incremental
echo DC1 is Done
echo Backing up EXCH:
start /wait ntbackup backup \\EXCH\c$ /j "EXCH Backup" /f "C:\BAK\EXCH\EXCH_%mydate%.bkf" /M incremental
echo EXCH is Done
echo Backing up FS1:
start /wait ntbackup backup \\FS1\c$ /j "FS1 Backup" /f "C:\BAK\FS1\FS1_%mydate%.bkf" /M incremental
echo FS1 is Done
echo Backup was completed %date% %time%
pause
Run Code Online (Sandbox Code Playgroud)
Fro*_*rud 26
tasklist.exe
Run Code Online (Sandbox Code Playgroud)
将列出本地或远程机器上的进程。
tasklist.exe /S server
Run Code Online (Sandbox Code Playgroud)
它可以显示 scvhost.exe 进程托管的服务
tasklist /SVC
Run Code Online (Sandbox Code Playgroud)
你也可以做一些过滤。这将显示使用了超过 15 分钟 CPU 时间的远程机器上的进程
tasklist /S server /FI "CPUTIME gt 00:15:00"
Run Code Online (Sandbox Code Playgroud)
小智 24
我发现我findstr经常在日志、错误文件等中查找内容。
一个简单的例子:在日志文件中,ex0905.log我们找到其中包含的所有行2009-05-05:
findstr "2009-05-05" ex0905.log
Run Code Online (Sandbox Code Playgroud)
Ivo*_*ser 21
有时我不得不担心终端服务器连接到服务器的空闲会话太少。
quser 在终端服务器上显示有关用户会话的信息。
quser /SERVER:myserver
Run Code Online (Sandbox Code Playgroud)
输出
C:\Documents and Settings\sysmanager01>quser /SERVER:serverx
USERNAME SESSIONNAME ID STATE IDLE TIME LOGON TIME
usr_hot1 1 Disc none 30.04.2009 17:59
usr_hot 2 Disc none 30.04.2009 18:01
appsuperuser rdp-tcp#6 3 Conn . 01.01.1601 02:00
Run Code Online (Sandbox Code Playgroud)
有时甚至有可能找到纯粹的工作狂,例如appsuperuser:-)
将quser可执行文件从任何 32 位服务器粘贴到我的本地 System32 文件夹时会更容易。
小智 17
我用
qwinsta
Run Code Online (Sandbox Code Playgroud)
查看断开连接的远程桌面会话和
logoff
Run Code Online (Sandbox Code Playgroud)
结束他们。
它适用于Windows 2000、Windows XP、Windows Vista、Windows Server 2003和Windows Server 2008(从未尝试过)。
phu*_*ion 16
systeminfo
Run Code Online (Sandbox Code Playgroud)
显示有关手头系统的大量信息。以下是它在 Vista 上的输出:
小智 15
非常有用的一个我最近才发现的:
winver.exe
Run Code Online (Sandbox Code Playgroud)
为您提供一个对话框,其中包含机器正在运行的 Windows 版本,包括 Service Pack 级别和内部版本号。
小智 14
仍然没有提到 WMIC.exe :)
从远程机器、本地机器......多台机器上找到你想要的任何东西。
精心填写的 HTML 页面,其中包含与操作系统相关的所有数据
WMIC OS get /all /format:htable
Run Code Online (Sandbox Code Playgroud)
查看所有可用选项
ALIAS - Access to the aliases available on the local system
BASEBOARD - Base board (also known as a motherboard or system board) management.
BIOS - Basic input/output services (BIOS) management.
BOOTCONFIG - Boot configuration management.
CDROM - CD-ROM management.
COMPUTERSYSTEM - Computer system management.
CPU - CPU management.
CSPRODUCT - Computer system product information from SMBIOS.
DATAFILE - DataFile Management.
DCOMAPP - DCOM Application management.
DESKTOP - User's Desktop management.
DESKTOPMONITOR - Desktop Monitor management.
DEVICEMEMORYADDRESS - Device memory addresses management.
DISKDRIVE - Physical disk drive management.
DISKQUOTA - Disk space usage for NTFS volumes.
DMACHANNEL - Direct memory access (DMA) channel management.
ENVIRONMENT - System environment settings management.
FSDIR - Filesystem directory entry management.
GROUP - Group account management.
IDECONTROLLER - IDE Controller management.
IRQ - Interrupt request line (IRQ) management.
JOB - Provides access to the jobs scheduled using the schedule service.
LOADORDER - Management of system services that define execution dependencies.
LOGICALDISK - Local storage device management.
LOGON - LOGON Sessions.
MEMCACHE - Cache memory management.
MEMLOGICAL - System memory management (configuration layout and availability of memory).
MEMPHYSICAL - Computer system's physical memory management.
NETCLIENT - Network Client management.
NETLOGIN - Network login information (of a particular user) management.
NETPROTOCOL - Protocols (and their network characteristics) management.
NETUSE - Active network connection management.
NIC - Network Interface Controller (NIC) management.
NICCONFIG - Network adapter management.
NTDOMAIN - NT Domain management.
NTEVENT - Entries in the NT Event Log.
NTEVENTLOG - NT eventlog file management.
ONBOARDDEVICE - Management of common adapter devices built into the motherboard (system board).
OS - Installed Operating System/s management.
PAGEFILE - Virtual memory file swapping management.
PAGEFILESET - Page file settings management.
PARTITION - Management of partitioned areas of a physical disk.
PORT - I/O port management.
PORTCONNECTOR - Physical connection ports management.
PRINTER - Printer device management.
PRINTERCONFIG - Printer device configuration management.
PRINTJOB - Print job management.
PROCESS - Process management.
PRODUCT - Installation package task management.
QFE - Quick Fix Engineering.
QUOTASETTING - Setting information for disk quotas on a volume.
RECOVEROS - Information that will be gathered from memory when the operating system fails.
REGISTRY - Computer system registry management.
SCSICONTROLLER - SCSI Controller management.
SERVER - Server information management.
SERVICE - Service application management.
SHARE - Shared resource management.
SOFTWAREELEMENT - Management of the elements of a software product installed on a system.
SOFTWAREFEATURE - Management of software product subsets of SoftwareElement.
SOUNDDEV - Sound Device management.
STARTUP - Management of commands that run automatically when users log onto the computer system.
SYSACCOUNT - System account management.
SYSDRIVER - Management of the system driver for a base service.
SYSTEMENCLOSURE - Physical system enclosure management.
SYSTEMSLOT - Management of physical connection points including ports, slots and peripherals, and
TAPEDRIVE - Tape drive management.
TEMPERATURE - Data management of a temperature sensor (electronic thermometer).
TIMEZONE - Time zone data management.
UPS - Uninterruptible power supply (UPS) management.
USERACCOUNT - User account management.
VOLTAGE - Voltage sensor (electronic voltmeter) data management.
VOLUMEQUOTASETTING - Associates the disk quota setting with a specific disk volume.
WMISET - WMI service operational parameters management.
Run Code Online (Sandbox Code Playgroud)
还有很多很多。
Osk*_*orn 13
链接命令,尤其是net stop和start重新启动任何服务:
net stop w3svc && net start w3svc
Run Code Online (Sandbox Code Playgroud)
(这是一个愚蠢的例子,iisreset会这样做,但无论如何;)
小智 13
color 02
Run Code Online (Sandbox Code Playgroud)
朋友们,这是您永远需要的唯一命令。其余的都是不必要的。
Ric*_*ard 12
explorer .
Run Code Online (Sandbox Code Playgroud)
选择当前文件夹打开资源管理器。
explorer /e, .
Run Code Online (Sandbox Code Playgroud)
打开资源管理器,带有文件夹树,选择当前文件夹。
Ste*_*ong 12
要更改您打开的 CMD 窗口的标题,只需使用:
title [your new title]
我在工作中打开了很多 CMD 窗口和其他程序。此命令与 Taskbar Shuffle(允许您将任务栏项目拖到新订单中)相结合,使我免于发疯。
小智 10
至少在 Windows XP 上(我没有在 Windows Vista 和 Windows 7 上尝试过):
appwiz.cpl @,2
Run Code Online (Sandbox Code Playgroud)
它会将您直接带到“添加/删除 Windows 组件”窗格。
以自动化方式添加或删除组件的另一种方法是使用
sysocmgr.exe
Run Code Online (Sandbox Code Playgroud)
在无人参与模式下使用 .inf 文件列出您要安装的组件。例如,
[NetOptionalComponents]
SNMP = 1
[SNMP]
Contact_Name = IT Dept.
Location = Office
Service = Physical, Applications, End-to-End
Community_Name = Mormon
Traps = server1, server2
Send_Authentication = Yes
Accept_CommunityName = Public:Read_Only
Any_Host = No
Limit_Host = server1, server2
Run Code Online (Sandbox Code Playgroud)
(归功于 .inf 文件的 systemadministrator.com。)
这是一个笨重的工具(嘿,它是 MS),但它对于在安装后整理您的组件非常宝贵。
Gul*_*zar 10
重新启动 IIS
iisreset
Run Code Online (Sandbox Code Playgroud)
ato*_*255 10
我还没有在列表中看到 taskkill。
TASKKILL [/S system [/U username [/P [password]]]] { [/FI filter] [/PID processid | /IM 图像名称] } [/F] [/T]
参数列表:/S system 指定要连接的远程系统。
Run Code Online (Sandbox Code Playgroud)/U [domain\]user Specifies the user context under which the command should execute. /P [password] Specifies the password for the given user context. Prompts for input if omitted. /F Specifies to forcefully terminate process(es). /FI filter Displays a set of tasks that match a given criteria specified by the filter. /PID process id Specifies the PID of the process that has to be terminated. /IM image name Specifies the image name of the process that has to be terminated. Wildcard '*' can be used to specify all image names. /T Tree kill: terminates the specified process and any child processes which were started by它。
与任务列表配合使用效果很好
装置经理
devmgmt.msc
Run Code Online (Sandbox Code Playgroud)
打开

dsquery * 和 dsmod
将您的dsquery结果dsmod传送到Active Directory 中并对Active Directory进行大量更改。
Description: Finds any objects in the directory according to criteria.
Syntax: dsquery * [{<StartNode> | forestroot | domainroot}]
[-scope {subtree | onelevel | base}] [-filter <LDAPFilter>]
[-attr {<AttrList> | *}] [-attrsonly] [-l]
[{-s <Server> | -d <Domain>}] [-u <UserName>]
[-p {<Password> | *}] [-q] [-r] [-gc]
[{-uc | -uco | -uci}]
Parameters:
Value Description
{<StartNode> | forestroot | domainroot}
The node where the search will start:
forest root, domain root, or a node
whose DN is <StartNode>.
Can be "forestroot", "domainroot" or an object
DN.
If "forestroot" is specified, the search is done
via the global catalog. Default: domainroot.
-scope {subtree | onelevel | base}
Specifies the scope of the search:
subtree rooted at start node (subtree);
immediate children of start node only (onelevel);
the base object represented by start node (base).
Note that subtree and domain scope
are essentially the same for any start node
unless the start node represents a domain root.
If forestroot is specified as <StartNode>,
subtree is the only valid scope.
Default: subtree.
-filter <LDAPFilter> Specifies that the search use the explicit
LDAP search filter <LDAPFilter> specified in the
LDAP search filter format for searching.
Default:(objectCategory=*).The search filter
string must be enclosed in double quotes.
-attr {<AttrList> | *} If <AttrList>, specifies a space-separated list
of LDAP display names to be returned for
each entry in the result set.
If *, specifies all attributes present on
the objects in the result set.
Default: distinguishedName.
-attrsonly Shows only the attribute types present on
the entries in the result set but not
their values.
Default: shows both attribute type and value.
-l Shows the entries in the search result set
in a list format. Default: table format.
{-s <Server> | -d <Domain>}
-s <Server> connects to the domain controller
(DC) with name <Server>.
-d <Domain> connects to a DC in domain <Domain>.
Default: a DC in the logon domain.
-u <UserName> Connect as <UserName>. Default: the logged in
user. User name can be: user name,
domain\user name, or user principal name (UPN).
-p <Password> Password for the user <UserName>. If * then you
are prompted for a password.
-q Quiet mode: suppress all output to standard
output.
-r Recurse or follow referrals during search.
Default: do not chase referrals during search.
-gc Search in the Active Directory global catalog.
-limit <NumObjects> Specifies the number of objects matching the
given criteria to be returned, where <NumObjects>
is the number of objects to be returned.
If the value of <NumObjects> is 0, all matching
objects are returned. If this parameter is not
specified, by default the first 100 results are
displayed.
{-uc | -uco | -uci} -uc Specifies that input from or output to pipe
is formatted in Unicode.
-uco Specifies that output to pipe or file is
formatted in Unicode.
-uci Specifies that input from pipe or file is
formatted in Unicode.
Remarks:
The dsquery commands help you find objects in the directory that match
a specified search criterion: the input to dsquery is a search criteria
and the output is a list of objects matching the search. To get the
properties of a specific object, use the dsget commands (dsget /?).
A user-entered value containing spaces or semicolons must be enclosed in
quotes (""). Multiple user-entered values must be separated using commas
(for example, a list of attribute types).
Examples:
To find all users in the current domain only whose SAM account name begins
with the string "jon" and display their SAM account name,
User Principal Name (UPN) and department in table format:
dsquery * domainroot
-filter "(&(objectCategory=Person)(objectClass=User)(sAMAccountName=jon*))"
-attr sAMAccountName userPrincipalName department
To read the sAMAccountName, userPrincipalName and department attributes of
the object whose DN is ou=Test,dc=microsoft,dc=com:
Dsquery * ou=Test,dc=microsoft,dc=com -scope base
-attr sAMAccountName userPrincipalName department
To read all attributes of the object whose DN is ou=Test,dc=microsoft,dc=com:
Dsquery * ou=Test,dc=microsoft,dc=com -scope base -attr *
See also:
dsquery computer /? - help for finding computers in the directory.
dsquery contact /? - help for finding contacts in the directory.
dsquery subnet /? - help for finding subnets in the directory.
dsquery group /? - help for finding groups in the directory.
dsquery ou /? - help for finding organizational units in the directory.
dsquery site /? - help for finding sites in the directory.
dsquery server /? - help for finding servers in the directory.
dsquery user /? - help for finding users in the directory.
dsquery quota /? - help for finding quotas in the directory.
dsquery partition /? - help for finding partitions in the directory.
dsquery * /? - help for finding any object in the directory by using
a generic LDAP query.
Directory Service command-line tools help:
dsadd /? - help for adding objects.
dsget /? - help for displaying objects.
dsmod /? - help for modifying objects.
dsmove /? - help for moving objects.
dsquery /? - help for finding objects matching search criteria.
dsrm /? - help for deleting objects.
dsquery failed:The parameter is incorrect.
type dsquery /? for help.
Run Code Online (Sandbox Code Playgroud)
实用程序
来自 Microsoft Technet “执行与文件分配表 (FAT) 和 NTFS 文件系统相关的任务,例如管理重分析点、管理稀疏文件或卸载卷。”
其最有用的选项之一是禁用旧版 8.3 文件名的创建。这对于在具有长文件名的目录中具有大量文件的服务器特别有用。
要在 XP 或 Server 2003 上禁用旧版 8.3 文件名:
fsutil 行为设置 disable8dot3 1
在 Windows 7(可能还有 Vista 和 Server 2008)上,您将使用:
fsutil 8dot3name 设置 1
有关详细信息,请参阅:http : //technet.microsoft.com/en-us/library/cc753059.aspx
用法:
Run Code Online (Sandbox Code Playgroud)ipconfig [/? | /all | /renew [adapter] | /release [adapter] | /flushdns | /displaydns | /registerdns | /showclassid adapter | /setclassid adapter [classid] ]在哪里
Run Code Online (Sandbox Code Playgroud)adapter Connection name (wildcard characters * and ? allowed, see例子)
Run Code Online (Sandbox Code Playgroud)Options: /? Display this help message /all Display full configuration information. /release Release the IP address for the specified adapter. /renew Renew the IP address for the specified adapter. /flushdns Purges the DNS Resolver cache. /registerdns Refreshes all DHCP leases and re-registers DNS names /displaydns Display the contents of the DNS Resolver Cache. /showclassid Displays all the dhcp class IDs allowed for adapter. /setclassid Modifies the dhcp class id.默认是只显示 IP 地址、子网掩码和
绑定到 TCP/IP 的每个适配器的默认网关。
对于 Release 和 Renew,如果未指定适配器名称,则 IP 地址
将释放或续订绑定到 TCP/IP 的所有适配器的租用。
对于 Setclassid,如果未指定 ClassId,则删除 ClassId。
例子:
Run Code Online (Sandbox Code Playgroud)> ipconfig ... Show information. > ipconfig /all ... Show detailed information > ipconfig /renew ... renew all adapters > ipconfig /renew EL* ... renew any connection that has its name starting with EL > ipconfig /release *Con* ... release all matching connections, eg. "Local Area Connection 1" or "Local Area Connection 2"
以不同的用户身份运行某些内容(有助于在没有人注销的情况下进行故障排除)
runas /U:*domainname*\*username* "*someapplication*"
Run Code Online (Sandbox Code Playgroud)
例如,如果您想使用您的凭据打开一个资源管理器窗口
runas /U:example.com\mylogin "explorer /separate"
Run Code Online (Sandbox Code Playgroud)
对于管理控制台管理单元(本示例中的服务),您需要使用 mmc 后跟普通命令来打开该管理单元
runas /U:example.com\mylogin "mmc services.msc"
Run Code Online (Sandbox Code Playgroud)
对于需要从未加入域的 PC(例如 SQL Server Management Studio)以域用户身份运行应用程序的情况
runas /netonly /U:domain\username application.exe
Run Code Online (Sandbox Code Playgroud)
netsh firewall set opmode disable
Run Code Online (Sandbox Code Playgroud)
关闭 Windows 防火墙。
taskkill.exe /f /fi "status eq Not Responding"
Run Code Online (Sandbox Code Playgroud)
杀死所有没有响应的程序。
我最近才发现forfiles
FORFILES [/P 路径名] [/M 搜索掩码] [/S] [/C 命令] [/D [+ | -] {MM/dd/yyyy | dd}]
描述:选择一个文件(或一组文件)并对该文件执行命令。这对批处理作业很有帮助。
我用这行来删除旧备份,这基本上删除了超过 6 天的文件:
Forfiles /p " C:\Backups\SQL " /d -6 /c "CMD /C del @FILE"
Run Code Online (Sandbox Code Playgroud)
Windows 更新服务
wuauclt.exe
/demoui
/a /ResetAuthorization
/r /ReportNow
/detectnow
Run Code Online (Sandbox Code Playgroud)
这个单一的命令有很多关于它的神话。它没有报告错误,没有帮助对话框,唯一的真正输出是为/demoui. 但它确实有效,我认为。
Windows Vista 和 Windows Server 2008 上的clip命令非常有用:它将任何传入的标准输入放在剪贴板上。
例子:
将当前目录复制到剪贴板:
dir | clip
Run Code Online (Sandbox Code Playgroud)
列出包含特定字符串的 C 文件:
findstr /i /s /m /c:"someFunction" *.c | clip
Run Code Online (Sandbox Code Playgroud)
小智 6
mstsc # starts the Remote Desktop window.
mstsc -v 192.168.0.1 # to remotely connect to a given IP.
Run Code Online (Sandbox Code Playgroud)
要获取在批处理文件中使用的当前日期/时间:
for /f "usebackq tokens=1,2,3,4 delims=/ " %%w in (`echo %DATE%`) 设置 YMD=%%z%%x%%y 对于 /f "usebackq 令牌=1,2,3,4 delims=:." %%x in (`echo %TIME%`) do set HMS=%%x%%y%%z 设置现在=%YMD%_%HMS% 回声%现在%
rasdial
Run Code Online (Sandbox Code Playgroud)USAGE: rasdial entryname [username [password|*]] [/DOMAIN:domain] [/PHONE:phonenumber] [/CALLBACK:callbacknumber] [/PHONEBOOK:phonebookfile] [/PREFIXSUFFIX] rasdial [entryname] /DISCONNECT rasdial For Online Privacy Information please refer to 'http://go.microsoft.com/fwlink/?LinkId=34493'
从命令行连接到 VPN 或拨号网络。
小智 5
subst.exe - 将路径与驱动器号相关联,包括本地驱动器。用法示例(添加然后删除):
subst M: C:\Documents and Settings\user\My Music\
subst M: /D
Run Code Online (Sandbox Code Playgroud)
(注意:不是持久的,需要在每次登录时运行)
最近我不得不使用: net use \\servername /d
它会终止对指定资源的权限。
另一个用途net use是以管理员身份重新挂载本地驱动器,这样您就不需要注销(在 WinXP 上,域上的切换用户被禁用)。
net use \\localShare /user:admin
我知道这是一个老问题,但我浏览了五页的答案,但没有看到以下内容:
推送,弹出
用法:
C:\Users\MyUser\src> pushd C:\Users\MyUser\Documents C:\Users\MyUser\Documents> cd 备份 C:\Users\MyUser\Documents\Backup> 复制 ..\*.* 。 C:\Users\MyUser\Documents\Backup> popd C:\Users\MyUser\src> rem 继续在 src 目录中工作。
在长目录中工作时很有用。我想回到我原来的地方。
| 归档时间: |
|
| 查看次数: |
306234 次 |
| 最近记录: |