DOS COMMANDS SYNTAX 8, TREASURE--> DOWNLOAD
141). RASDIAL = Manage RAS connections... |
---|
(EXPLAIN - RASDIAL (Dial Up Networking) Manage RAS/DUN connections. Dial a RAS connection: RASDIAL entryname [/PHONEBOOK:PhonebookFile] [/PHONE:PhoneNumber] [username [password|*]] [/CALLBACK:CallBackNumber] [/DOMAIN:domain][/PREFIXSUFFIX] Hang up a RAS connection: RASDIAL [entryname] /DISCONNECT Display RAS Status: RASDIAL To use this command requires that Dial Up Networking Service be installed (via Control Panel - Networking) The default location for PhoneBook entries is \%SystemRoot%\system32\ras\ |
142). RASPHONE = Manage RAS connections... |
---|
(EXPLAIN - RASPHONE (Dial Up Networking) Manage Remote Access Service (RAS) connections. This is a part of the Dial-Up Networking service, typically used to connect a PC to an Internet Service Provider. Dial a RAS connection: RASPHONE [-v] -f PhoneBook_file -d "PhoneBook_entry" Hang up a RAS connection: RASPHONE [-v] -f PhoneBook_file -h "PhoneBook_entry" Display RAS Status dialogue box RASPHONE -S Other RAS options: RASPHONE [-v] -f PhoneBook_file options "PhoneBook_entry" OPTIONS -a : Add new PhoneBook entry -e : Edit an existing PhoneBook entry -c : Clone an existing PhoneBook entry -r : Delete/remove an existing PhoneBook entry -v : Disable - 'grey out' the option to rename the PhoneBook_entry To use this command requires that Dial Up Networking Service be installed (via Control Panel - Networking) The default location for PhoneBook entries is %SystemRoot%\System32\ras\ |
143). RECOVER = Recover a damaged file from a defective disk... |
---|
(EXPLAIN - RECOVER) Recover a damaged file from a defective disk. Syntax RECOVER [drive:][path]filename Recover is designed to help in the case of hardware failure. When a drive fails the failure is not always total, in other words you may be able to read some of the files but not others, and some files will be only partly readable. The data on a disk is stored in tracks and sectors in an almost random manner. Data stored in a bad sectors cannot be read. RECOVER reads a file sector by sector and recovers data from the good sectors. You must specify a filename. Recover does not allow you to undelete a file. Recover the files one at a time. |
144). REG = Registry: Read, Set, Export, Delete keys and values... |
---|
(EXPLAIN - REG.exe) Read, Set or Delete registry keys and values, save and restore from a .REG file. Syntax: REG QUERY [ROOT\]RegKey /v ValueName [/s] REG QUERY [ROOT\]RegKey /ve --This returns the (default) value REG ADD [ROOT\]RegKey /v ValueName [/t DataType] [/S Separator] [/d Data] [/f] REG ADD [ROOT\]RegKey /ve [/d Data] [/f] -- Set the (default) value REG DELETE [ROOT\]RegKey /v ValueName [/f] REG DELETE [ROOT\]RegKey /ve [/f] -- Remove the (default) value REG DELETE [ROOT\]RegKey /va [/f] -- Delete all values under this key REG COPY [\\SourceMachine\][ROOT\]RegKey [\\DestMachine\][ROOT\]RegKey REG EXPORT [ROOT\]RegKey FileName.reg REG IMPORT FileName.reg REG SAVE [ROOT\]RegKey FileName.hiv REG RESTORE \\MachineName\[ROOT]\KeyName FileName.hiv REG LOAD FileName KeyName REG UNLOAD KeyName REG COMPARE [ROOT\]RegKey [ROOT\]RegKey [/v ValueName] [Output] [/s] REG COMPARE [ROOT\]RegKey [ROOT\]RegKey [/ve] [Output] [/s] Key: ROOT : HKLM = HKey_Local_machine (default) HKCU = HKey_current_user HKU = HKey_users HKCR = HKey_classes_root ValueName : The value, under the selected RegKey, to edit. (default is all keys and values) /d Data : The actual data to store as a "String", integer etc /f : Force an update without prompting "Value exists, overwrite Y/N" \\Machine : Name of remote machine - omitting defaults to current machine. Only HKLM and HKU are available on remote machines. FileName : The filename to save or restore a registry hive. KeyName : A key name to load a hive file into. (Creating a new key) /S : Query all subkeys and values. /S Separator : Character to use as the separator in REG_MULTI_SZ values the default is "\0" /t DataType : REG_SZ (default) | REG_DWORD | REG_EXPAND_SZ | REG_MULTI_SZ Output : /od (only differences) /os (only matches) /oa (all) /on (no output) Notes: Any of the above commands can be run against a remote machine by adding \\MachineName to the command line, assuming the Remote Registry Service is running. Registry data stored under HKCU will be visible and writable by the currently logged in user. Registry data stored under HKLM will be visible to all users and writable by administrators. To include a quote mark (") in the data, prefix it with the escape character (\) e.g. "Here is \" a quote" Enclose ValueNames that contain the \ character in single quotes. REG RESTORE has a tendency not to work, possibly due to firewall issues, Export and Import are much more reliable. Examples REG QUERY HKCU\Console\ REG QUERY HKCU\Console /v ScreenBufferSize Find the location of the Start Menu folder: REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "Start Menu" REG ADD HKCU\Software\SS64 /v Sample /d "some test data" REG QUERY HKCU\Software\SS64 /v Sample REG ADD HKLM\Software\DiLithium /v WarpSpeed /t REG_BINARY /d ffffffff REG QUERY HKLM\Software\DiLithium /v WarpSpeed REG COPY \\Wks580\HKCU\Software\SS64 HKCU\Software\SS64 REG COPY HKCU\Software\SS64 HKCU\Software\SS64Copy REG EXPORT HKCU\Software\SS64 C:\MyReg.REG REG IMPORT C:\MyReg.REG REG SAVE HKCU\Software\SS64 C:\MyRegHive.hiv REG RESTORE \\Wks580\HKCU\Software\SS64 C:\MyRegHive.hiv Run a script at first logon (Run Once) to do this we edit the Default User profile by temporarily loading it as ZZZ: REG LOAD HKU\ZZZ "C:\Documents and Settings\Default User\NTUSER.DAT" REG ADD HKU\ZZZ\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce /v newUserProfile /t REG_EXPAND_SZ /d "D:\setup.cmd" /f REG UNLOAD HKU\ZZZ More examples are available via: REG QUERY /? REG ADD /? etc |
145). REGEDIT = Import or export registry settings... |
---|
(EXPLAIN - REGEDIT) Import, export or delete registry settings from a text (.REG) file Syntax Export the Registry (all HKLM plus current user) REGEDIT /E pathname Export part of the Registry REGEDIT /E pathname "RegPath" Import a reg script REGEDIT pathname Silent import REGEDIT /S pathname Start the regedit GUI REGEDIT Open multiple copies of GUI (XP and 2003 only) REGEDIT -m Key /E : Export /S : Silent Import How to add keys and values from the registry: Create a text file like this: Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\SomeKey] "SomeStringValue"="Hello" When double clicking this .reg file the key and value will be added. Alternatively run REGEDIT MYKEY.REG from the command line. How to delete keys and values from the registry: Create a reg file like this, notice the hyphen inside the first bracket Windows Registry Editor Version 5.00 [-HKEY_CURRENT_USER\SomeKey] When double clicking this .reg file the key "SomeKey" will be deleted along with all string, binary or Dword values in that key. If you want to just delete values, leaving the key in place, set the value you want to delete = to a hyphen e.g. Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\SomeKey] "SomeStringValue"=- Again double clicking this .reg file will delete the values specified, or you can use REGEDIT /s MyDeleteScript.REG Compare the Registry of two machines Windiff is your friend, this simple GUI utility from the resource kit will list all the differences. 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" Under Windows NT 4 all registry scripts start with: REGEDIT4 (This version string will also work in XP and later versions of Windows.) |
146). REGSVR32 = Register or unregister a DLL... |
---|
(EXPLAIN - REGSVR32) Register or unregister a DLL. Syntax REGSVR32 [/U] [/S] [/C] [/I:[Command_Line]] DLL_Name REGSVR32 [/U] [/S] [/C] /N /I:[Command_Line] DLL_Name Key /u Unregister Server. /s Silent - no dialogue boxes. /c Console output. /n Don't call DllRegisterServer /i Call DllInstall (or DllUninstall if /u is specified) Command_Line An optional command line for DllInstall Examples Unregister (disable) XP Zip folders REGSVR32 /u C:\Windows\System32\zipfldr.dll Unregister (Disable) CAB file viewer: REGSVR32 /u C:\Windows\System32\cabview.dll Register (enable) XP Zip folders REGSVR32 zipfldr.dll Register (enable) CAB file viewer: REGSVR32 cabview.dll Register Windows Update DLLs (for those times when XP repair breaks Windows Update) regsvr32 /s wuapi.dll regsvr32 /s wuaueng1.dll regsvr32 /s wuaueng.dll regsvr32 /s wucltui.dll regsvr32 /s wups2.dll regsvr32 /s wups.dll regsvr32 /s wuweb.dll Register DAO 3.6 (Data Access Objects): REGSVR32 "C:\Program Files\Common Files\Microsoft Shared\DAO\DAO360.DLL" |
147). REGINI = Change Registry Permissions... |
---|
(EXPLAIN - REGINI) Change Registry Permissions. Syntax REGINI [-m \\machinename | -h hivefile hiveroot | -w Win95Directory] [-i n] [-o outputWidth] [-b] textFiles... Key -m A remote computer. -h The local hive to manipulate. -w Path to Windows 95 system.dat / user.dat files -i n The display indentation multiple. Default is 4 -o outputWidth How wide the output is to be. By default the outputWidth is set to the width of the console window if standard output has not been redirected to a file. In the latter case, an outputWidth of 240 is used. -b Make REGINI backward compatible with older versions of REGINI that did not strictly enforce line continuations and quoted strings Specifically, REG_BINARY, REG_RESOURCE_LIST and REG_RESOURCE_REQUIREMENTS_LIST data types did not need line continuations after the first number that gave the size of the data. It just kept looking on following lines until it found enough data values to equal the data length or hit invalid input. Quoted strings were only allowed in REG_MULTI_SZ. They could not be specified around key or value names, or around values for REG_SZ or REG_EXPAND_SZ Finally, the old REGINI did not support the semicolon as an end of line comment character. textFiles One or more ANSI or Unicode text files with registry data. The easiest way to understand the format of the input textFile is to use the REGDMP command with no arguments to dump the current contents of your NT Registry to standard out. Redirect standard out to a file and this file is acceptable as input to REGINI Some general rules are: Semicolon character is an end-of-line comment character, provided it is the first non-blank character on a line Backslash character is a line continuation character. All characters from the backslash up to but not including the first non-blank character of the next line are ignored. If there is more than one space before the line continuation character, it is replaced by a single space. Indentation is used to indicate the tree structure of registry keys The REGDMP program uses indentation in multiples of 4. You may use hard tab characters for indentation, but embedded hard tab characters are converted to a single space regardless of their position Values should come before child keys, as they are associated with the previous key at or above the value's indentation level. For key names, leading and trailing space characters are ignored and not included in the key name, unless the key name is surrounded by quotes. Imbedded spaces are part of a key name. Key names can be followed by an Access Control List (ACL) which is a series of decimal numbers, separated by spaces, bracketed by a square brackets (e.g. [8 4 17]). The valid numbers and their meanings are: 1 - Administrators Full Access 2 - Administrators Read Access 3 - Administrators Read and Write Access 4 - Administrators Read, Write and Delete Access 5 - Creator Full Access 6 - Creator Read and Write Access 7 - World Full Access 8 - World Read Access 9 - World Read and Write Access 10 - World Read, Write and Delete Access 11 - Power Users Full Access 12 - Power Users Read and Write Access 13 - Power Users Read, Write and Delete Access 14 - System Operators Full Access 15 - System Operators Read and Write Access 16 - System Operators Read, Write and Delete Access 17 - System Full Access 18 - System Read and Write Access 19 - System Read Access 20 - Administrators Read, Write and Execute Access 21 - Interactive User Full Access 22 - Interactive User Read and Write Access 23 - Interactive User Read, Write and Delete Access If there is an equal sign on the same line as a left square bracket then the equal sign takes precedence, and the line is treated as a registry value. If the text between the square brackets is the string DELETE with no spaces, then REGINI will delete the key and any values and keys under it. For registry values, the syntax is: value Name = type data Leading spaces, spaces on either side of the equal sign and spaces between the type keyword and data are ignored, unless the value name is surrounded by quotes. If the text to the right of the equal sign is the string DELETE, then REGINI will delete the value. The value name may be left off or be specified by an at-sign character which is the same thing, namely the empty value name. So the following two lines are identical: = type data @ = type data This syntax means that you can't create a value with leading or trailing spaces, an equal sign or an at-sign in the value name, unless you put the name in quotes. Valid value types and format of data that follows are: REG_SZ text REG_EXPAND_SZ text REG_MULTI_SZ "string1" "str""ing2" ... REG_DATE mm/dd/yyyy HH:MM DayOfWeek REG_DWORD numberDWORD REG_BINARY numberOfBytes numberDWORD(s)... REG_NONE (same format as REG_BINARY) REG_RESOURCE_LIST (same format as REG_BINARY) REG_RESOURCE_REQUIREMENTS (same format as REG_BINARY) REG_RESOURCE_REQUIREMENTS_LIST (same format as REG_BINARY) REG_FULL_RESOURCE_DESCRIPTOR (same format as REG_BINARY) REG_QWORD numberQWORD REG_MULTISZ_FILE fileName REG_BINARYFILE fileName If no value type is specified, default is REG_SZ For REG_SZ and REG_EXPAND_SZ, if you want leading or trailing spaces in the value text, surround the text with quotes. The value text can contain any number of imbedded quotes, and REGINI will ignore them, as it only looks at the first and last character for quote characters. For REG_MULTI_SZ, each component string is surrounded by quotes. If you want an imbedded quote character, then double quote it, as in string2 above. For REG_BINARY, the value data consists of one or more numbers The default base for numbers is decimal. Hexidecimal may be specified by using 0x prefix. The first number is the number of data bytes, excluding the first number. After the first number must come enough numbers to fill the value. Each number represents one DWORD or 4 bytes. So if the first number was 0x5 you would need two more numbers after that to fill the 5 bytes. The high order 3 bytes of the second DWORD would be ignored. Whenever specifying a registry path, either on the command line or in an input file, the following prefix strings can be used: HKEY_LOCAL_MACHINE HKEY_USERS HKEY_CURRENT_USER USER: Each of these strings can stand alone as the key name or be followed a backslash and a subkey path. There are several versions of regini with different syntax - the resource kit includes a word document with help and examples. |
148). REM = Record comments (remarks) in a batch file... |
---|
(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' |
149). REN = Rename a file or files... |
---|
(EXPLAIN - REN) Rename a file or files. REN [drive:][path]old_filename new_filename RENAME is a synonym for REN You cannot specify a different drive or path for `new_filename` - use the MOVE command instead. Both the source and/or destination may include wildcards. Examples Rename Monday.txt as Tuesday.txt C:\> REN Monday.txt Tuesday.txt Rename all text files in the current folder to have the extension .BAK C:\> REN *.txt *.BAK Rename Monday.txt as Monday.BAK C:\> REN Monday.txt *.BAK |
150). REPLACE = Replace or update one file with another... |
---|
(EXPLAIN - REPLACE) Replace or update one file with another Syntax REPLACE Source_PathName Destination_path [/A] [/P] [/R] [/W] REPLACE Source_PathName Destination_path [/P] [/R] [/S] [/W] [/U] Key path : The folder where files are to be replaced. /A : Add any missing files. /P : Prompt for confirmation (each file) /R : Replace even Read-only files /S : Include all subfolders of the destination. /W : Wait for you to insert a floppy disk. /U : Replace (update) only files that are older than the source. Limitations: When replacing in all subdirectories (/S ) you cannot ADD files (/A) or restrict to replacing older files (/U) |
151). RD = Delete folder(s)... |
---|
(EXPLAIN - RD) Delete folder(s) Syntax RD pathname RD /S pathname RD /S /Q pathname Key /S : Delete all files and subfolders in addition to the folder itself. Use this to remove an entire folder tree. /Q : Quiet - do not display YN confirmation Place any long pathnames in double quotes. RD does not support wildcards but you can remove several folders in one command by listing the pathname to each. e.g. RD c:\docs\Jan c:\docs\Feb "c:\My Documents\Mar" RMDIR is a synonym for RD |
152). RMTSHARE = Share a folder or a printer... |
---|
(EXPLAIN - RMTSHARE.exe) Manage File and Printer shares, local or on a remote server. Although missing from recent Resource kits, the old version appears to work fine under Windows 2000/XP/2003. Syntax Display all shares RMTSHARE \\server Display details of a specific share RMTSHARE \\server\sharename Share a Folder RMTSHARE \\server\sharename=drive:path [options] Share a Printer RMTSHARE \\server\sharename=printername /PRINTER [options] Edit an existing SHARE RMTSHARE \\server\sharename [options] Delete a SHARE RMTSHARE \\server\sharename /DELETE Options /USERS:number /UNLIMITED /REMARK:"text" /GRANT user:perm /REMOVE user Notes: Either specify /Users to restrict the number of connections that can be made OR specify /UNLIMITED You can include several /GRANTs in a single command line. Enclose paths that include spaces like this \\server\"long share name"="c:\long file name" |
153). ROBOCOPY = Robust File and Folder Copy... |
---|
(EXPLAIN - ROBOCOPY.exe(WINDOWS 7 COMMAND) Robust File and Folder Copy. By default Robocopy will only copy a file if the source and destination have different time stamps or different file sizes. Syntax ROBOCOPY source_folder destination_folder [file(s)_to_copy] [options] Key file(s)_to_copy : A list of files or a wildcard. (defaults to copying *.*) Source options /S : Copy Subfolders. /E : Copy Subfolders, including Empty Subfolders. /COPY:copyflag[s] : What to COPY (default is /COPY:DAT) (copyflags : D=Data, A=Attributes, T=Timestamps S=Security=NTFS ACLs, O=Owner info, U=aUditing info). /SEC : Copy files with SECurity (equivalent to /COPY:DATS). /DCOPY:T : Copy Directory Timestamps. ## /COPYALL : Copy ALL file info (equivalent to /COPY:DATSOU). /NOCOPY : Copy NO file info (useful with /PURGE). /A : Copy only files with the Archive attribute set. /M : like /A, but remove Archive attribute from source files. /LEV:n : Only copy the top n LEVels of the source tree. /MAXAGE:n : MAXimum file AGE - exclude files older than n days/date. /MINAGE:n : MINimum file AGE - exclude files newer than n days/date. (If n < 1900 then n = no of days, else n = YYYYMMDD date). /FFT : Assume FAT File Times (2-second date/time granularity). /256 : Turn off very long path (> 256 characters) support. Copy options /L : List only - don't copy, timestamp or delete any files. /MOV : MOVe files (delete from source after copying). /MOVE : Move files and dirs (delete from source after copying). /Z : Copy files in restartable mode (survive network glitch). /B : Copy files in Backup mode. /ZB : Use restartable mode; if access denied use Backup mode. /IPG:n : Inter-Packet Gap (ms), to free bandwidth on slow lines. /R:n : Number of Retries on failed copies - default is 1 million. /W:n : Wait time between retries - default is 30 seconds. /REG : Save /R:n and /W:n in the Registry as default settings. /TBD : Wait for sharenames To Be Defined (retry error 67). Destination options /A+:[RASHCNET] : Set file Attribute(s) on destination files + add. /A-:[RASHCNET] : UnSet file Attribute(s) on destination files - remove. /FAT : Create destination files using 8.3 FAT file names only. /CREATE : CREATE directory tree structure + zero-length files only. /DST : Compensate for one-hour DST time differences ## /PURGE : Delete dest files/folders that no longer exist in source. /MIR : MIRror a directory tree - equivalent to /PURGE plus all subfolders (/E) Logging options /L : List only - don't copy, timestamp or delete any files. /NP : No Progress - don't display % copied. /LOG:file : Output status to LOG file (overwrite existing log). /UNILOG:file : Output status to Unicode Log file (overwrite) ## /LOG+:file : Output status to LOG file (append to existing log). /UNILOG+:file : Output status to Unicode Log file (append) ## /TS : Include Source file Time Stamps in the output. /FP : Include Full Pathname of files in the output. /NS : No Size - don't log file sizes. /NC : No Class - don't log file classes. /NFL : No File List - don't log file names. /NDL : No Directory List - don't log directory names. /TEE : Output to console window, as well as the log file. /NJH : No Job Header. /NJS : No Job Summary. Repeated Copy Options /MON:n : MONitor source; run again when more than n changes seen. /MOT:m : MOnitor source; run again in m minutes Time, if changed. /RH:hhmm-hhmm : Run Hours - times when new copies may be started. /PF : Check run hours on a Per File (not per pass) basis. Job Options /JOB:jobname : Take parameters from the named JOB file. /SAVE:jobname : SAVE parameters to the named job file /QUIT : QUIT after processing command line (to view parameters). /NOSD : NO Source Directory is specified. /NODD : NO Destination Directory is specified. /IF : Include the following Files. Advanced options you'll probably never use /EFSRAW : Copy any encrypted files using EFS RAW mode. ## /MT[:n] : Multithreaded copying, n = no. of threads to use (1-128) ### default = 8 threads, not compatible with /IPG and /EFSRAW The use of /LOG is recommended for better performance. /SECFIX : FIX file SECurity on all files, even skipped files. /TIMFIX : FIX file TIMes on all files, even skipped files. /XO : eXclude Older - if destination file exists and is the same date or newer than the source - don't bother to overwrite it. /XC | /XN : eXclude Changed | Newer files /XX | /XL : eXclude eXtra | Lonely files and dirs. An "extra" file is present in destination but not source, excluding extras will delete from destination. A "lonely" file is present in source but not destination excluding lonely will prevent any new files being added to the destination. /XF file [file]... : eXclude Files matching given names/paths/wildcards. /XD dirs [dirs]... : eXclude Directories matching given names/paths. XF and XD can be used in combination e.g. ROBOCOPY c:\source d:\dest /XF *.doc *.xls /XD c:\unwanted /S /IA:[RASHCNETO] : Include files with any of the given Attributes /XA:[RASHCNETO] : eXclude files with any of the given Attributes /IS : Include Same, overwrite files even if they are already the same. /IT : Include Tweaked files. /XJ : eXclude Junction points. (normally included by default). /MAX:n : MAXimum file size - exclude files bigger than n bytes. /MIN:n : MINimum file size - exclude files smaller than n bytes. /MAXLAD:n : MAXimum Last Access Date - exclude files unused since n. /MINLAD:n : MINimum Last Access Date - exclude files used since n. (If n < 1900 then n = n days, else n = YYYYMMDD date). /BYTES : Print sizes as bytes. /X : Report all eXtra files, not just those selected & copied. /V : Produce Verbose output log, showing skipped files. /ETA : Show Estimated Time of Arrival of copied files. ## = New Option in Vista (XP027) all other options on this page are for the XP version of Robocopy (XP010) ### = New Option in Windows 7 and Windows 2008 R2 Robocopy EXIT CODES File Attributes [RASHCNETO] R – Read only A – Archive S – System H – Hidden C – Compressed N – Not content indexed E – Encrypted T – Temporary O - Offline If either the source or desination are a "quoted long foldername" do not include a trailing backslash as this will be treated as an escape character, i.e. "C:\some path\" will fail but "C:\some path\\" or "C:\some path\." or "C:\some path" will work. Robocopy will fail to copy files that are 'locked' by other users or applications, limiting the number of retries with /R:0 will speed up large jobs. By copying only the files that have changed, robocopy can be used to backup very large volumes. To limit the network bandwidth used by robocopy, specify the Inter-Packet Gap parameter /IPG:n This will send packets of 64 KB each followed by a delay of n Milliseconds. ROBOCOPY will accept UNC pathnames including UNC pathnames over 256 characters long. /REG Writes to the registry at HKCU\Software\Microsoft\ResKit\Robocopy /B (backup mode) will allow Robocopy to override file and folder permission settings (ACLs). All versions of Robocopy will copy security information (ACLs) for directories, version XP010 will not copy file security changes unless the file itself has also changed, this greatly improves performance. To run ROBOCOPY under a non-administrator account will require backup files privilege, to copy security information auditing privilege is also required, plus of course you need at least read access to the files and folders. The Windows Server 2003 Resource Kit Tools include Robocopy XP010, this can be run on NT 4/ Windows 2000. Robocopy does not run on Windows 95, or NT 3.5. (RoboCopy is a Unicode application). Robocopy 'Jobs' and the 'MOnitor source' option provide an alternative to setting up a Scheduled Task to run a batchfile with a RoboCopy command. Examples: Copy files from one server to another (auto skip files already in the destination) ROBOCOPY \\Server1\reports \\Server2\backup *.doc /S List files over 32 MBytes in size: ROBOCOPY C:\work /MAX:33554432 /L Move files over 14 days old: (note the MOVE option will fail if any files are open and locked.) ROBOCOPY C:\work C:\destination /move /minage:14 Backup a Server The script below copies data from FileServ1 to FileServ2, the destination holds a full mirror along with file security info. When run regularly to synchronize the source and destination, robocopy will only copy those files that have changed (change in time stamp or size.) @ECHO OFF SETLOCAL SET _source=\\FileServ1\e$\users SET _dest=\\FileServ2\e$\BackupUsers SET _what=/COPYALL /B /SEC /MIR :: /COPYALL :: COPY ALL file info :: /B :: copy files in Backup mode. :: /SEC :: copy files with SECurity :: /MIR :: MIRror a directory tree SET _options=/R:0 /W:0 /LOG:MyLogfile.txt /NFL /NDL :: /R:n :: number of Retries :: /W:n :: Wait time between retries :: /LOG :: Output log file :: /NFL :: No file logging :: /NDL :: No dir logging ROBOCOPY %_source% %_dest% %_what% %_options% Run two robocopy jobs at the same time with START /Min Start /Min "Job one" Robocopy \\FileServA\C$\Database1 \\FileServeBackupA\c$\Backups Start /Min "Job two" Robocopy \\FileServB\C$\Database2 \\FileServeBackupB\c$\Backups Bugs Version XP026 returns a success errorlevel even when it fails. |
154). ROUTE = Manipulate network routing tables... |
---|
(EXPLAIN - ROUTE.exe) Manipulate network routing tables. Route packets of network traffic from one subnet to another by modifying the route table. Syntax Display route details: ROUTE [-f] PRINT [destination_host] [MASK subnet_mask_value] [gateway] [METRIC metric] [IF interface_no.] Add a route: ROUTE [-f] [-p] ADD [destination_host] [MASK subnet_mask_value] [gateway] [METRIC metric] [IF interface_no.] Change a route: ROUTE [-f] CHANGE [destination_host] [MASK subnet_mask_value] [gateway] [METRIC metric] [IF interface_no.] Delete a route: ROUTE [-f] DELETE [destination_host] [MASK subnet_mask_value] [gateway] [METRIC metric] [IF interface_no.] key -f Clear (flush) the routing tables of all gateway entries. If this is used in conjunction with one of the commands, the tables are cleared prior to running the command. destination_host The address (or set of addresses) that you want to reach. -p Create a persistent route - survives system reboots. (not supported in Windows 95) subnet_mask_value The subnet mask value for this route entry. This defines how many addresses are there. If not specified, it defaults to 255.255.255.255. gateway The gateway. interface The interface number (1,2,...) for the specified route. If the option `IF interface_no` is not given, ROUTE will try to find the best interface available. metric The metric, ie. cost for the destination. Note that routes added to the table are not made persistent unless the -p switch is specified. Non-persistent routes only last until the computer is rebooted. Symbolic names used for Destination_Host are looked up in the network database file NETWORKS. The symbolic names for gateway are looked up in the host name database file HOSTS. If the command is PRINT or DELETE. Destination or gateway can be a wildcard ('*'), or the gateway argument may be omitted. An IP address mask of 0.0.0.0 means everything. (rather like the *.* wildcard). In other words it says: When matching this pattern, don't worry about matching any of the bits - everything matches. If Destination_Host contains a * or ?, it is treated as a shell pattern, and only matching destination routes are printed. The '*' matches any string, and '?' matches any one char. Examples: 157.*.1 157.* 127.* *224* |
155). RUN = Start | RUN commands... |
---|
(EXPLAIN - Start | Run Commands for Windows XP, Vista and Windows 7:) Accessibility Controls access.cpl Accessibility Options control access.cpl Adapter Troubleshooter (Vista/Win7) AdapterTroubleshooter Add Hardware Wizard hdwwiz.cpl Add/Remove Programs appwiz.cpl Add/Remove Programs (Add New Programs) control appwiz.cpl,,1 Add/Remove Programs (Add Remove Windows Components) control appwiz.cpl,,2 Add/Remove Programs (Set Program Access & Defaults ) control appwiz.cpl,,3 Administrative Tools control admintools Advanced User Accounts Control Panel (Vista/Win7) Netplwiz Automatic Updates wuaucpl.cpl Authorization Manager (Vista/Win7) azman.msc Backup Status and Utility (Vista/Win7) sdclt Bluetooth Transfer Wizard fsquirt Calculator calc Certificate Manager certmgr.msc Character Map charmap Check Disk Utility (XP) chkdsk Clipboard Viewer clipbrd Color Management colorcpl Command Prompt cmd Component Services dcomcnfg Computer Management (XP) compmgmt.msc Computer Management (Vista/Win7) CompMgmtLauncher Control Panel control Credential (passwords) Backup and Restore Wizard (Vista/Win7) credwiz Date and Time Properties timedate.cpl Device Manager devmgmt.msc Direct X Control Panel* directx.cpl Direct X Troubleshooter dxdiag Disk Cleanup Utility cleanmgr Disk Defragmenter (XP) dfrg.msc Disk Defragmenter (Vista) dfrgui Disk Defragmenter defrag Disk Management diskmgmt.msc Disk Partition Manager diskpart Display Properties control desktop Display Properties desk.cpl Display Properties (Appearance) control color Dr. Watson System Troubleshooting Utility drwtsn32 Driver Verifier Utility verifier Driver Package Installer (Vista/Win7) dpinst DVD Player dvdplay Event Viewer eventvwr.msc File Signature Verification Tool sigverif Files and Settings Transfer Tool migwiz Findfast findfast.cpl Firewall Control Panel (Vista/Win7) FirewallControlPanel Firewall Settings (Vista/Win7) FirewallSettings Folders Properties control folders Fonts control fonts Fonts Folder fonts Game Controllers joy.cpl Group Policy Editor (XP Prof) gpedit.msc IExpress - Turn a cmd/vbs script into an installer .exe file C:\Windows\System32\iexpress.exe (example) Indexing Service ciadv.msc Internet Properties inetcpl.cpl IP Configuration ipconfig iSCSI Initiator (Vista/Win7) iscsicpl Keyboard Properties control keyboard Language Pack Installer (Vista/Win7) lpksetup Local Security Policy secpol.msc Local Users and Groups (XP) lusrmgr.msc Log out logoff Microsoft Access* msaccess Microsoft Excel* excel Microsoft Malicious Software Removal Tool mrt Microsoft Paint mspaint Microsoft Powerpoint* powerpnt Microsoft Support Diagnostic Tool (Vista/Win7) msdt Microsoft Word* winword Mouse Properties control mouse Mouse Properties main.cpl MSN Messenger* msnmsgr Network Connections control netconnections Network Connections ncpa.cpl Network Setup Wizard netsetup.cpl Notepad notepad ODBC Data Source Administrator odbccp32.cpl 32-bit ODBC driver under 64-bit platform = C:\windows\sysWOW64\odbcad32.exe 64 bit ODBC driver under 64-bit platform = C:\windows\system32\odbcad32.exe On Screen Keyboard osk Paint pbrush Password Properties password.cpl Performance Monitor perfmon.msc Phone and Modem Options telephon.cpl Phone Dialer dialer Power Configuration powercfg.cpl Printers and Faxes control printers Printers Folder printers Private Character Editor eudcedit Quicktime* QuickTime.cpl Quicktime Player* quicktimeplayer Regional Settings intl.cpl Registry Editor regedit Registry Editor regedit32 Reliability and Performance Monitor perfmon.msc Remote Assistance(Vista/Win7) msra Remote Desktop mstsc Removable Storage ntmsmgr.msc Removable Storage Operator Requests ntmsoprq.msc Resultant Set of Policy (XP Prof) rsop.msc Scanners and Cameras sticpl.cpl Scheduled Tasks control schedtasks Security Center wscui.cpl Services services.msc Shared Creation Wizard shrpubw Shared Folders fsmgmt.msc Shut Down Windows shutdown Software Licensing/Activation (Vista/Win7) slui Sounds and Audio mmsys.cpl Sound Recorder (Vista/Win7) soundrecorder Sound Volume (Vista/Win7) sndvol SQL Client Configuration cliconfg Sync Center mobsync Syncronization Tool mobsync System Configuration Editor sysedit System Configuration Utility msconfig System File Checker Utility (Scan/Purge) sfc System Information msinfo32 System Properties sysdm.cpl System Properties (Vista/Win7) SystemPropertiesAdvanced, SystemPropertiesComputerName, SystemPropertiesDataExecutionPrevention,SystemPropertiesHardware, SystemPropertiesPerformance,SystemPropertiesProtection, SystemPropertiesRemote Task Manager taskmgr Telnet Client telnet Trusted Platform Module Initialization Wizard (Vista/Win7) TpmInit Tweak UI* tweakui User Account Management nusrmgr.cpl User Accounts (Autologon) control userpasswords2 Utility Manager utilman Windows Error Reports wercon Windows Features (Vista/Win7) optionalfeatures Windows Firewall firewall.cpl Windows Firewall with Advanced Security (Vista/Win7) wf.msc Windows Image Acquisition (scanner)(Vista/Win7) wiaacmgr Windows Magnifier magnify Windows Management Infrastructure wmimgmt.msc Windows Mobility Center (Mobile PCs only)(Vista/Win7) mblctr Windows Security Center wscui.cpl Windows System Security Tool syskey Windows Update wupdmgr Windows Update (Vista/Win7) wuapp Windows Update Standalone Installer(Vista/Win7) wusa Windows XP Tour Wizard tourstart Windows Version (About Windows) winver Wordpad write * = optional component that may not be installed on all machines. |
156). RUNAS Execute a program under a different user account... |
---|
(EXPLAIN - RUNAS) Execute a program under a different user account. Syntax RUNAS [/profile] [/env] [/netonly] /user:user Program Key /profile Option to load the user's profile (registry) /env Use current environment instead of user's. /netonly Use the credentials specified only for remote connections. /user Username in form USER@DOMAIN or DOMAIN\USER (USER@DOMAIN is not compatible with /netonly) Program The command to execute Enter the password when prompted. When you start a program with RunAs /netonly, the program will execute on your local computer as the user you are currently logged on as, but any connections to other computers on the network will be made using the user account specified. Without /netonly everything will run under the user account specified. RunAs from Windows Explorer Select an executable file, Shift-Right-click and select Run As.. This option can be hidden by setting HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer HideRunAsVerb=1 ErrorLevel The error level (%ERRORLEVEL%) returned by RunAs in Windows XP and above: success=0, failure=1 Examples Run mycommand.exe as the user Jdoe on domain SS64dom Runas /user:SS64Dom\jDoe "mycommand.exe" Run CMD.exe as the Administrator on the local machine: Runas /profile /user:DELLPC218\administrator CMD Run Notepad.exe as the Domain Administrator on domain SS64dom Runas /profile /env /user:SS64Dom\administrator NOTEPAD Run Notepad.exe and open a file, escape the quote characters around the filename with \ Runas /env /user:jDoe@swest.ss64.com "NOTEPAD \"my file.txt\"" Notes: The backslash \ is NOT the standard escape character used by other CMD commands. RunAs Reqires the "Secondary Logon" service to be running. |
157). RUNDLL32 = Run a DLL command (add/remove print connections)... |
---|
(EXPLAIN - RunDLL32.exe) Run a DLL program. This command is available on all version of Windows from Win95 onwards, but the DLL's and options available do vary considerably. Many options are case sensitive. Syntax RUNDLL32.EXE dll_name,EntryPoint [options] Examples Un-install MS Java Virtual Machine (JVM): RUNDLL32 advpack.dll,LaunchINFSection java.inf,UnInstall Copy a floppy disk RUNDLL32 diskcopy,DiskCopyRunDll Lock workstation RUNDLL32.exe user32.dll, LockWorkStation Add a Network Printer RUNDLL32 printui.dll,PrintUIEntry /ia /c\\server /m "AGFA-AccuSet v52.3" /h "Intel" /v "Windows 2000" /f %windir%\inf\ntprint.inf Add a Local Printer RUNDLL32 printui.dll,PrintUIEntry /if /b "Test Printer" /c\\SERVER /f "%windir%\inf\ntprint.inf" /r "lpt1:" /m "AGFA-AccuSet v52.3" Add a printer connection that's available to anyone who logs on: Rundll32 printui.dll,PrintUIEntry /ga /n\\Server\PrintShare Display all the available commands for PRINTUI.DLL RUNDLL32 printui.dll,PrintUIEntry /? (add/remove print drivers, print queues, preferences, properties etc) |
158). SC = Service Control... |
---|
(EXPLAIN - SC.exe) Service Control - Create, Start, Stop, Query or Delete any Windows SERVICE. The command options for SC are case sensitive. Syntax SC [\\server] [command] [service_name] [Options] Key server : The machine where the service is running service_name : The KeyName of the service, this is often but not always the same as the DisplayName shown in Control Panel, Services. You can get the KeyName by running: SC GetKeyName commands: query [qryOpt] Show status queryEx [qryOpt] Show extended info - pid, flags GetDisplayName Show the DisplayName GetKeyName Show the ServiceKeyName EnumDepend Show Dependencies qc Show config - dependencies, full path etc start START a service. stop STOP a service pause PAUSE a service. continue CONTINUE a service. create Create a service. (add it to the registry) config permanently change the service configuration delete Delete a service (from the registry) control Send a control to a service interrogate Send an INTERROGATE control request to a service Qdescription Query the description of a service description Change the description of a service Qfailure Query the actions taken by a service upon failure failure Change the actions taken by a service upon failure sdShow Display a service's security descriptor using SDDL SdSet Sets a service's security descriptor using SDDL qryOpt: type= driver|service|all Query specific types of service state= active|inactive|all Query services in a particular state only bufsize= bytes ri= resume_index_number (default=0) group= groupname Query services in a particular group Misc commands that don't require a service name: SC QueryLock Query the LockStatus for the ServiceManager Database. this will show if a service request is running SC Lock Lock the Service Database SC BOOT Values are {ok | bad} Indicates whether to save the last restart configuration as the `last-known-good` restart configuration Options The CREATE and CONFIG commands allow additional options to be set see the build-in help: 'SC create' and 'SC config' Note the qryOpt options above are case sensitive - they must be entered in lower case, also the position of spaces and = must be exactly as shown. The SC command duplicates some aspects of the NET command but adds the ability to create a service. SC query will display if a service is running, giving output like this: SERVICE_NAME : messenger TYPE : 20 WIN32_SHARE_PROCESS STATE : 4 RUNNING (STOPPABLE,NOT_PAUSABLE,ACCEPTS_SHUTDOWN) WIN32_EXIT_CODE : 0 (0x0) SERVICE_EXIT_CODE : 0 (0x0) CHECKPOINT : 0x0 WAIT_HINT : 0x0 To retrieve specific information from SC's output, pipe into FIND or FindStr e.g. C:\> SC query messenger | FIND "STATE" | FIND "STOPPED" C:\> SC query messenger | FIND "STATE" | FIND "RUNNING" The statements above will return an %ERRORLEVEL% = 1 if the text is not found IF errorlevel 1 GOTO :my_subroutine The NET START command can be used in a similar way to check if a service is running: NET START | FIND "Service name" > nul IF errorlevel 1 ECHO The service is not running The service control manager will normally wait up to 30 seconds to allow a service to start - you can modify this time (30,000 milliseconds) in the registry HKLM\SYSTEM\CurrentControlSet\Control ServicesPipeTimeout (REG_DWORD) Some options only take effect at the point when the service is started e.g. the SC config command allows the executable of a service to be changed. When the service next starts up it will run the new executable. Config changes requires the current user to have “permission to configure the service”. Examples: SC GetKeyName "task scheduler" SC GetDisplayName schedule SC start schedule SC QUERY schedule SC QUERY type= driver SC QUERY state= all |findstr "DISPLAY_NAME STATE" >svc_installed.txt SC \\myServer CONFIG myService obj= LocalSystem password= mypassword SC CONFIG MyService binPath=c:\myprogram.exe obj=".\LocalSystem" password="" Watch out for extra spaces: SC QUERY state= all Works SC QUERY sTate =all Fails! |
159). SCHTASKS = Schedule a command to run at a specific time... |
---|
(EXPLAIN - SCHTASKS) Create, delete, edit, list, start or stop a scheduled task. Works on local or remote computers. Syntax: SCHTASKS /Create [Connect_Options] Create_Options /TN taskname SCHTASKS /Delete [Connect_Options] /TN taskname [/F] SCHTASKS /Query [Connect_Options] [/FO format] [/NH] [/V] SCHTASKS /Run [Connect_Options] /TN taskname SCHTASKS /End [Connect_Options] /TN taskname SCHTASKS /Change [Connect_Options] {[/RU username] [/RP password] [/TR taskrun]} /TN taskname Connect_Options: /S system # Remote system (default is local) [/U username [/P password]] # Submit job under this name Create_Options: /TR taskrun # Pathname of the executable to run /ST starttime # HH:MM:SS (24 hour) [/RU username [/RP password]] # Run job as this user /SC schedule [/MO modifier] # When to run, see below [/D day] # Day = MON,TUE,WED,THU,FRI,SAT,SUN [/M months] # Month=JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NOV,DEC. [/I idletime] # 1 - 999 minutes (ONIDLE task only) [/SD startdate] [/ED enddate] # Start and end date "dd/mm/yyyy" options: /TN A name for the task /F Force delete, ignore warnings even if the task is currently runnning. /FO Output format: TABLE, LIST, CSV /NH No header /V Verbose output Notes: For MONTHLY schedules give the DAY as a number 1 - 31 (default=1) To prompt for the password, specify /RP * or /RP none The User Account under which the Schedule service runs may require specific file access permissions, user permissions and drive mappings. If the /RU username and /RP Password parameters match the currently logged-in user, the task will run interactively (visible in the foreground). For the system account, /RU username can be written as "", "NT AUTHORITY\SYSTEM" or "SYSTEM", a Password is not required. The system account has full access to the local machine but has no permissions on any other machines (or mapped drives) across the Network. /SC schedule The schedule frequency. Valid schedules: MINUTE,HOURLY,DAILY,WEEKLY,MONTHLY, ONCE,ONSTART,ONLOGON,ONIDLE. /MO modifiers allow finer control: MINUTE: 1 - 1439 minutes. HOURLY: 1 - 23 hours. DAILY: 1 - 365 days. WEEKLY: 1 - 52 weeks. ONCE: No modifiers. ONSTART: No modifiers. ONLOGON: No modifiers. ONIDLE: No modifiers. MONTHLY: 1 - 12, or FIRST, SECOND, THIRD, FOURTH, LAST, LASTDAY. Power Saving The property for "Wake up the machine to run this task" cannot be set using schtasks, but this property is essential if you need the task to run on a machine that has PowerSaving enabled. To work around this, create a task on one computer using the control panel GUI. This will create a .job file in C:\%windir%\Tasks\ To replicate the scheduled task onto other machines copy the .JOB file to C:\%windir%\Tasks on each machine. This techique will not retain any system account credentials, so if you need to run the tasks under System, run the following after copying the .JOB file: SCHTASKS /CHANGE /RU "NT Authority\System" /TN "Yourtaskname" Examples: Create a task to run at 11 pm every weekday SCHTASKS /Create /SC weekly /D MON,TUE,WED,THU,FRI /TN MyDailyBackup /ST 23:00:00 /TR c:\backup.cmd /RU MyDomain\MyLogin /RP MyPassword Now delete the task: SCHTASKS /Delete /TN "MyDailyBackup" /f Create a daily task to run a script at 5 pm: SCHTASKS /create /tn "My Script" /tr "\"c:\my folder\script.cmd\" arguments" /sc daily /sd 12/29/2008 /st 17:00 Task Scheduler options are stored in the registry HKLM\SOFTWARE\Microsoft\SchedulingAgent\ |
160). SCLIST = Display NT Services... |
---|
(EXPLAIN - SCLIST) List Services Syntax SCLIST [options] [ComputerName] Key -r : Display only running services -s : Display only stopped services ComputerName : The computer running the services (default = %ComputerName% ) |
No comments:
Post a Comment