Batch files - Examples (S*)

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 Scheduld.bat List all scheduled task and their main properties W2K 19/11/2003 Requires SysInternals.com' STRINGS.EXE
Download the ZIPped sources SCList.bat List the properties of all shortcuts on an NT machine NT+RK 01/10/1999 Use Shortcut.bat if you do not own a copy of the NT Resource Kit or if you need both UNC path and fully qualified path
Download the ZIPped sources Screen.bat Demo: different ways to display text NT 03/11/1999 Also available as OS/2 Rexx script
Download the ZIPped sources ScrnRes.bat Change remote PC's screen resolution NT 25/08/2004 Requires PSEXEC from SysInternals' PSTools and 12noon's Resolution Changer
Download the ZIPped sources ScrnSavr.bat Install a Windows screensaver and open Control Panel's screensaver settings page 95 98 NT 23/10/1999  
Download the ZIPped sources ScrSzDOS.bat Save current screen size (lines and columns) in environment variables DOS 17/03/2002  
ScrSzNT.bat NT 17/03/2002
Download the ZIPped sources SCSI.bat Enumerate disk drives (IDE and SCSI) W2K 11/09/2006 Version 1 used EGREP, as of version 2.01 Windows 2000's internal FOR command is used instead.
Also available in KiXtart and Rexx.
Download the ZIPped sources Servers.bat Display size, free space and used space (both in MB and as a percentage of disk size) for every partition on every server. NT+RK 24/05/2001 Also available in Rexx and VBScript as FreeSpace.*
Download the ZIPped sources SetOwn.bat Restore ownership and permissions for roaming (TS) profile directories. W2K3 02/07/2005 Requires several (third party) tools, you will be prompted for downloads if these tools are not available.
Download the ZIPped sources SetWallp.bat Make the specified file Windows' wallpaper W2K 30/01/2007 Use Wallpapr.bat to use a random bitmap as wallpaper.
Download the ZIPped sources SFN.bat Display the Short File Name NT4 10/11/2003 Inspired by a tip from Denis Rouleau.
Based on the assumption that time is displayed in 24 hour format; increase "tokens" by 1 on systems with AM/PM time format.
This batch file is obsolete by now; in Windows 2000 SP4 and later use %%~sA or %~s1 instead.
Download the ZIPped sources ShareMig.bat 1.00
ShareMg2.bat 2.00
ShareMg2.vbs 2.00
Migrate all non-printer shares from one server to another. W2K 02/11/2005 Version 1.00 needs to be run on the server, and fails on share names containing spaces, but it is "universal" for both Windows 2000 and Windows Server 2003.
Version 2.00 requires both the batch and the VBScript file, and needs manual modifications for Windows 2000, but it can be run from any computer in the domain and it won't fail on share names containing spaces.
For printer migration, use Microsoft's PrintMig; for Scheduled Tasks migration, copy the scheduled tasks -- %windir%\Tasks\*.job -- to the new server, and use JT.EXE to re-set the "Run as:" property for each migrated task.
Download the ZIPped sources ShDsktop.bat Restore the Show Desktop shortcut in the Quick Launch tray W2K 10/06/2003  
Download the ZIPped sources Shortcut.bat List the (UNC and fully qualified) path that shortcuts point to NT 11/07/2005 Use SCList.bat if you need all properties, not just the path (requires the NT Resource Kit)
Download the ZIPped sources ShortExt.bat Display or modify "extension truncation" registry setting NT 02/03/2002 Based on a tip from the Windows Registry Guide
Download the ZIPped sources ShowPRN.bat Display all physical printers W2K 17/01/2004 Also available as VBScript script.
This batch file requires Microsoft's DEVCON utility.
Download the ZIPped sources ShowPRNT.bat Display all physical printers in tab delimited format W2K 17/01/2004 Also available as VBScript script.
This batch file requires Microsoft's DEVCON utility.
Download the ZIPped sources SNDisk.bat Display harddisk characteristics gathered by IBM's E-Gatherer tool W2K 05/03/2005 May work in XP and Server 2003 too, tested only in 2000.
May generate an error message on non-IBM systems, but will still show the desired results.
More info on EGatherer's undocumented switches is available here.
This batch file depends on E-gatherer's backwards compatibility with older versions, which is entirely up to IBM.
Download the ZIPped sources SortDate.bat
SortTime.bat
Store sorted date and time in variables, independent of Control Panel's "Regional Settings" All 04/10/2006 Take a look at DateTime for a "real DOS" version.
Much simpler in Kix, Perl, Rexx or VBScript.
Download the ZIPped sources Spider.bat Display the validity of hyperlinks in a group of locally stored HTML files NT 12/11/2005 Quick-and-dirty alpha version. Requires WGET.EXE and CUT.EXE.
Download the ZIPped sources SrvSpace.bat Display free space for every partition on every server. TAB delimited screen output for easy export of output. NT 05/06/2000 For Windows XP use DiskSpc.bat instead.
Download the ZIPped sources StarDate.bat Convert current date and time to stardate NT 26/01/2003 Based on an algorithm found on The StarTrek Gallery.
Also available as KiXtart, Perl, Rexx and VBScript scripts
Download the ZIPped sources SysBkup.bat Run a SystemState Backup W2K 10/02/2007 See Microsoft's NTBackup page for available command line switches
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