Posts

Showing posts with the label vb

Using Batch to decrypt PGP and more

Image
This script was recently written to automatically process files on our FTP server. They come in daily, in pairs, and dated with todays date, e.g. XXERUP0912.dat.pgp. The script checks for existence, ensures a pair is found, makes sure they are the right and same date, then decrypts them and calls an external program I wrote to inject them into a SQL database for querying via ASP, which I also wrote. If any of the steps fail, it gets logged, and an email notification is sent to a number of folks. I had a bit of an issue with expansion, but found the error of my ways in short order... @ECHO On SETLOCAL ENABLEDELAYEDEXPANSION :: ////////////////////////////////////////////// :: :: Set path variables for key access, passphrase, :: and source our key files. SET PGPPATH=C:\PGP_Keys\ SET PGPPASS=MYPGPPASS :: The "KEY" to a successful import of our keys is running these commands as the user :: that will be running this script. :: pgp +batchmode -ka %PGPPATH%SE...

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...