DOS COMMANDS SYNTAX 11, TREASURE--> DOWNLOAD
201). WINRM = Windows Remote Management... |
---|
(EXPLAIN - WINRM) Windows Remote Management Secure communication with local and remote computers using web services. Syntax winrm g[et] | s[et] | c[reate] | d[elete] | e[numerate] | i[nvoke] | id[entify] | quickconfig | configSDDL | helpmsg Retrieve instances of RESOURCE_URI: winrm get RESOURCE_URI [-SWITCH:VALUE [-SWITCH:VALUE] ...] winrm get winrm/config winrm get winrm/config/client winrm get winrm/config/service Modify settings in RESOURCE_URI: winrm set RESOURCE_URI [-SWITCH:VALUE [-SWITCH:VALUE] ...] [@{KEY="VALUE"[;KEY="VALUE"]}] [-file:VALUE] Spawn an instance of RESOURCE_URI: winrm create RESOURCE_URI [-SWITCH:VALUE [-SWITCH:VALUE] ...] [@{KEY="VALUE"[;KEY="VALUE"]}] [-file:VALUE] Control remote access to WinRM resources, launch a GUI to edit security settings. winrm configsddl RESOURCE_URI Enable this machine for remote management. winrm quickconfig [-quiet] [-transport:VALUE] This will start the WinRM service, set the service to auto start, create a listener and enable an http firewall exception for WS-Management traffic -q[uiet] Don't prompt for confirmation. -transport:VALUE Perform quickconfig for either http or https. Default = http. List instances of RESOURCE_URI: winrm enumerate RESOURCE_URI [-ReturnType:Value] [-Shallow] [-BasePropertiesOnly] [-SWITCH:VALUE [-SWITCH:VALUE] ...] Remove an instance of RESOURCE_URI: winrm delete RESOURCE_URI [-SWITCH:VALUE [-SWITCH:VALUE] ...] Execute method specified by ACTION on target object specified by RESOURCE_URI winrm invoke ACTION RESOURCE_URI [-SWITCH:VALUE [-SWITCH:VALUE] ...] [@{KEY="VALUE"[;KEY="VALUE"]}] [-file:VALUE] Display error message associate with the error code. winrm helpmsg errorcode Key -a[uthentication]:VALUE The authentication mechanism to use when communicating with the remote machine. -defaultCreds Allow implicit credentials when Negotiate is used. Remote HTTPS operations for trusted machines. -dialect:VALUE Dialect of the filter expression for enumeration or fragment. Example: Use a WQL query -dialect:http://schemas.microsoft.com/wbem/wsman/1/WQL Example: Use XPATH for filtering with enumeration or fragment get/set. -dialect:http://www.w3.org/TR/1999/REC-xpath-19991116 -encoding:VALUE The encoding type when talking to remote machine (see -remote). Possible options are "utf-8" (the default) or "utf-16". -f[ormat]:FORMAT The format of output. FORMAT can be "xml", "pretty" (better formatted XML), or "text". -r[emote]:VALUE Specify the identifier of a remote endpoint/system. This may be a simple host name or a complete URL. -skipCAcheck The certificate issuer need not be a trusted root authority. Remote HTTPS operations for trusted machines. -skipCNcheck The certificate common name (CN) of the server need not match the hostname of the server. HTTPS operations for trusted machines. -skipRevocationcheck Do not check the revocation status of the server certificate. Remote HTTPS operations for trusted machines. -SPNPort Append port number to the Service Principal Name (SPN) of the remote server. Service principal name is used when Negotiate or Kerberos authentication mechanism is in use. -timeout:MS Timeout in milliseconds. Limits duration of corresponding operation. Default timeout can be configured by: winrm set winrm/config @{MaxTimeoutms="XXXXXX"} Where XXXXXX is an integer indicating milliseconds. -file:VALUE @{KEY="VALUE"[;KEY="VALUE"]} Input from an XML file or via key/value pairs. Applies to set, create, and invoke operations -fragment:VALUE Specify a section inside the instance XML that is to be updated or retrieved for the given operation. Example: Get the status of the spooler service winrm get wmicimv2/Win32_Service?name=spooler -fragment:Status/text() -options:{KEY="VALUE"[;KEY="VALUE"]} Key/value pairs for provider-specific options. Example: -options:{key1="value1";key2=$null} WinRM is the Microsoft implementation of WS-Management Protocol, a standard Simple Object Access Protocol (SOAP)-based, firewall-friendly protocol that allows hardware and operating systems, from different vendors, to interoperate. To improve security, WinRM 2.0 uses HTTP/HTTPS ports 5985/5986 by default. If the computer name is passed using r: If the computer name is passed as a URI, such as r:http://Mycomputer/wsman, then the IE default ports will be used (ports 80/443 by default). Examples Configure Windows Remote Management on the server (DemoServer2), run this from an elevated CMD (or powershell) prompt: C:\> winrm quickconfig On a client you can then open a remote shell connected to DemoServer2 with: winrs -r:DemoServer2 cmd Retrieve current configuration in XML format: winrm get winrm/config -format:pretty Retrieve spooler instance of Win32_Service class: winrm get wmicimv2/Win32_Service?Name=spooler Modify a configuration property of WinRM: winrm set winrm/config @{MaxEnvelopeSizekb="100"} Disable a listener on this machine: winrm set winrm/config/Listener?Address=*+Transport=HTTPS @{Enabled="false"} Create instance of HTTP Listener on IPv6 address: winrm create winrm/config/Listener?Address=IP:3ffe:8311:ffff:f2c1::5e61+Transport=HTTP Delete the HTTP listener on this machine for given IP address: winrm delete winrm/config/Listener?Address=IP:192.168.2.1+Transport=HTTP Call StartService method on Spooler service: winrm invoke StartService wmicimv2/Win32_Service?Name=spooler Call Create method of Win32_Process class with specified parameters: winrm invoke Create wmicimv2/Win32_Process @{CommandLine="notepad.exe";CurrentDirectory="C:\"} Display error message associated with the error code 0x5: winrm helpmsg 0x5 |
202). WINRS = Windows Remote Shell... |
---|
(EXPLAIN - WINRS) Windows Remote Shell Syntax winrs [-/SWITCH[:VALUE]] COMMAND Key COMMAND Any string that can be executed as a command in the cmd.exe shell. (All switches accept both short form or long form. For example both -r and -remote are valid.) -r[emote]:ENDPOINT The target endpoint using a NetBIOS name or the standard connection URL: [TRANSPORT://]TARGET[:PORT]. If not specified -r:localhost is used. -un[encrypted] Messages to the remote shell will not be encrypted. This is useful for troubleshooting, or when the network traffic is already encrypted using ipsec, or when physical security is enforced. By default the messages are encrypted using Kerberos or NTLM keys. This switch is ignored when HTTPS transport is selected. -u[sername]:USERNAME Username. If -username is specified, -password must be as well. If not specified Winrs will negotiate authentication or prompt. -p[assword]:PASSWORD Password. If not specified winrs will prompt for it. -d[irectory]:PATH The starting directory for remote shell. If not specified the remote shell will start in %USERPROFILE%. -env[ironment]:STRING=VALUE A single environment variable to be set when shell starts. This allows changing default environment for the shell. Multiple occurrences of this switch may be used. -noe[cho] Disable echo. This may be necessary to ensure that user's answers to remote prompts are not displayed locally. By default echo is "on". -nop[rofile] Do not load the user's profile. By default the server will attempt to load the user profile. If the remote user is not a local administrator on the target system then this option will be required. -comp[ression] Turn on compression. Older installations on remote machines may not support compression so it is off by default. -[use]ssl Use an SSL connection when using a remote endpoint. Specifying this instead of the transport "https:" will use the default WinRM default port. -? Help To terminate the remote command press Ctrl-C or Ctrl-Break, which will be sent to the remote shell. The second Ctrl-C will force termination of winrs.exe. The URI alias to manage active shells is shell/cmd. The URI alias for WinRS configuration is winrm/config/winrs. Examples Configure Windows Remote Management on the server (DemoServer2), run this from an elevated CMD (or powershell) prompt: C:\> winrm quickconfig On a client you can then open a remote shell connected to DemoServer2 with: winrs -r:DemoServer2 cmd Batch file to quickly open a remote cmd shell: [rshell.cmd] @echo off winrs -r:%1 cmd Run a dir command on a remote machine: C:\> winrs -r:DemoServer3 dir Run an install package on a remote server: C:\> winrs -r:Server25 msiexec.exe /i c:\install.msi /quiet Run a powershell script on the remote box: C:\> winrs /r:DemoServer2 powershell.exe -nologo -noprofile -command d:\test\test.ps1 Note that you can't open a full interactive remote powershell console, but as remoting functionality is built-in to Powershell 2.0 there isn't any need. Connecting to the remote server 'myserver' winrs -r:https://myserver.com command winrs -r:myserver.com -usessl command winrs -r:myserver command winrs -r:http://127.0.0.1 command winrs -r:http://169.51.2.101:80 -unencrypted command winrs -r:https://[::FFFF:129.144.52.38] command winrs -r:http://[1080:0:0:0:8:800:200C:417A]:80 command winrs -r:https://myserver.com -t:600 -u:administrator -p:$%fgh7 ipconfig winrs -r:myserver -env:PATH=^%PATH^%;c:\tools -env:TEMP=d:\temp config.cmd winrs -r:myserver netdom join myserver /domain:testdomain /userd:johns /passwordd:$%fgh789 |
203).WMIC = WMI Commands... |
---|
(EXPLAIN - WMIC.exe) Windows Management Instrumentation Command. Read a huge range of information about local or remote computers. Also provides a way to make configuration changes to multiple remote machines. Syntax Retrieve information about WMIC [global_switches] [/locale:ms_409] Interactive mode: WMIC Aliases: ALIAS - Access local system aliases [CALL] BASEBOARD - Base board management (motherboard or system board) BIOS - BIOS management (Basic input/output services) BOOTCONFIG - Boot configuration CDROM - CD-ROM COMPUTERSYSTEM - Computer system [CALL/SET] CPU - CPU CSPRODUCT - Computer system product information from SMBIOS. DATAFILE - DataFiles [CALL] DCOMAPP - DCOM Applications. DESKTOP - User's Desktop DESKTOPMONITOR - Desktop Monitor DEVICEMEMORYADDRESS - Device memory addresses DISKDRIVE - Physical disk drive DISKQUOTA - Disk space usage for NTFS volumes.[SET] DMACHANNEL - Direct memory access (DMA) channel ENVIRONMENT - System environment settings [SET] FSDIR - Filesystem directory entry [CALL] GROUP - Group account [CALL] IDECONTROLLER - IDE Controller IRQ - Interrupt request line JOB - Jobs scheduled using the schedule service.[CALL] LOADORDER - System services that define execution dependencies. LOGICALDISK - Local storage devices [CALL/SET] LOGON - LOGON Sessions. MEMCACHE - Cache memory MEMLOGICAL - System memory, layout and availability MEMPHYSICAL - Physical memory management NETCLIENT - Network Client management. NETLOGIN - Network login information for a particular user. NETPROTOCOL - Protocols (and their network characteristics). NETUSE - Active network connection. NIC - Network Interface Controller (NIC) NICCONFIG - Network adapter. [CALL] NTDOMAIN - NT Domain. [SET] NTEVENT - NT Event Log. NTEVENTLOG - NT eventlog file [CALL/SET] ONBOARDDEVICE - Common adapter devices built into the motherboard. OS - Operating System/s [CALL/SET] PAGEFILE - Virtual memory file swapping PAGEFILESET - Page file settings [SET] PARTITION - Partitioned areas of a physical disk. PORT - I/O ports PORTCONNECTOR - Physical connection ports PRINTER - Printer device [CALL/SET] PRINTERCONFIG - Printer device configuration PRINTJOB - Print job [CALL] PROCESS - Processes [CALL]* PRODUCT - Windows Installer [CALL] QFE - Quick Fix Engineering (patches) QUOTASETTING - Setting information for disk quotas on a volume. [SET] REGISTRY - Computer system registry [SET] SCSICONTROLLER - SCSI Controller [CALL] SERVER - Server information SERVICE - Service application [CALL] SHARE - Shared resourcees [CALL] SOFTWAREELEMENT - Elements of a software product* SOFTWAREFEATURE - Subsets of SoftwareElement. [CALL]* SOUNDDEV - Sound Devices STARTUP - Commands that run automatically when users logon SYSACCOUNT - System account SYSDRIVER - System driver for a base service. [CALL] SYSTEMENCLOSURE - Physical system enclosure SYSTEMSLOT - Physical connection points including ports, slots and peripherals, and proprietary connections points. TAPEDRIVE - Tape drives TEMPERATURE - Temperature sensor (electronic thermometer). TIMEZONE - Time zone data UPS - Uninterruptible power supply (UPS) USERACCOUNT - User accounts [CALL/SET] VOLTAGE - Voltage sensor (electronic voltmeter) data VOLUME - Local storage volume [CALL/SET] VOLUMEQUOTASETTING - Associates the disk quota setting with a specific disk volume. [SET] WMISET - WMI service operational parameters [SET] New aliases in Windows 2003: MEMORYCHIP - Memory chip information. RDACCOUNT - Remote Desktop connection permission [CALL] RDNIC - Remote Desktop connection on a specific network adapter [CALL/SET] RDPERMISSIONS - Permissions to a specific Remote Desktop connection [CALL] RDTOGGLE - Turn Remote Desktop listener on or off remotely[CALL] RECOVEROS - Blue Screen Information [SET] SHADOWCOPY - Shadow copy management [CALL] SHADOWSTORAGE - Shadow copy storage areas [CALL/SET] VOLUMEUSERQUOTA - Per user storage volume quotas [SET] Options By default an alias will return a standard LIST of information, you can also choose to GET one or more specific properties. Configuration changes can be made, where indicated above with: [CALL or SET ] The CREATE and DELETE options allow you to change the WMI schema itself. alias alias LIST [BRIEF | FULL | INSTANCE | STATUS |SYSTEM | WRITEABLE] [/TRANSLATE:BasicXml|NoComma ] [/EVERY:no_secs] [/FORMAT:format] alias GET [property list] [/VALUE ] [/ALL ] [/TRANSLATE:BasicXml|NoComma ] [/EVERY:no_secs] [/FORMAT:format] alias CALL method_name [parameters] alias SET [assignments] alias CREATE alias DELETE alias ASSOC [/RESULTCLASS:classname] [/RESULTROLE:rolename][/ASSOCCLASS:assocclass] For more help WMIC /locale:ms_409 /alias /? WMIC /locale:ms_409 /alias option /? e.g. WMIC /locale:ms_409 /BIOS /CALL /? WMIC /locale:ms_409 /MEMLOGICAL /SET /? The order of the /FORMAT and /TRANSLATE switches is significant: if /TRANSLATE follows /FORMAT, the output is formatted first and then translated. All the options above can be extended with a WHERE clause, best shown by the examples below: Format: Format defines the layout of the information, XML output is automatically formatted using a default style sheet, while other formats (HTML, Table, MOF, Raw XML etc) can be specified using /FORMAT: stylesheet_name Stylesheets supplied with WMIC: csv.xsl, hform.xsl, htable-sortby.xsl, htable.xsl texttable.xsl, textvaluelist.xsl, xml.xsl All output files are unicode text (convert to ASCII with TYPE) Tab Separated Values (.tsv) can be opened in excel The PROCESS alias can be used to start a new installation process, if doing this across the network, place the installer files on a share with permissions EVERYONE : Read Only. This is because network credentials will be dropped when jumping from one remote machine to another (unless you have kerberos configured). Examples WMIC /locale:ms_409 OS WMIC OS LIST BRIEF WMIC OS GET csname, locale, bootdevice WMIC OS GET osarchitecture /value WMIC /locale:ms_409 NTEVENT where LogFile='system' WMIC NTEVENT where "LogFile='system' and Type>'0'" WMIC SERVICE where (state=”running”) GET caption, name, state > services.tsv WMIC SERVICE where caption='TELNET' CALL STARTSERVICE WMIC PRINTER LIST STATUS WMIC PRINTER where PortName="LPT1:" GET PortName, Name, ShareName WMIC /INTERACTIVE:ON PRINTER where PortName="LPT1:" DELETE WMIC PROCESS where name='evil.exe' delete WMIC /output:"%computername%.txt" MEMORYCHIP where "memorytype=17" get Capacity WMIC /node:@workstns.txt /failfast:on PROCESS call create "\\server\share\installer.cmd" Interactive mode: C:>START "Windows Management" WMIC wmic:root\cli>/locale:ms_409 wmic:root\cli>OS get csname wmic:root\cli>quit Notes WMIC is available on XP Professional and Windows 2003 or later versions of Windows. The availability of WMI information does vary across different versions of Windows e.g. ODBC, SNMP, Windows Installer. To run WMIC requires administrator rights. In Windows 2000, around 4,000 properties can be monitored, and around 40 can be configured. In Windows XP around 6,000 properties can be monitored, and around 140 can be configured. Windows 2003 offers a few improvements and bug fixes: the global option /locale:ms_409 is not required (it defaults to English US.) When you type WMIC for the first time in Windows 2003 all the aliases are compiled. The second, and subsequent times you run WMIC, it will start immediately. Under XP WMIC is slower to initialise, therefore to run several WMI queries it can be quicker to use interactive mode. * WMI information for installed software packages (PACKAGE and SOFTWAREFEATURE) is often incomplete and inconsistent for a variety of historical reasons. A more reliable method is to retrieve a list of installed programs directly from the Add/Remove list in the registry, with a WSH script like this from Torgeir Bakken. |
204). WUAUCLT = Windows Update... |
---|
(EXPLAIN - WUAUCLT) Windows Update Agent, download new Windows Update files. Syntax wuauclt Options Options: /a or /ResetAuthorization Initiate an asynchronous background search for applicable updates. If Automatic Updates are disabled, this has no effect. /r or /ReportNow Send all queued reporting events to the server asynchronously. /DetectNow Initiate detection right away, Query the WSUS server immediately to see if any new updates are needed. WSUS uses a cookie on client computers to store computer group membership when client-side targeting is used. By default this cookie expires an hour after WSUS creates it. If you are using client-side targeting and change group membership, use /ResetAuthorization /detectnow to expire the cookie, initiate detection, and have WSUS update computer group membership. Examples: C:\> wuauclt /a /DetectNow C:\> wuauclt /r /DetectNow |
205). XCACLS = Change file and folder permissions... |
---|
(EXPLAIN - XCACLS.exe) Display or modify Access Control Lists (ACLs) for files and folders. Syntax XCACLS filename [options] XCACLS filename Key If no options are specified XCACLS will display the ACLs for the file(s) options can be any combination of: /T Traverse all subfolders and change all matching files found. /E Edit ACL instead of replacing it. /x Edit ACL instead of replacing it; affect only ACEs that this user already owns* /R user Revoke all access rights from the given user. /D user Deny specified user access, this will over-ride all other permissions the user has. /C Continue on access denied errors. /Y Replace user's rights without verify /P user:permision[;FolderSpec] Replace user's rights. see /G option below /G user:permision[;FolderSpec] Grant specified user access rights, permision can be: r Read c Change (write) f Full control p Change Permissions (Special access) o Take Ownership (Special access) x EXecute (Special access) e REad (Special access) w Write (Special access) d Delete (Special access) t Used only by FolderSpec. see below * Option only valid in Windows 2003 FolderSpec is a permission applied to a folder. If FolderSpec is not specified then permission will apply to both files and folders. This allows you to set different permissions that will apply (through inheritance) when new files are added to the folder. FolderSpec = ;T@ where @ is one of the rights above, when this is specified new files will inherit FolderSpec instead of permission. At least one folder access right must follow the T For example ;TF will apply full control (but ;FT is not valid) Wildcards can be used to specify more that one file in a command. You can specify more than one user in a command. You can combine access rights. Although taking ownership is listed as an option it does not work, use SUBINACL for this. Inheritance Errors "Permissions incorrectly ordered" - the quickest way to resolve or avoid these errors is to use the newer iCACLS command instead of XCACLS. Inherited folder permissions are displayed as: OI - Object inherit - This folder and files. (no inheritance to subfolders) CI - Container inherit - This folder and subfolders. IO - Inherit only - The ACE does not apply to the current file/directory These can be combined as folllows: (OI)(CI) This folder, subfolders, and files. (OI)(CI)(IO) Subfolders and files only. (CI)(IO) Subfolders only. (OI) (IO) Files only. So BUILTIN\Administrators:(OI)(CI)F means that both files and Subdirectories will inherit 'F' (Fullcontrol) similarly (CI)R means Directories will inherit 'R' (Read folders only = List permission) When xcacls is applied to the current folder only there is no inheritance and so no output. Versions: NTFS standards have changed with different versions of Windows and XCACLS has been updated to suit, early versions of Xcacls may give unpredictable results against an NTFS v5 partition. xcacls.vbs is described in Q825751 and can be downloaded here - xcacls.vbs is an unsupported utility that addresses a limitation with the original xcacls.exe, specifically the inability to append permissions to a folder whose child objects have the inheritance flag set. The .vbs version does not suppport unc paths and is very slow to update multiple ACLs. Examples: :: Allow guests the right to read and execute in MyFolder XCACLS MyFolder /E /G guests:rx :: Allow guests the Full Control permission in MyFolder and all subfolders XCACLS MyFolder /T /E /G guests:f :: Grant guests only read access to all files in and below MyFolder, :: new folders created will be Read Access only, new files will not inherit any rights. XCACLS MyFolder /T /P guests:R;Tr :: Grant guests only execute access to all files in and below MyFolder XCACLS MyFolder /T /P guests:x |
206). XCOPY = Copy files and folders... |
---|
(EXPLAIN - XCOPY ) Copy files and/or directory trees to another folder. XCOPY is similar to the COPY command except that it has additional switches to specify both the source and destination in detail. NOTE: Xcopy is now deprecated under Vista and Windows 2008 - use Robocopy instead XCOPY is particularly useful when copying files from CDROM to a hard drive, as it will automatically remove the read-only attribute. Syntax XCOPY source [destination] [options] Key source : Pathname for the file(s) to be copied. destination : Pathname for the new file(s). [options] can be any combination of the following: Source Options /A Copy files with the archive attribute set (default=Y) /M Copy files with the archive attribute set and turn off the archive attribute, use this option when making regular Backups (default=Y) /H Copy hidden and system files and folders (default=N) /D:mm-dd-yyyy Copy files changed on or after the specified date. If no date is given, copy only files whose source date/time is newer than the destination time. /U Copy only files that already exist in destination. /S Copy folders and subfolders /E Copy folders and subfolders, including Empty folders. May be used to modify /T. /EXCLUDE:file1[+file2][+file3]... (Windows 2000 only) The files can each contain one or more full or partial pathnames to be excluded. When any of these match any part of the absolute path of a SOURCE file, then that file will be excluded. For example, specifying a string like \obj\ or .obj will exclude all files underneath the directory obj or all files with the .obj extension respectively. Copy Options /W Prompt you to press a key before starting to copy. /P Prompt before creating each file. /Y (Windows 2000 only) Suppress prompt to confirm overwriting a file. may be preset in the COPYCMD env variable. /-Y (Windows 2000 only) Prompt to confirm overwriting a file. /V Verify that the new files were written correctly. /C Continue copying even if an error occurs. /I If in doubt always assume the destination is a folder e.g. when the destination does not exist. /Z Copy files in restartable mode. If the copy is interrupted part way through, it will restart if possible. (use on slow networks) /Q Do not display file names while copying. /F Display full source and destination file names while copying. /L List only - Display files that would be copied. Destination Options /R Overwrite read-only files. /T Create folder structure, but do not copy files. Do not include empty folders or subfolders. /T /E will include empty folders and subfolders. /K Copy attributes. XCOPY will otherwise reset read-only attributes. /N If at all possible, use only a short filename (8.3) when creating a destination file. This may be nececcary when copying between disks that are formatted differently e.g NTFS and VFAT, or when archiving data to an ISO9660 CDROM. /O (Windows 2000 only) copy file Ownership and ACL information. /X Copy file audit settings (implies /O). XCOPY will accept UNC pathnames Examples: To copy a file: XCOPY C:\utils\MyFile D:\Backup\CopyFile To copy a folder: XCOPY C:\utils D:\Backup\utils /i To copy a folder including all subfolders. XCOPY C:\utils\* D:\Backup\utils /s /i The /i defines the destination as a folder. Notes In many cases the functionality of XCOPY is superseded by ROBOCOPY. To force the overwriting of destination files under both NT4 and Windows2000 use the COPYCMD environment variable: SET COPYCMD=/Y This will turn off the prompt in Win2000 and will be ignored by NT4 (which overwrites by default). When comparing Dates/Times the granularity (the finest increment of the timestamp) is 2 seconds for a FAT volume and 0.1 microsecond for an NTFS volume. The WinXP version of XCOPY will accept wildcards for the source e.g. *.txt It is also more forgiving with trailing backslashes |
207).:: = Comment / Remark... |
---|
(EXPLAIN - REM) In a batch file REM at the start of a line signifies a comment or REMARK alternatively adding :: at the start of a line has a similar effect For example: @ECHO OFF :: :: First comment :: REM Second comment REM :: Although you can use rem without a comment to add vertical spacing to a batch file, you can also use completely blank lines. The blank lines are ignored when processing the batch program. The double-colon is not documented as a comment command, it is a special case of a CALL label that acts like a comment. The pro's and cons of each method are listed below. Bugs There are problems using a :: comment within an IF or FOR code bracket e.g. @echo off FOR /L %%i IN (1,1,10) Do ( Echo before comment :: Some comment Echo after comment ) The above will return the error :: was unexpected at this time. In Windows 2000 and XP a comment like ::%~ or REM %~ will be interpreted giving the error: The following usage of the path operator in batch-parameter substitution is invalid: %~ In Windows NT 4 the REM command would incorrectly reset the %errorlevel% to 0 The bottom line on this is that you must test your comments to be sure they will be ignored as you expect. Registry Comments Within a registry file comments can be preceded by "; " e.g. ; ; Turn the NUMLOCK on at login ; [HKEY_CURRENT_USER\Control Panel\Keyboard] "InitialKeyboardIndicators"="2" FTP Comments There is no valid comment character for FTP but you can cheat by escaping to the shell and running REM e.g. C:\WORK>type ftpscript !REM This is a remark bye C:\WORK>ftp -s:ftpscript ftp> !REM This is a remark ftp> bye C:\WORK> #Now stand in the place where you work, Now face West Think about the place where you live, Wonder why you haven't before# - REM 'Stand' |