Rob van der Woude's Scripting Pages

Batch Files: Examples (R)

💾 Click the floppy disk or package (for third party scripts) 📦 icons to download the ZIPped sources

Click the question mark icons to view the MD5 and SHA1 checksums for the ZIPped sources

 

 

All 0..9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

 

Batch file examples
💾 Name Version Description OS (1) Last modified Remarks
💾 Random.bat 1.00 Generate random numbers DOS 2000-07-07 Works only with comma as decimal delimiter; fixed in 2.00.
In OS/2 Rexx or KiXtart only one single line is needed to generate random numbers, Perl needs 2 lines.
💾 Random.bat 2.00 Generate random numbers DOS 2000-07-07 In OS/2 Rexx or KiXtart only one single line is needed to generate random numbers, Perl needs 2 lines.
💾 Random.bat 1.00 Generate random numbers NT 2003-08-08 Depends on US language settings.
In OS/2 Rexx or KiXtart only one single line is needed to generate random numbers, Perl needs 2 lines.
💾 Random.bat 2.00 Generate random numbers NT 2003-08-08 Language independent.
In OS/2 Rexx or KiXtart only one single line is needed to generate random numbers, Perl needs 2 lines.
💾 RC.bat 2.11 Display the errorlevel returned by the specified command and the time it took NT 2012-07-02  
💾 ReadINI.bat 1.30 Read a value from an INI file NT 2007-07-31 May fail on "special" characters like & | < > and parentheses.
In version 1.20 the speed of processing has been improved by Jeroen Verschuuren.
Version 1.30 contains several improvements by Van Woods, US Army Corps of Engineers, Seattle District.
READINI is also available as KiXtart, Perl, Rexx and and VBScript scripts.
💾 ReadLine.bat 1.00 Read the specified line(s) from standard input and store it in an environment variable W2K 2011-01-19 Skips empty lines.
💾 ReadReg.bat 2.10 Read a value from the registry NT 2004-10-25 Requires EGREP or FINDSTR.
May fail on "special" characters like & | < > and parentheses.
Uses FINDSTR if available, or EGREP otherwise.
Also available as KiXtart, Perl, Rexx and VBScript scripts.
💾 ReadXML.bat 1.10 Read a value from an XML file NT 2011-02-06 Requires XML Starlet
💾 Recycled.bat 1.00 Create or delete a shortcut to the "Recycle Bin" in your Start Menu NT 2001-09-22 The shortcut does not give you the same functionality as the original Recycle Bin, but it can be used to quickly check the properties of deleted files.
Tested in NT 4 only.
💾 RegDLL.bat 1.01 Add Explorer menu entries to register/unregister DLLs W2K 2004-01-05 Based on an article on The Code Project website.
💾 RemMacro 1.00 Use McAfee VirusScan to remove all macro's from MS-Office documents 95 NT 2002-03-15  
💾 RemoteSID.bat 2.11 Shows who is logged on to a remote computer, displaying both user ID and Security ID (SID). NT 2001-11-15 Requires GETSID and PSLOGGEDON
📦 Removables.bat 5.0c Display mounted removable devices W2K 2008-07-27 Written by Carlito S.
Does not require administrator privileges.
💾 RenewUSB 1.01 Remove all USB devices and then rescan for new ones W2K 2017-01-16 Requires DEVCON.
Use ResetDevices.bat instead on Windows 7 and later.
💾 RepeatEvery 1.02 Repeat a command forever, with a specified interval, until a key is pressed W7 2016-07-05  
💾 ResetDevices 1.01 Remove disconnected devices W7 2017-01-16 Requires DEVCON.
You will be prompted for download if DEVCON isn't found.
💾 Restart_Ethernet.cmd 1.01 Restart Ethernet network adapter W7 2020-09-02 Requires elevated privileges.
💾 RestartMouse.bat 1.00 Restart a mouse that suddenly hangs, when plugging in a new mouse doesn't help W7 2022-12-04 Requires DEVCON
💾 RestHome   Use NT's FOR /D parameter to restore a server's home directory shares and access rights NT 2000-10-17 Also available as Rexx scripts for OS/2 LAN Server; or use ForD as a FOR /D replacement in OS/2 batch files.
💾 ResumePrinting.bat 1.00 Resume printing on the specified printer XP 2010-07-11 Requires WMIC.
Use PausePrinting.bat to pause printing.
Also available in VBScript.
💾 Reverse.bat 2.00 Return a string in reverse order NT 2001-08-05 See Tom Lavedas' User-to-User article for a DOS version using CHOICE.
Rexx has a built-in REVERSE() function.
💾 RipCD.bat 1.01 Save audio CD tracks as MP3s W7 2016-10-06 Requires VLC Media Player.
Based on a batch file by elrobis, to which I added automatic detection of VLC path and CDROM drive letter.
💾 RmHidDev.bat 1.00 Remove all hidden (inactive) Plug&Play devices W2K 2006-11-10 Requires DEVCON.
Written to remove "ghost devices" from Ghost images.
You will be prompted for download if DEVCON isn't found.
Warning: May cripple your OS, use entirely at your own risk, and only after making a full backup.
💾 RmUserID.bat   Delete a user account and the associated data and share W2K 2004-10-23 Requires Windows Server 2003's DS Tools, RMTSHARE, TAKEOWN, TSCMD and OWN.BAT
💾 RoboMove.bat   Moves files in target folder to match source folder as closely as possible, to make following ROBOCOPY process more efficient W2K 2014-10-09 Best used together with ROBOCOPY.
Warning: beta version, not tested rigorously yet.
💾 RunBackupWithoutSleep.bat 1.20 Run a backup, defrag or any other long task without the computer going to sleep W7 2012-10-15  
💾 RxAssoc.bat 2.00 Associates the REX extension with Regina Rexx executable. After executing this batch file once, you can call any *.REX directly, without the need to precede it with REXX.EXE. NT 2000-02-11 With SET PATHEXT=.REX;%PATHEXT% (better yet: set it as a global variable in Control Panel, System) you won't need to type the .REX extension to run .REX scripts.
Adapt the (hard coded) path for REXX.EXE to your own situation.
Better still, use REGINA.EXE instead of REXX.EXE.
💾 RXDir.bat   Use Regular eXpressions in the DIR command NT 2004-10-16 Requires EGREP

 

All 0..9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

 

Notes: (1) Operating System version these batch files were written for
All No version specific commands are used, though it is (obviously) not tested with every DOS version available
95 Windows 95 (and probably Windows 98 as well)
98 Windows 98
DOS3 MS-DOS 3 and 4
DOS6+ MS-DOS 6 and later
NT Windows NT 4 and later
NT4 Windows NT 4 (Windows NT 4 Terminal Server Edition too)
W2K Windows 2000 and later
XP Windows XP
W2K3 Windows Server 2003
W2K8 Windows Server 2008
W10 Windows 10
WV Windows Vista
W2K8R2 Windows Server 2008 Release 2
W7 Windows 7
OS2 OS/2 Warp
TS Windows NT 4 Terminal Server Edition, or Windows Server 200* with Terminal Services

page last modified: 2024-10-09; loaded in 0.0138 seconds