Posts

Showing posts from 2009

Delete files older than x days using batch script

This one keeps coming back when you are administering several systems which are all pushing out some files to storage for example OLD SQL servers who are spitting out BAK files. Forfiles /P D:\SQLbackup /S /M *.BAK /D -2 /C "cmd /c del /q @path" Forfiles is standard included in windows since Windows 2000 Let me explain the switches I used. /P |This one is for specifying the path. /S |This is the same as in the dir command for recursively enumerating the files. /M |Where you specify the search pattern to look for. /D -2 |This is the most interesting part beacause this switch looks for files older or equal than 2 days. /C |Here is where you specify what to do. If you want to start a command make sure it starts with cmd /c, I did a del command specifying the file by using the @path variable.

Starting a CMD prompt hidden for cacti poller.php

After implementing a CACTI monitoring environment at our customer on a windows platform (huh). We had a problem that our CACTI poller scheduled task was visible when it was started. I first created this vbscript. To start the commandprompt hidden. Set WshShell = WScript.CreateObject("WScript.Shell") Set WshExec = WshShell.Exec("php c:\Apache2\htdocs\cacti\poller.php") But this method is much better. Because it fits on 1 line! CreateObject("Wscript.shell").run "php c:\Apache2\htdocs\cacti\poller.php",0 In short to run the cacti poller hidden you only have to schedule the above line in a vbscript every 5 minutes.

Netbackup Admin Script

Normal procedure for NetBackup with our Robot with 2 LTO4 tapes is physically adding media then do an inventory and then check in the gui your retention period for the tapes. I've written a script which does all that. The only thing you need to change part where I let findstr search for eg LTO4 (all our LTO4 tapedrives use a pool with LTO4 in the name) @echo off e: cd "\Program Files\Veritas\Volmgr\bin" Rem ***************** REM * Inventory Robot REM ***************** vmupdate -rt TLD -rn 1 -h hpbck01 -rh hpbck01 -use_barcode_rules Rem ************** Rem * Expire Media REM ************** for /f "delims=, " %%a in ('"vmquery -rn 1 -bx findstr /I "LTO4""') do "E:\Program Files\Veritas\NetBackup\bin\admincmd\bpexpdate.exe" -d 0 -ev %%a -force Rem **************************** Rem * Move media to scratch pool REM **************************** for /f "delims=, " %%b in ('"vmquery -rn 1 -bx findstr /I "NetB

Recover Deleted Items Outlook 2000

By default, the Recover Deleted Items functionality is only enabled on the Deleted Items folder in a user's private folders. Items that are hard deleted cannot be recovered. To enable the Recover Deleted Items functionality on mail folders other than the Deleted Items folder (for example, for the Sent Items, Drafts, Outbox and Inbox folders), make the following changes to the registry: Start Registry Editor. Locate and then click the following key in the registry: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Exchange\Client\Options On the Edit menu, click Add Value , and then add the following registry value: Value name: DumpsterAlwaysOn Data type: DWORD Value data: 1 Close Registry Editor. You can use an administrator's computer or a user's computer to make this change to the registry. After you change the registry, start Outlook, and then click Deleted Item Recovery on the Tools menu. A list of items that were hard deleted during the retention time that is set on the s

Copy fonts using script for unattended vista install

I had to create a vbscript to copy fonts from a network share for an unattended vista (or windows 7) install Const FONTS = &H14& Set objShell = CreateObject("shell.Application") Set objFolder = objShell.Namespace(FONTS) strdir = "\\srv001\REMINST\Drivers\Finalize\Fonts" enumdir(strdir) Sub EnumDir(strdir) dim FSO,f,fc set FSO=Wscript.CreateObject("scripting.FileSystemObject") If fso.FolderExists(strDir) then set f=fso.GetFolder(strDir) set fc=f.files if fc.Count > 2 then for each fl in fc objFolder.CopyHere strdir & "\" & fl.name next End If else wscr

Terminal Server Profile Path Woes

During a migration process I came accross this odd problem. I could not change a Terminal Server Profile Path for a couple of hundred users. I searched the microsoft site but I could not find anything that would help me quick. Yes I did find this link http://technet.microsoft.com/en-us/library/cc783578.aspx But my client did not have grouppolicies in place and I did not want to use the "Terminal Services Extension" I found several partly usefull scripts I combined the best of them in the script below. I really hope you will find this usefull. '****************************************************************************** Const ADS_SCOPE_SUBTREE = 2 Const ForAppending = 8 On Error Resume Next Set objFSO = CreateObject("Scripting.FileSystemObject") Set objTextFile = objFSO.OpenTextFile ("c:\myusers.txt", ForAppending, True) Set objConnection = CreateObject("ADODB.Connection") Set objCommand = CreateObject("ADODB.Command") objConnect