Welcome to the ScriptVault, where ScriptingAnswers.com users share their administrative scripts.

Have you written a script that accomplishes some administrative task? Please share it! Just navigate to the appropriate category and click the "Contribute to this category" link!

You are here: Top > Misc Batch

Contribute to this category


Sub-Categories

(no categories are available)

 

Scripts

Add Active Directory User Role Contributed by Tristan Emerson
This script is to be used when trying to add a user to Active Directories, but the user may already be in the system. The script checks to see if the user exists in the system, then does the following based on the condition. If the user exists, make the user a member of the group passed. If the user does not exists, add the user and put him/her in the group passed. Input is to be taken in the following format: addUserRole.bat uname fname lname pwd "group" "OU" The "group" and "OU" are put in quotations because in the system I was using we had some groups and OUs that were more than one word. The file can be modified so it will take in multiple word last-names etc.
Common .CMD Methods Contributed by Marshall
These scripts cover several different 'methods' that I use regularly inmy daily scripting. They help add a lot of flexibility and power to batch files. What 'methods' are covered? 1) How to spawn a .VBS from a .CMD (Create it, execute it, delete it)and gather variables from that execution. Here we'll be gatheringa USERNAME and PASSWORD from a msgBox. 2) The use of FOR F/ %%I in a .CMD file to pull lines from a textfilein as a variable. 3) Creation and appending of files with redirectors > and >>(basic reports and logs) as well as the creation of directories, shouldthey not exist 'IF NOT EXIST' 4) Calling psexec.exe from within a .CMD file with variables 5) Parsing of a text file using FIND /V and redirectors. Besides acting as a tutorial on these methods the 'real' purpose of thescript is to gather the Audit Policies and NET ACCOUNTS informationfrom remote systems (specified by the SERVERS.INI) and save thatinformation in a report. It will also generate a log to showcompletion. Filesfound here: SERVERS.INI - As with most of my scripts these .CMD files aredependant upon youcreating a SERVERS.INI file to hold a list of hostnames or IP addressesto the remote systems you wish to use. GETPOL.CMD - This is the fileyou'll run, it will gather the username and password from user inputand pass those variables to AUDIT.CMD AUDIT.CMD - The 'meat' of the script, this will gather the dataand output it to a report. Dependancies- These scripts are dependant upon the following executables: psexec.exe from thePsTools Toolkit which can be downloaded for free fromhttp://www.systernals.com/ auditpol.exe from the WindowsNT/2000 Resource Kit
DskChk.cmd Contributed by Christian Sawyer
First, it does a read-only Chkdsk. If Chkdsk sets the errorlevel to 3, meaning that it found errors and needs to be run with the /F (fix) option, the file checks to see whether the systemroot or pagefile exist on the drive. If so, it runs Chkdsk the next time the system is rebooted. If systemroot or pagefile don't exist on the drive, it runs a Chkdsk /F /R now, and then it runs a Defrag -b and a regular Defrag. (The -b switch is an undocumented switch that optimizes the drive for boot.) I ran it as well on my SBS2K3 server and 2K3 servers as on my XP machine.
Fix script for Sun Java DST tzupdater patch Contributed by Kirk Patten
This script may be used to apply the Sun Java DST fix for 2007, tzupdater.jar. It will patch all Sun Java binaries on a system that are supported by tzupdater.jar in one go. It lists the disk partitions and searches for java.exe binaries to execute with tzupdater.jar. Helpful because SUN does not supply a solution for recursive application on Windows.
MakeMM21 Contributed by Mark Fairpo
Install Movie Maker 2.1 from WinXP-SP2 or a cancelled SP2 Setup ___________________________ Exiting... Unable to detect your desired operation: 1. To create \MM21INF, run me from inside %windir%\ServicePackFiles\I386 '' or %windir%\I386 on WinXP-SP2, or from inside the temporary extract '' folder from WindowsXP-KB835935-SP2-ENU.exe then cancel SP2 Setup 2. In Safe-Mode (F8 on boot) right-click MOVIEMK.INF and choose Install 3. Run me again from inside Movie Maker folder to register new v2.1 DLLs \MM21INF is a basic install that needs Windows Media Format 9 Series SDK runtime (WMFdist.exe or MM20ENU.exe) and Microsoft add directX 9.0c or later Step 1 needs 18 files: blank.txt empty.txt filters.xm? moviemk.ch? moviemk.ex? moviemk.in? news.pn? paint.pn? sample1.jp? sample2.jp? wmm2ae.dl? wmm2eres.dl? wmm2ext.dl? wmm2filt.dl? wmm2fxa.dl? wmm2fxb.dl? wmm2res.dl? wmm2res2.dl? THIS BATCH FILE HAS NOT BEEN WIDELY TESTED. GREAT CARE WAS TAKEN TO ENSURE THAT THIS BATCH FILE PERFORMS AS IT SHOULD. IT IS PROVIDED ''AS IS'', BY USING THIS BATCH FILE, YOU AGREE TO USE IT AT YOUR OWN RISK.
Remove Active Directory User Role Contributed by Tristan Emerson
This script is to be used when trying to remove a user from Active Directories, and delete the user entirely if they are left in no groups. Input is to be taken in the following format: remUserRole.bat uname fname lname "group" "OU" The "group" and "OU" are put in quotations because in the system I was using we had some groups and OUs that were more than one word. The file can be modified so it will take in multiple word last-names etc.