Posts

Showing posts with the label windows automation

Windows VBS Automated Maintenance Scripts

I had a need to automate a number of tasks for remote administration, and used Visual Basic Scripting and Windows Scripting Host Objects, since I am fairly comfortable with VB/VBA. This is an automated defragmentation script that uses dirms.exe, a defragmentation utility found here . Option Explicit Dim FSO, Drive, oShell, WshShell, BtnCode, rtn, hd, stComp Set WshShell = WScript.CreateObject("WScript.Shell") Set FSO = CreateObject("Scripting.FileSystemObject") Set oShell = WScript.CreateObject ("WScript.shell") '''' ''''''''''''''''''' DIRMS.EXE USAGE ' dirms c -q : Do free space evaluation, defragment, and quickly move files to the front of the drive ' dirms c DEFRAG -q : Defragment files only ' dirms c CoMpAcT -q : C ompact only ' dirms c COMFRAG -q : Perform partial compaction (quickly) on all fragmented files ' dirms c COMFRAG c:\filena...

Database updates

I needed a method to update a database application across a WAN, and found that I could do this with my Linux firewalls, and Windows batch scripting. The topology is this: Win2k Svr -> Linux FW -> Internet Win2k Svr batch file: @ECHO OFF SET _LOGFILE=mydb.log Net Stop "SQL Anywhere - mydb" >> "%_LOGFILE%" ATTRIB -R "C:\Program Files\mydb Software\mydb\mydb.db" ATTRIB -R "C:\Program Files\mydb Software\mydb\mydb.log" NET USE Z: \\win2ksvr\home\backup\backup\mydb admpass /USER:domain\admin FOR /F "tokens=2,3,4 delims=/ " %%i in ('DATE /T') do set d=%%k%%i%%j FOR /F "tokens=1,2,3 delims=:. " %%i in ('TIME /T') do set t=%%i%%j%%k XCOPY "C:\Program Files\mydb Software\mydb\mydb.log" Z: CALL :REPORT %ERRORLEVEL% "C:\Program Files\mydb Software\mydb\mydb.log" XCOPY "C:\Program Files\mydb Software\mydb\mydb.db" Z: CALL :REPORT %ERRORLEVEL% "C:\Program Files\mydb Softwar...