Batch files - Examples (R*)

Download the ZIPped sources Click the floppy disk icons to download the ZIPped sources

 

Batch file examples
Download the ZIPped sources Name Description OS (1) Last modified
(DD/MM/YYYY)
Remarks
Download the ZIPped sources Random.bat V1
Random.bat V2
Generate random numbers (V1 works only with comma as decimal delimiter; fixed in V2) DOS 07/07/2000 In OS/2 Rexx or Kix only one single line is needed to generate random numbers, Perl needs 2 lines.
Random.bat (NT) V1
Random.bat (NT) V2
Generate random numbers (V1 depends on US language settings, V2 for Windows 2000/XP, by Nathan Rooke, is language independent) NT 08/08/2003
Download the ZIPped sources ReadINI.bat Read a value from an INI file NT 31/07/2007 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.
Download the ZIPped sources ReadReg.bat Read a value from the registry NT 25/10/2004 May fail on "special" characters like & | < > and brackets.
Uses FINDSTR if available, or EGREP otherwise.
Also available as KiXtart, Perl, Rexx and VBScript scripts.
Download the ZIPped sources Recycled.bat Create or delete a shortcut to the "Recycle Bin" in your Start Menu NT 22/09/2001 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.
Download the ZIPped sources RegDLL.bat Add Explorer menu entries to register/unregister DLLs W2K 05/01/2004 Based on an article on The Code Project website
Download the ZIPped sources Regedit.bat and
Regedit.vbs
Open Windows 2000's REGEDIT.EXE in "classic" view instead of last accessed key W2K 16/04/2002 Tip and VBScript file from the Windows Scripting Guide
Download the ZIPped sources RemMacro Use McAfee VirusScan to remove all macro's from MS-Office documents 95 NT 15/03/2002  
Download the ZIPped sources RemoteSID.bat Shows who is logged on to a remote computer, displaying both user ID and Security ID (SID). NT+RK 15/11/2001 Uses PSLOGGEDON.EXE from SysInternals' PsTools "suite"
Download the ZIPped sources RenewUSB Remove all USB devices and then rescan for new ones W2K 11/06/2004 I had to run this script twice before my computer accepted my wife's new USB stick.
Warning: May cripple your OS, use entirely at your own risk, and only after making a full backup.
This scripts uses Microsoft's free DEVCON utility; you will be prompted for download if it isn't found.
Download the ZIPped sources RestHome Use NT's FOR /D parameter to restore a server's home directory shares and access rights NT 17/10/2000 Also available as Rexx scripts for OS/2 LAN Server; or use ForD as a FOR /D replacement in OS/2 batch files
Download the ZIPped sources Reverse.bat Return a string in reverse order NT 05/08/2001 See Tom Lavedas' User-to-User article for a DOS version using CHOICE.
Rexx has a built-in REVERSE() function
Download the ZIPped sources RmHidDev.bat Remove all hidden (inactive) plug&play devices W2K 10/11/2006 Written to remove "ghost devices" from Ghost images.
Warning: May cripple your OS, use entirely at your own risk, and only after making a full backup.
This scripts uses Microsoft's free DEVCON utility; you will be prompted for download if it isn't found.
Download the ZIPped sources RmUserID.bat Delete a user account and the associated data and share. W2K+RK 23/10/2004 Uses the following tools: DSGET and DSQUERY (native in Windows Server 2003, will work in Windows 2000 and XP), RMTSHARE and TAKEOWN (Windows NT 4 Server Resource Kit), TSCMD (www.systemtools.com) and OWN.BAT.
Modify the server and share names to match your own environment.
Download the ZIPped sources RxAssoc.bat 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 11/02/2000 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.
Download the ZIPped sources RXDir.bat Use Regular eXpressions in the DIR command NT 16/10/2004 Requires EGREP, available at Sourceforge.net.
Notes: (1) Operating System version these batch files were meant 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
Kix Windows (most functions also in plain DOS) with KiXtart
NT4 Windows NT 4 (Windows NT 4 Terminal Server Edition too)
NT Windows NT (Windows 2000 and Windows NT 4 Terminal Server Edition too)
NT+RK Windows NT with Resource Kit (Windows NT 4 Terminal Server Edition with Resource Kit too)
W2K Windows 2000, and probably XP and Server 2003 as well
W2K+RK Windows 2000 with (Server) Resource Kit, and (probably) XP and Server 2003 as well
W2K3 Windows Server 2003
XP Windows XP
OS2 OS/2 Warp
TS Windows NT 4 Terminal Server Edition, or Windows 2000 Server or Windows Server 2003 with Terminal Services