今天早些时候,我不得不将客户端计算机启动到安全模式并通过(client computer)命令提示符(command prompt)删除病毒, 因为每当 Windows加载时,文件就会被锁定,因此无法删除!您可能不得不在生活中使用命令提示符(command prompt)还有其他几个原因(尽管很少),所以知道如何导航是件好事!
如果您一直想学习如何在Windows中使用(Windows)命令提示符(command prompt),我将介绍一些最常执行的基本命令。就像(Just)每个人都在同一页面上一样,您可以通过转到“开始(Start)”然后单击“运行”(Run)并输入CMD来进入(CMD)命令提示符(command prompt)。在Windows 7中,只需单击开始(Start)并开始键入cmd。在Windows 8中,您只需右键单击开始按钮(Start button)并选择命令提示符。(Command Prompt.)
您现在将看到一个黑色的大窗口,光标位于 C:Documents 和 SettingsUsername 或 C:UsersUsername 中的用户 C:\Documents and Settings\Username文件C:\Users\Username的(user profile)末尾。那么现在该怎么办!?好吧,由于我无法解释所有内容(explain everything),您可能希望通过键入HELP并按Enter来使用(Enter.)MS DOS本身提供的一些帮助指南。(MS DOS)
当你这样做时,你会得到一个你可以在MS DOS中使用的所有命令的列表,以及它们的作用的简短描述:
您还可以通过键入命令名称(command name)后跟/?来了解有关参数以及如何使用每个命令的更多详细信息。. 例如,输入CD /?,将为您提供有关如何使用CD 命令(CD command)的快速教程:
从上面可以看出,MS DOS 命令 CD(command CD)显示或更改当前目录的名称。因此,如果您想从默认用户配置文件目录(default user profile directory)更改为Windows System32 目录(Windows System32 directory)以删除病毒文件(virus file),您将键入以下内容以导航到该目录:
cd c:\window\system32 and press Enter
提示符处的当前目录现在将更改为:
现在您在该目录中,您可能希望首先查看所有文件和目录,因此您可以输入命令DIR并按Enter。您现在将获得该目录中所有文件和文件夹的巨大列表。你可以输入DIR /?并查看可以传递给它的参数。
如您所见,您可以输入DIR /P以分页格式提供列表,您可以慢慢浏览。或者您可以输入DIR /W以获得宽格式的列表,而不是单列。DOS最酷的地方在于您可以为每个命令包含多个参数,因此您可以输入DIR /P /W并获得逐页视图以及宽格式:
现在我们有了文件和文件夹的列表,让我们继续删除病毒示例(virus example)。如果要删除文件,可以使用DEL命令。再次输入DEL /?将为您提供有关该命令的一些有用信息。
要删除文件,我们只需输入DEL 文件名(DEL filename)即可删除文件。当您以这种方式使用该命令时,它不会在删除文件之前提示您确认,因此请确保您输入了正确的文件名(correct file name)。此外,您必须输入带有扩展名的文件名(file name),因此删除该文件将是DEL Test.txt。此外,如果您需要删除名称中包含空格的文件,则必须使用DEL “This is a test.txt” 之(DEL “This is a test.txt”)类的引号。
如果您需要创建或删除文件夹,您将使用MKDIR 和RMDIR 命令。值得注意的是,如果你尝试删除一个非空目录,你会得到一个错误信息(error message)。但是,如果您确定要删除目录和其中的所有内容(directory and everything),则可以使用RMDIR /S foldername命令。
还有许多其他命令可用于执行各种操作,例如复制文件、打印文本(print text)文件、更改文件(change file)权限等。因此,如果您可以使用GUI 界面在(GUI interface)Windows中完成大部分操作,那何必费心呢?DOS,对吧?
首先,你永远不知道Windows什么时候会发生不好的事情,并且你被困在命令提示符(command prompt)中,因为不会加载任何其他内容。此外,您在命令提示符(command prompt)中键入的任何命令(如我们上面所示)都可以保存到扩展名为 .BAT 的文件中,只需单击该文件即可随时运行,也可以使用Windows 计划任务控制面板小程序(Windows Scheduled Tasks Control Panel applet)安排运行.
因此,如果您希望能够在您的计算机上定期执行一些简单的操作,例如将文件从一个文件夹复制到另一个文件夹,只需在记事本(Notepad)中键入命令并将文件保存为 .BAT 扩展名而不是文本文件(text file)。基本上(Basically),您必须为文件类型选项(File Type option)选择所有文件,然后输入名称,如“MyFile.bat”,并包含引号。
让我提几个其他经常被证明非常有用的命令。
IPCONFIG
IPCONFIG 命令(IPCONFIG command)为您提供有关您的网卡、IP 地址(IP address)的信息,还可以让您更新您的IP 地址(IP address)。我最喜欢的是 ipconfig /all,它将为您提供有关计算机上每个网络适配器(network adapter)的详细信息。然后,您可以使用此信息来确定您的路由器IP 地址(IP address)(默认网关)以及您是否从DHCP 服务器获取(DHCP server)IP 地址(IP address)。
磁盘部分
同样,当您最终遇到硬盘驱动器问题时,此命令可能非常有用。DISKPART允许您管理安装在计算机上的硬盘。您可以执行诸如将分区设置为活动分区、为分区分配驱动器号、缩小磁盘、使磁盘脱机或联机(disk offline or online)等操作。
证监会
系统文件检查器(System File Checker)非常有用,因为它会扫描所有受保护的系统文件并用正确的文件版本替换不正确的版本。很多时候,Windows中的某些系统文件已损坏,系统文件检查器(system file checker)会为您轻松修复它们。您只需运行sfc /scannow,它就会执行扫描并修复任何问题。这确实需要相当长的时间,但如果您遇到任何类型的腐败问题,这是值得的。
下面列出了您可能最终不得不使用的其他一些非常有用的命令:
- chkdsk – 验证硬盘或软盘的文件系统完整性(file system integrity)。
- 复制(copy)– 将文件从一个位置复制到另一个位置。目标默认为当前目录。如果有多个源文件,目标必须是一个目录,否则会出错。
- fc - 比较两个文件或文件集并显示它们之间的差异
- fdisk –操作(Manipulates)硬盘分区(disk partition)表。从命令行(command line)运行时,它会显示各种分区操作的菜单。
- 格式(format)-删除(Delete)磁盘上的所有文件并重新格式化为MS-DOS。主要用于(Use)格式化软盘或其他可移动磁盘。
- scandisk –磁盘(Disk)诊断实用程序,可替代CHKDSK 实用程序(CHKDSK utility)。
- netstat –显示(Shows)从本地计算机到任何外部设备的所有当前连接。
希望这能让您了解如何在MS DOS 命令(MS DOS command)提示符下使用和导航!您还可以查看此站点,其中列出了您可以在命令提示符下使用的(command prompt)所有命令(all commands)。如果您有任何问题,请发表评论!享受!
Beginner’s Guide to the Windows Command Prompt
Earlіer today I had to boot a client computer into safe mode and delete a virus via the command prompt because whenever Windows would load, the file would become locked and hence undeletable! There are sеveral other reasons why you may have to use the command prompt in your life (though rarely), so it’s good to know how to navigatе your way arоund!
If you have been meaning to learn how to use the command prompt in Windows, I’ll go through some of the basic commands that are performed most often. Just so everyone’s on the same page, you can get to the command prompt by going to Start and then click on Run and typing in CMD. In Windows 7, just click on Start and begin typing cmd. In Windows 8, you can just right-click on the Start button and choose Command Prompt.
You’ll now see a large black window with the cursor at the end of the path to your user profile in C:\Documents and Settings\Username or C:\Users\Username. So what to do now!? Well, since I can’t explain everything, you’ll probably want to end up using some of the help guides that are provided in MS DOS itself by typing in HELP and pressing Enter.
When you do that, you’ll get a list of all the commands you can use in MS DOS and a short description of what they do:
You can also find out more detailed information about the parameters and how to use each command by typing in the command name followed by a /?. For example, typing in CD /?, will present you with a quick tutorial on how to use the CD command:
As you can see from above, the MS DOS command CD displays the name of or changes the current directory. So if you wanted to change from the default user profile directory to the Windows System32 directory to delete a virus file, you would type in the following to navigate to that directory:
cd c:\window\system32 and press Enter
You current directory at the prompt will now change to:
Now that you are in that directory, you may want to view all of the files and directories first, so you can type in the command DIR and press Enter. You’ll now get a giant list of all of the files and folders in that directory. You can type in DIR /? and see what parameters you can pass to it.
As you can see, you could type in DIR /P to give the list in a paginated format that you can browse through slowly. Or you could type in DIR /W to get the list in a wide format rather than one single column. The cool thing about DOS is that you can include several parameters for each command, so you could type in DIR /P /W and get a page-by-page view along with wide format:
So now that we have a list of files and folders, let’s continue with our deleting a virus example. If you want to delete a file, you would use the DEL command. Again typing in DEL /? will give you some useful info on the command.
To delete a file, we can simply type in DEL filename and that will delete the file. When you use the command this way, it won’t prompt you to confirm before deleting the file, so make sure you have typed in the correct file name. Also, you have to enter the file name with the extension, so it would be DEL Test.txt to delete that file. Also, if you need to delete a file that has spaces in the name, you have to use quotes like DEL “This is a test.txt”.
If you need to create or delete folders, you would use the MKDIR and RMDIR commands. It’s worth noting that if you try to delete a non-empty directory, you will get an error message. However, if you are sure you want to delete the directory and everything inside, you can use the RMDIR /S foldername command.
There are lots of other commands that you can use to do all sorts of stuff like copy files, print text files, change file permissions, etc. So if you can do most of this stuff in Windows using the GUI interface, then why bother with DOS, right?
Firstly, you never know when something bad will happen to Windows and you’re stuck in the command prompt because nothing else will load. Also, any command you type in the command prompt, like we showed above, can be saved into a file with a .BAT extension and run anytime by just clicking on the file or can be scheduled to run using the Windows Scheduled Tasks Control Panel applet.
So if you want to be able to routinely perform some simple actions on your computer, like copying files from one folder to another, just type the commands into Notepad and save the file with a .BAT extension instead of as a text file. Basically, you have to choose All Files for the File Type option and then type in the name like “MyFile.bat” with the quotes included.
Let me mention a couple of other commands that prove to be very useful very often.
IPCONFIG
The IPCONFIG command gives you information about your network cards, IP addresses and also lets you renew your IP address. My favorite is ipconfig /all, which will give you detailed information about each network adapter on your computer. You can then use this info to figure out your router IP address (default gateway) and whether or not you’re getting an IP address from a DHCP server.
DISKPART
Again, when you end up with hard drive problems, this command can prove to be very useful. DISKPART lets you administer the hard disks installed on your computer. You can do things like set a partition to be the active partition, assign a drive letter to a partition, shrink a disk, take a disk offline or online, etc.
SFC
System File Checker is really useful because it scans all protected system files and replaces incorrect versions with correct file versions. There will be a lot of times when certain system files in Windows have become corrupt and system file checker will fix them for you easily. You just run sfc /scannow and it will perform a scan and fix any issues. It does take quite a bit of time, but worth it if you’re having any kind of corruption issues.
A couple of other very useful commands that you might have to end up using are listed below:
- chkdsk – Verifies a hard disk or a floppy disk for file system integrity.
- copy – Copies files from one location to another. The destination defaults to the current directory. If there are multiple source files, the destination must be a directory or else you will get an error.
- fc – Compares two files or sets of files and displays the differences between them
- fdisk – Manipulates hard disk partition tables. When run from the command line, it displays a menu of various partitioning operations.
- format – Delete all the files on the disk and reformat it for MS-DOS. Use mostly for formatting floppy disks or other removable disks.
- scandisk – Disk diagnostic utility that is a replacement for the CHKDSK utility.
- netstat – Shows you all the current connections from your local computer to anything external.
That should hopefully get you up and running on how to use and navigate in the MS DOS command prompt! You can also check out this site that has a list of all commands you can use at the command prompt. If you have a question, please post a comment! Enjoy!