Scripting...

I've been putting together a lot of automation in the way of login/logout scripts, and documenting on our company Intranet that I put together [FlexWiki.com]. Here are the scripts.

UPLOAD.BAT

  • Location: F:\DATA\DOWNLOAD\OUTPUT.
  • Explanation: Used by persons scrubbing data to upload to Misys server and change permissions for interfacing purposes. Without this script, the files would not be set to the correct permissions, and a root user would have to manually change those at the AIX CLI.
@ECHO OFF

:: Create the temporary script file
>script.ftp ECHO ftputil
>>script.ftp ECHO mypassword
>>script.ftp ECHO ascii
>>script.ftp ECHO prompt n
>>script.ftp ECHO cd /src/APPS/HT/bin
>>script.ftp ECHO mput *.TXT
>>script.ftp ECHO debug .

:: Create the file list
dir /b *.TXT > FILES.LST
FOR /F "tokens=1" %%I IN (FILES.LST) DO >>script.ftp ECHO quote SITE chmod 666 %%I

:: Exit FTP
>>script.ftp ECHO quit

:: Use the temporary script for unattended FTP
FTP -v -s:script.ftp misys

:: Now move the files into the upload dir
FOR /F "tokens=1" %%I IN (FILES.LST) DO MOVE %%I UPLOAD

:: For the paranoid: overwrite the temporary file before deleting it
TYPE NUL >script.ftp
TYPE NUL >FILES.LST
DEL script.ftp
DEL FILES.LST
GOTO End

:END
EXIT

LOGON.BAT

  • Location: \\IBSFP\NETLOGON.
  • Explanation: Used for all users logins.
@ECHO OFF

:: ----------------------------------------------
::   Don't run on DC's
@SET DC=IBSFP
@SET DC1=IBSFAX
IF "%DC%" == "%COMPUTERNAME%" GOTO EOF
IF "%DC1%" == "%COMPUTERNAME%" GOTO EOF

:: ----------------------------------------------
::   Assign a drive letter to netlogon
NET USE X: \\IBSFP\NETLOGON

:: ----------------------------------------------
:: Run our kix scripts...

::   This one copies the appropriate WSFTP
::   config files, to the users pc.
::   Make sure they belong to the right groups.
::   i.e. FTPmngmnt, FTPRecovery, or FTPAcctsRec
X:\KIX\WKIX32.EXE X:\KIX\WSFTP_INI.KIX

::   This maps appropriate drives based on group membership
X:\KIX\WKIX32.EXE X:\KIX\MAP_DRIVES.KIX

::   This copies flashcode if not found on the machine.
::   See script for instructions.
X:\KIX\WKIX32.EXE X:\KIX\FLASH_CODE.KIX

::   This takes care of the compliance notice.
X:\KIX\WKIX32.EXE X:\KIX\WELCOME.KIX

::   NOTE: install_vnc.kix, tif_regfix.kix and postscript_fix.kix
::         are handled by 'Software Installation' GPO see scrips
::         for explanations.
:: ------ END OF KIX SCRIPTS -------

:: ----------------------------------------------
::   Copy pstsize to local machine
::   This checks for maximum PST size limitations
::   and issues a warning if it reaches a size of
::   1.8gb or larger.
IF NOT EXIST %WINDIR%\SYSTEM32\PSTSIZE.EXE COPY X:\PST\PSTSIZE.EXE %WINDIR%\SYSTEM32\
pstsize /G /M=One of your mail folders has exceeded it's recommended size. PLEASE ARCHIVE DATA BEFORE

CORRUPTION AND MAIL LOSS OCCURS!

:: ----------------------------------------------
::   Copy easyprint to the desktop if it's not there
IF NOT EXIST "%ALLUSERSPROFILE%\DESKTOP\EASYPRINT.LNK" COPY X:\EASYPRINT.LNK "%ALLUSERSPROFILE%\DESKTOP\"

:: ----------------------------------------------
::   Copy defrag script to local pc
IF NOT EXIST C:\DAILY.BAT COPY X:\DEFRAG\DAILY.BAT C:\
IF NOT EXIST C:\WEEKLY.BAT COPY X:\DEFRAG\WEEKLY.BAT C:\
AT | FIND /I "DAILY.BAT"
IF ERRORLEVEL 1 AT 22:00 /EVERY:M,T,W,TH,F C:\DAILY.BAT
AT | FIND /I "WEEKLY.BAT"
IF ERRORLEVEL 1 AT 22:00 /EVERY:SU C:\WEEKLY.BAT


:: ----------------------------------------------
::   Copy reboot script, and schedule it, but not for DAVID's PC's
IF "%COMPUTERNAME%" == "IBSPC25" GOTO EOF
IF "%COMPUTERNAME%" == "IBSPC22" GOTO EOF
IF NOT EXIST C:\REBOOT.VBS COPY X:\DEFRAG\REBOOT.VBS C:\
AT | FIND /I "REBOOT.VBS"
IF ERRORLEVEL 1 AT 19:30 /INTERACTIVE /EVERY:M,T,W,TH,F,S,SU C:\REBOOT.VBS


:: ----------------------------------------------
::   Get outta here
GOTO EOF


:: ----------------------------------------------
:EOF
::   remove x:
NET USE X: /DEL
EXIT

LOGOFF.BAT

  • Location: \\IBSFP\NETLOGON
  • Explanation: Used for all users logoffs.
@ECHO OFF
CD /D C:\DOCUMENTS AND SETTINGS
:: Flush temp inet files
FOR /D %%X IN (*) DO DEL /F /S /Q "C:\DOCUMENTS AND SETTINGS\%%X\LOCAL SETTINGS\TEMPORARY INTERNET FILES\*.*"

:: Flush temp files
FOR /D %%X IN (*) DO DEL /F /S /Q "C:\DOCUMENTS AND SETTINGS\%%X\LOCAL SETTINGS\TEMP\*.*"
DEL /F /S /Q %WINDIR%\TEMP\*.*
DEL /F /S /Q C:\TEMP\*.*

:: Deletes Microsoft Update files
SET UNF=%SYSTEMROOT%\$NTUNINSTALL*
FOR /F "TOKENS=*" %%I IN ('DIR /B /AD %UNF%') DO RD /S /Q "%SYSTEMROOT%\%%I"

SET UNF=%SYSTEMROOT%\$MSI31UNINSTALL*
FOR /F "TOKENS=*" %%I IN ('DIR /B /AD %UNF%') DO RD /S /Q "%SYSTEMROOT%\%%I"

SET UNF=%SYSTEMROOT%\$NTSERVICEPACK*
FOR /F "TOKENS=*" %%I IN ('DIR /B /AD %UNF%') DO RD /S /Q "%SYSTEMROOT%\%%I"

:: ----------------------------------------------
::   Get outta here
GOTO EOF

:EOF
EXIT

DEFENDER.CMD

  • Location: \\IBSFP\NETLOGON.
  • Explanation: Used for all users MS Defender settings. Deployed through Software Installation GPO.
@ECHO OFF

REM ScanParameters=Full or quick scan. 2 is Full. Assume 1 is quick [Unverified].

REM ScheduleDay=what day to run. 5 is Thursday. Monday is 2. Sunday 1.

REM ScheduleTime=540 (decimal) equals "approx 09.00" hours. 0400hrs equals decimal setting 240, so my guess is that it's 1 per minute. 0401hrs would be "241".

REM AllowNonAdminFunctionality= Allow non-admins to screw around with the settings. 0 equals don't allow, 1 allow them.

REG ADD "HKLM\vSOFTWARE\Microsoft\Windows Defender\Scan" /v ScanParameters /d 2 /t REG_DWORD /f
REG ADD "HKLM\SOFTWARE\Microsoft\Windows Defender\Scan" /v ScheduleDay /d 7 /t REG_DWORD /f
REG ADD "HKLM\SOFTWARE\Microsoft\Windows Defender\Scan" /v ScheduleTime /d 540 /t REG_DWORD /f
REG ADD "HKLM\SOFTWARE\Microsoft\Windows Defender\UX Configuration" /v AllowNonAdminFunctionality /d 0 /t REG_DWORD /f

3DSCR.KIX

  • Location: \\IBSFP\NETLOGON\KIX.
  • Explanation: This script is reponsible for setting the desktop screensavers. Deployed through ScreenSaverWallpaper GPO.
IF setconsole("hide")
ENDIF

WriteValue("HKEY_USERS\@SID\Software\Microsoft\Screensavers\Text3D", "AllScreensSame", "00000000", "REG_DWORD")
WriteValue("HKEY_USERS\@SID\Software\Microsoft\Screensavers\Text3D", "SurfaceType", "00000001", "REG_DWORD")
WriteValue("HKEY_USERS\@SID\Software\Microsoft\Screensavers\Text3D", "Specular", "00000001", "REG_DWORD")
WriteValue("HKEY_USERS\@SID\Software\Microsoft\Screensavers\Text3D", "SurfaceColor", "00008080", "REG_DWORD")
WriteValue("HKEY_USERS\@SID\Software\Microsoft\Screensavers\Text3D", "CustomTexture", "", "REG_SZ")
WriteValue("HKEY_USERS\@SID\Software\Microsoft\Screensavers\Text3D", "CustomEnvironment", "", "REG_SZ")
WriteValue("HKEY_USERS\@SID\Software\Microsoft\Screensavers\Text3D", "UseCustomColor", "00000001", "REG_DWORD")
WriteValue("HKEY_USERS\@SID\Software\Microsoft\Screensavers\Text3D", "UseCustomTexture", "00000000", "REG_DWORD")
WriteValue("HKEY_USERS\@SID\Software\Microsoft\Screensavers\Text3D", "UseCustomEnvironment", "00000000", "REG_DWORD")
WriteValue("HKEY_USERS\@SID\Software\Microsoft\Screensavers\Text3D", "MeshQuality", "000001f4", "REG_DWORD")
WriteValue("HKEY_USERS\@SID\Software\Microsoft\Screensavers\Text3D", "Size", "0000000a", "REG_DWORD")
WriteValue("HKEY_USERS\@SID\Software\Microsoft\Screensavers\Text3D", "RotationSpeed", "0000000a", "REG_DWORD")
WriteValue("HKEY_USERS\@SID\Software\Microsoft\Screensavers\Text3D", "RotationStyle", "00000003", "REG_DWORD")
WriteValue("HKEY_USERS\@SID\Software\Microsoft\Screensavers\Text3D", "DisplayString", "ibs", "REG_SZ")
WriteValue("HKEY_USERS\@SID\Software\Microsoft\Screensavers\Text3D", "DisplayTime", "00000000", "REG_DWORD")
WriteValue("HKEY_USERS\@SID\Software\Microsoft\Screensavers\Text3D", "FontWeight", "00000190", "REG_DWORD")
WriteValue("HKEY_USERS\@SID\Software\Microsoft\Screensavers\Text3D", "FontHeight", "fffffff3", "REG_DWORD")
WriteValue("HKEY_USERS\@SID\Software\Microsoft\Screensavers\Text3D", "FontItalic", "00000000", "REG_DWORD")
WriteValue("HKEY_USERS\@SID\Software\Microsoft\Screensavers\Text3D", "FontCharSet", "01020300", "REG_DWORD")
WriteValue("HKEY_USERS\@SID\Software\Microsoft\Screensavers\Text3D", "FontPitchFamily", "61004252", "REG_DWORD")
WriteValue("HKEY_USERS\@SID\Software\Microsoft\Screensavers\Text3D", "FontFace", "Bauhaus 93", "REG_SZ")

FLASHCODE.KIX

  • Location: \\IBSFP\NETLOGON\KIX.
  • Explanation: This script deploys Flashcode to the desktops. Deployed through LOGON.BAT.
IF setconsole("hide")
ENDIF

; ACHM Users dont have the necessary drives mapped, so don't run this
IF INGROUP ("ACHM") =1
EXIT
ENDIF


; John Croson - 04/2009

; Purpose: Deploy Flash Code to clients.
;   1. Install locally on your pc
;   2. Run it, and provide the serial number
;   3. Copy the shortcut created on the desktop to the installation directory
;   4. Copy the entire contents of your installation [YYYY Q?] to \\ibsfp\gpoassignedsoftware\flashcode

; \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
;
;  DO NOT CHANGE THE DIRECTORY STRUCTURE OF THE FLASH CODE REPOSITORY, LISTED IN STEP 4 ABOVE.
;  THIS SCRIPT SIMPLY LOOKS FOR THESE FOLDERS ON THE CLIENT PC, AND IF NOT FOUND, COPIES THE FILES.
;  IF YOU PUT SOMETHING ELSE IN THE FLASH CODE REPOSITORY LISTED IN STEP 4 ABOVE, IT WILL BE COPIED AS WELL.
;
; \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\


; This checks for the existance of the Flash Code root directory
; If C:\Program Files\Flash Code doesn't exist, create it
; This will also be used as the client install path variable
$fc = "C:\Program Files\Flash Code"
IF NOT EXIST ($fc)
  MD "$fc"
ENDIF


; Set our Flash Code repository path, and first charachter, as
; KixTart "sees" the ".." directory listing, if omitted
$fcSrc = "\\IBSFP\GPOAssignedSoftware\Flash Code\"
$DirName = Dir($fcSrc + "2*")

While $DirName <> "" and @ERROR = 0
    ? "Found " + $DirName

; Concat the install dir path
$fcDest = $fc + "\" + $DirName

; If C:\Program Files\Flash Code\$DirName doesn't exist, ask of the user wants it installed.
IF NOT EXIST($fcDest)
$return = MessageBox("You don't have " + $DirName + " FlashCode." + chr(13) + "Installation will take approximately 1 - 3 minutes." + chr(13) + "Do you want it installed?", "IHBS Software", 36)
    ; If we say no, go to the next Installation check
    IF $return = 7
    GOTO End
    ENDIF

;otherwise continue executing
? "Making new dir..."
MD $fcDest

; Concat the absolute source of files
$fcAbsSrc = $fcSrc + $Dirname

COPY $fcAbsSrc $fcDest + "\" /c /r /h /s
    If @Error <> 0
        MessageBox("Error " + @Error + " has been encountered during the file copy phase." + chr(13) + "Please notify IT of this error.", "File Copy Error", 0, 10)
    EndIf

? "Copying link..."
COPY $fcDest + "\Flash Code " + $DirName + ".lnk" "C:\Documents and Settings\All Users\Desktop\"
    If @Error <> 0
        MessageBox("Error " + @Error + " has been encountered during the link copy phase." + chr(13) + "Please notify IT of this error.", "Link Creation Error", 0, 10)
    Else
        MessageBox("The copy process is complete." + chr(13) + "You should now have a new icon on your desktop.", "IHBS Software", 0, 10)
    EndIf
ENDIF

:End

    $DirName = Dir()  ; retrieve next file
Loop

INSTALL_VNC.KIX

  • Location: \\IBSFP\NETLOGON\KIX.
  • Explanation: Installs VNC to desktop workstations. Deployed through Software Installation GPO.
IF setconsole("hide")
ENDIF

; KiXtart Script
;
; install_vnc.KIX
;
;
; From post found here, outlining the details of deploying UltraVNC
; http://forum.ultravnc.info/viewtopic.php?p=26475
;
;     download UltraVNC-101-Setup.exe
;
; - run the exe with the command "UltraVNC-101-Setup.exe /saveinf=c:\someconfigfile.inf" ,
; this will save the main config file to a path of your choosing.
;
; - go through the setup changing config settings to how you want it installed (language, program path, etc).
;
; Make sure to make the following selections
; UltraVNC Server
; Mirror Driver
; DSM Encryption Plugin
;
; and on the additional tasks page
;
; select Register UltraVNC as service
; DO NOT select Start or restart UltraVNC Service
; select Configure MS-Logon II
; DO NOT select Configure Admin Properties
; DO NOT select Clean old VNC registry keys
;
; Don't worry about the ACL settings, we will change those in a bit
;
; Finish up the install.
;
; Now that it is install, go to the start menu and click on UltraVNC > UltraVNC Server
;
; Double click on the tray icon which will pull up the admin settings.
;
; Make all the changes you want applied across all computers here. The password, MS Logon groups, and misc settings need to be set.
;
; Now that you have made all your admin changes, go to your program path within DOS, by default c:\program files\ultravnc.
;
; Type in MSLogonACL.exe /e c:\someaclconfigfile.acl - this will create your ACL file
;
; close DOS and go to regedit - start > run > regedit
;
; Export the hkey_local_machine > software > ORL key to a reg file
;
; now, edit the someconfigfile.inf file you created many steps ago, and put this in for the acl and reg paths
;
; AclFile=c:\pathtoacl\someaclfile.txt
; PropertiesFile=c:\pathtoacl\someregfile.reg
;
;
;
; Now, your setup is all done. Shut down VNC and uninstall it.
;
; Start the automated install by typing in this
; UltraVNC-101-Setup.exe /verysilent /loadinf=c:\pathtoinffile\ultravnc.inf"


; Supervisors need their fully installed version. Good thing there is only a couple of them... ;)
$PC=@WKSTA
SELECT
CASE $PC = "IBSPC60" ;Jill
 Exit
CASE $PC = "IBSPC25" ;David
 Exit
CASE $PC = "IBSPC22" ;David
 Exit
CASE $PC = "IBSPC35" ;Chris
 Exit
CASE $PC = "IBSPC59" ;Rick
 Exit
CASE $PC = "IBSPC31" ;Rebecca
 Exit
CASE $PC = "IBSPC55" ;Marianne
 Exit
CASE $PC = "IBSVPC" ;Me
 Exit
ENDSELECT


; Check for TW VNC 4 and remove the service
$VNC4 = KeyExist("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\RealVNC_is1")
If $VNC4
$UNV4 = KeyExist("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WinVNC4")
If @ERROR = 0
DelTree("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WinVNC4")
EndIf
EndIf

; Check for 3.3.6 and uninstall it
$VNC3 = KeyExist("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\WinVNC_is1")
If $VNC3
; uninstall it if there is a string
$UNV3 = ReadValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\WinVNC_is1", "UninstallString")
If @ERROR = 0
shell $UNV3 + " /silent"
EndIf
EndIf

; Check for UltraVNC, and if found, check for installation type
$UVNC = KeyExist("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{A8AD990E-355A-4413-8647-A9B168978423}_is1")
If $UVNC
; Check to see if we are a default install
$INS = ReadValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{A8AD990E-355A-4413-8647-A9B168978423}_is1", "Inno Setup: Setup Type")
   If $INS = "full" ;usually a default install
    $UNST = ReadValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{A8AD990E-355A-4413-8647-A9B168978423}_is1", "UninstallString")
     ;first uninstall it
     shell $UNST + " /verysilent"
     ;then reinstall it
     shell "%COMSPEC% /c @LDRIVE\VNC\UltraVNC-102-Setup /verysilent /loadinf=@LDRIVE\VNC\VNCCONFIG.INI"
     ;shell '%COMSPEC% /C NET START "VNC Server"'
   EndIf
EndIf

; if it's not installed, install it and start the service
If Not $UVNC
run "@LDRIVE\VNC\UltraVNC-102-Setup /verysilent /loadinf=@LDRIVE\VNC\VNCCONFIG.INI"
;shell '%COMSPEC% /c NET START "VNC Server"'
EndIf

; finally remove all shortcuts
If Exist ("C:\Documents and Settings\All Users\Start Menu\Programs\UltraVNC")
  Del "C:\Documents and Settings\All Users\Start Menu\Programs\UltraVNC\*.*" /s
  Rd "C:\Documents and Settings\All Users\Start Menu\Programs\UltraVNC\Doc"
  Rd "C:\Documents and Settings\All Users\Start Menu\Programs\UltraVNC\UltraVNC Driver"
  Rd "C:\Documents and Settings\All Users\Start Menu\Programs\UltraVNC\UltraVNC Server"
  Rd "C:\Documents and Settings\All Users\Start Menu\Programs\UltraVNC"
EndIf

;DONE!!!!!

MAP_DRIVES.KIX

  • Location: \\IBSFP\NETLOGON\KIX.
  • Explanation: Maps network drives, deployed through LOGON.BAT.
IF setconsole("hide")
ENDIF

; John Croson - 05/2007

; Purpose: Map drives based on group membership.

Global $fServer

$fServer = IBSFP


; REMOVE ALL DRIVE MAPPINGS
USE * /DELETE

; MAP ALL COMMON DRIVES
USE F: "\\$fServer\common"
USE G: "\\$fServer\medrec"
USE H: "\\$fServer\download"

; I WAS IN HERE AS IMPOWER


IF INGROUP ("Supervisors") =1
 USE J: "\\$fServer\HR$$"
 USE K: "\\$fServer\monitoring"
ENDIF

USE M: "\\$fServer\scandocs"
USE S: "\\$fServer\office"
USE T: "\\$fServer\software"
USE O: "\\$fServer\data"
USE Z: "\\$fServer\users\@USERID"

IF INGROUP ("OutsideVendors") =1
USE * /DELETE
USE z: \\ibsfp\Vendors
ENDIF


$fServer = 0

POSTSCRIPT_SEARCH_FIX.KIX

  • Location: \\IBSFP\NETLOGON\KIX.
  • Explanation: Applies registry modifications to allow XP workstations the ability to search the contents of Post Script files. Deployed through Software Installation GPO.
IF setconsole("hide")
ENDIF


; John Croson - 07/2007

; Purpose: Allows the searching the contents of PostScript
;          documents using the MS provided Plain Text filter.
;          See http://support.microsoft.com/kb/309173
;          This can be done with many different file types.

WriteValue("HKEY_CLASSES_ROOT\.ps\PersistentHandler", "", "{5e941d80-bf96-11cd-b579-08002b30bfeb}", "REG_SZ")

TIF_REGFIX.KIX

  • Location: \\IBSFP\NETLOGON\KIX.
  • Explanation: Resets registry key that determines default program TIF images open in. Aquarius web requires Imaging Professional, not Preview, as MS has a habit of resetting this during patching. Deployed through Software Installation GPO.
IF setconsole("hide")
ENDIF

; John Croson - 06/2007

; Purpose: Reset registry key that determines default
;          application that opens TIF files. If this
;          fails to get reset, the next patch that MS
;          releases for Imaging Preview resets this to
;          it, instead of the Imaging program used for
;          Aquarius Web.

WriteValue("HKEY_CLASSES_ROOT\.tif", "", "Imaging.Document", "REG_SZ")
WriteValue("HKEY_CLASSES_ROOT\.tiff", "", "Imaging.Document", "REG_SZ")

WELCOME.KIX

  • Location: \\IBSFP\NETLOGON\KIX.
  • Explanation: This sets the warning message before users log into their workstations. Deployed through LOGON.BAT.
  IF setconsole("hide")
ENDIF
;
;     NT/W2K modify welcome text - Kixtart 3.63, 4.00
;
; (c) scripting@wanadoo.nl - 2001
;
;     vs 1.02 - program
;
;     1.00  (20010505)     original version
;     1.01  (20010701)     - extract $ivalue to site defineable block. user can
;                            specify
;                            - $wLegalNoticeCaption
;                            - $wLegalNoticeText
;                            - $wLogonPrompt
;                            - $wWelcome
;                          - introduction of SKIP set_mode. it will only show
;                            the actual settings
;                          - new user information included by using $os variable
;     1.02  (20011120)     - add "windows XP"
;                          - layout corrections
;
$prgrm_version="1.02"
;
$cr=CHR(10)
$lf=CHR(13)
$eol=$lf+$cr



; ---------------------------------------------------------------------------
; - site defined settings                                                   -
; ---------------------------------------------------------------------------


$set_mode="yes"  ; - yes  = set    welcome text
                 ; - no   = remove welcome text
                 ; - skip = show   actual welcome text
$debug_mode="yes" ; - yes  = user information to screen

$wLegalNoticeCaption="Integrated Billing Systems"
;

$wLegalNoticeText=                  "This computer is the property of the Integrated Billing Systems and subject to the appropriate use policies located in the following folder:"+$eol
$wLegalNoticeText=$wLegalNoticeText+$eol
$wLegalNoticeText=$wLegalNoticeText+" F:\IBS  Policy & Procedures Manual\IBS Procedures\IT Procedures."+$eol
$wLegalNoticeText=$wLegalNoticeText+$eol
$wLegalNoticeText=$wLegalNoticeText+"Unauthorized use is a violation of compliance policies. This computer system, including all related
equipment, networks, and network devices, is provided only for authorized use. Any or all uses of this system and all files on this system may be
intercepted, monitored, recorded, copied, audited, inspected, and disclosed to  authorized personnel. By using this system, the user consents to such interception,
monitoring, recording, copying, auditing, inspection, and disclosure at the discretion of authorized
personnel. Unauthorized or improper use of this system may result in administrative disciplinary action and civil and criminal penalties.
By continuing to use this system, you indicate
your awareness of and consent to these terms and conditions of use. "+$eol
$wLegalNoticeText=$wLegalNoticeText+$eol
$wLegalNoticeText=$wLegalNoticeText+" Log off immediately if you do not agree to the conditions stated in this warning."+$eol
$wLegalNoticeText=$wLegalNoticeText+$eol
$wLegalNoticeText=$wLegalNoticeText+" Last successful logon at "+LCASE(@day)+" "+@mdayno+"-"+LCASE(substr(@month,1,3))+"-"+@year+" "+@time
;
$wLogonPrompt="Enter a username and password that is valid for this system."
;
$wWelcome=" to the Integrated Billing Systems network" ; - text beside 'Begin Logon', 'Logon Information', 'Workstation Locked' + 'Unlock Workstation' -

; ---------------------------------------------------------------------------
; -                                                                         -
; ---------------------------------------------------------------------------

IF (@inwin = 1)
 $NT_mode="yes"
ELSE
 $NT_mode="no"
ENDIF
;
$os=""
$os_dos=@dos
SELECT
 CASE ($NT_mode = "yes") AND ($os_dos = "5.1")   ; - Windows XP -
   $os="XP"
 CASE ($NT_mode = "yes") AND ($os_dos = "5.0")   ; - Windows 2000 -
   $os="W2K"
 CASE ($NT_mode = "yes")                         ; - Windows NT -
   $os="NT4"
 CASE ($NT_mode <> "yes") AND ($os_dos = "4.90") ; - Windows ME -
   $os="ME"
 CASE ($NT_mode <> "yes") AND ($os_dos = "4.10") ; - Windows 98 -
   $os="W98"
 CASE ($NT_mode <> "yes") AND ($os_dos = "4.0")  ; - Windows 95 -
   $os="W95"
 CASE 1
   $os="???" ; - undetermined -
ENDSELECT
;
IF ($NT_mode = "yes")
 $ikey="HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon"
 IF (ExistKey($ikey) = 0)
   $ikey_ex="LegalNoticeCaption"
   $ivalue=$wLegalNoticeCaption
   GOSUB update_welcome_text
   ;
   $ikey_ex="LegalNoticeText"
   $ivalue=$wLegalNoticeText
   GOSUB update_welcome_text
   ;
   $ikey_ex="LogonPrompt"
   $ivalue=$wLogonPrompt
   GOSUB update_welcome_text
   ;
   $ikey_ex="Welcome"
   $ivalue=$wWelcome
   GOSUB update_welcome_text
 ENDIF
ELSE
 IF ($debug_mode = "yes")
   ? "Update Welcome Messages - "+@kix
   ?
   ? "$$wLegalNoticeCaption"
   ? " "+$wLegalNoticeCaption
   ? "$$wLegalNoticeText"
   ?     $wLegalNoticeText
   ? "$$wLogonPrompt"
   ? " "+$wLogonPrompt
   ? "$$wWelcome"
   ? " "+$wWelcome
   ?
 ENDIF
ENDIF
GOTO end_script

:update_welcome_text
SELECT
CASE ($set_mode = "yes")
 IF ($debug_mode = "yes")
   IF (len(ReadValue($ikey, $ikey_ex)) <> 0)
     ? "<<<<<<> $ivalue)
   IF (WriteValue($ikey, $ikey_ex, $ivalue, "REG_SZ") <> 0)
     ? "Warning WELCOME-"+$ikey_ex+" "+@error+": "+@serror
   ENDIF
 ENDIF
 IF ($debug_mode = "yes")
   IF (len(ReadValue($ikey, $ikey_ex)) <> 0)
     ? ">>>>>>  WELCOME (new): "+$ikey_ex+"="
     ? ReadValue($ikey, $ikey_ex)
   ELSE
     ? ">>>>>>  WELCOME (new): "+$ikey_ex+"="+ReadValue($ikey, $ikey_ex)
   ENDIF
 ENDIF
 IF ($debug_mode = "yes")
   ?
 ENDIF
CASE ($set_mode = "no")
 IF (ExistKey($ikey) = 0)
   IF (WriteValue($ikey, $ikey_ex, "", "REG_SZ") <> 0)
     ? "Warning WELCOME-"+$ikey_ex+" "+@error+": "+@serror
   ENDIF
 ENDIF
 IF ($debug_mode = "yes")
   ? "Remove  WELCOME: "+$ikey_ex+"="+ReadValue($ikey, $ikey_ex)
 ENDIF
CASE ($set_mode = "skip")
 IF ($debug_mode = "yes")
   ? Substr($ikey_ex+"                    ",1,20)+" "+ReadValue($ikey, $ikey_ex)
 ENDIF
ENDSELECT
RETURN
:end_script
IF ($debug_mode = "yes")
 SELECT
 CASE ($set_mode = "yes")
   ? "Informative Welcome.KIX "+$os+": set_mode="+LCASE($set_mode)+" => update welcome info"
 CASE ($set_mode = "no")
   ? "Informative Welcome.KIX "+$os+": set_mode="+LCASE($set_mode)+" => remove welcome info"
 CASE ($set_mode = "skip")
   ? "Informative Welcome.KIX "+$os+": set_mode="+LCASE($set_mode)+" => show welcome info"
 CASE 1
   ? "Informative Welcome.KIX "+$os+": set_mode="+LCASE($set_mode)+" => possible settings are 'yes/no/skip'"
 ENDSELECT
 IF ($NT_mode <> "yes")
   ? "                             no welcome info possible on "+$os+" version."
ENDIF
BREAK OFF
flushkb

WSFTP_INI.KIX

  • Location: \\IBSFP\NETLOGON\KIX.
  • Explanation: Deploys WSFTP program settings. Deployed through LOGON.BAT.
IF setconsole("hide")
ENDIF

; John Croson - 06/2006
; Purpose: Keep WSFTP configuration files
;          centralized and manageable.
;          Copies config files based on
;          group membership.


; Location of client ini config files
$wsftpdir = "C:\Program Files\WS_FTP Pro"

; Location of server ini config files
$sdir ="\\IBSFP\NETLOGON\WSFTP"


; Domain admins shouldn't be modified
IF INGROUP("Domain Admins")
EXIT
ENDIF


;Remove unecessary WSFTP config files
IF EXIST ("$wsftpdir\antiviru.ini") DEL "$wsftpdir\antiviru.ini" ENDIF
IF EXIST ("$wsftpdir\archives.ini") DEL "$wsftpdir\archives.ini" ENDIF
IF EXIST ("$wsftpdir\games.ini") DEL "$wsftpdir\games.ini" ENDIF
IF EXIST ("$wsftpdir\hardware.ini") DEL "$wsftpdir\hardware.ini" ENDIF
IF EXIST ("$wsftpdir\onlinese.ini") DEL "$wsftpdir\onlinese.ini" ENDIF
IF EXIST ("$wsftpdir\software.ini") DEL "$wsftpdir\software.ini" ENDIF
IF EXIST ("$wsftpdir\usgovern.ini") DEL "$wsftpdir\usgovern.ini" ENDIF

; This keeps a current copy of the WSFTP files on the users machine.

IF EXIST ("$wsftpdir\WS_FTP.ini")

 SELECT
       CASE INGROUP("FTPMngmnt")
       ? "Management group..."
     MOVE "$wsftpdir\WS_FTP.ini" "$wsftpdir\WS_FTP.bak"
        COPY "$sdir\WS_FTP.ini" "$wsftpdir"
     COPY "$sdir\Management.ini" "$wsftpdir"
     COPY "$sdir\AccountsReceivable.ini" "$wsftpdir"
     COPY "$sdir\Collections.ini" "$wsftpdir"

    CASE INGROUP("FTPRecovery")
         ? "Recovery Group..."
     MOVE "$wsftpdir\WS_FTP.ini" "$wsftpdir\WS_FTP.bak"
        COPY "$sdir\WS_FTP.ini" "$wsftpdir"
        IF EXIST ("$wsftpdir\AccountsReceivable.ini") DEL "$wsftpdir\AccountsReceivable.ini" ENDIF
        IF EXIST ("$wsftpdir\Management.ini") DEL "$wsftpdir\Management.ini" ENDIF
     COPY "$sdir\Collections.ini" "$wsftpdir"

    CASE INGROUP("FTPAcctsRec")
      ? "Accounts recievable"
     MOVE "$wsftpdir\WS_FTP.ini" "$wsftpdir\WS_FTP.bak"
        COPY "$sdir\WS_FTP.ini" "$wsftpdir"
     IF EXIST ("$wsftpdir\Collections.ini") DEL "$wsftpdir\Collections.ini" ENDIF
        IF EXIST ("$wsftpdir\Management.ini") DEL "$wsftpdir\Management.ini" ENDIF
     COPY "$sdir\AccountsReceivable.ini" "$wsftpdir"

  CASE INGROUP("FTPSpecial")
   ? "Special Group"
   MOVE "$wsftpdir\WS_FTP.ini" "$wsftpdir\WS_FTP.bak"
     COPY "$sdir\FTP_Special\WS_FTP.ini" "$wsftpdir"
     COPY "$sdir\FTP_Special\Special.ini" "$wsftpdir"
     IF EXIST ("$wsftpdir\Collections.ini") DEL "$wsftpdir\Collections.ini" ENDIF
        IF EXIST ("$wsftpdir\Management.ini") DEL "$wsftpdir\Management.ini" ENDIF
        IF EXIST ("$wsftpdir\AccountsReceivable.ini") DEL "$wsftpdir\AccountsReceivable.ini" ENDIF


    CASE 1
      ? "No group"
       IF EXIST ("$wsftpdir\Collections.ini") DEL "$wsftpdir\Collections.ini" ENDIF
        IF EXIST ("$wsftpdir\Management.ini") DEL "$wsftpdir\Management.ini" ENDIF
        IF EXIST ("$wsftpdir\AccountsReceivable.ini") DEL "$wsftpdir\AccountsReceivable.ini" ENDIF
        MOVE "wsftpdir\WS_FTP.bak" "wsftpdir\WS_FTP.ini"

  ENDSELECT

ENDIF

OCR.BAT

  • Location: D:\PROGRAM FILES\AQUARIUSOCRSERVICE
  • Explanation: Used to stop and start the Aquarius OCR service. Necessary because the service runs so fast that documents get locked during normal scanning hours, which adversly affects that process.
  • Schedule: Stops service at 6:30 A.M. and starts again at 6:00 P.M.
@ECHO OFF

@SET STATUS=%1

IF %STATUS% == START GOTO STARTOCR

IF %STATUS% == STOP GOTO STOPOCR

:STARTOCR
REM IF EXIST AQOCR_5.LOG DEL AQOCR_5.LOG
REM IF EXIST AQOCR_4.LOG REN AQOCR_4.LOG AQOCR_5.LOG
REM IF EXIST AQOCR_3.LOG REN AQOCR_3.LOG AQOCR_4.LOG
REM IF EXIST AQOCR_2.LOG REN AQOCR_2.LOG AQOCR_3.LOG
REM IF EXIST AQOCR_1.LOG REN AQOCR_1.LOG AQOCR_2.LOG
REM REN AQOCR.LOG AQOCR_1.LOG
REM CD.> AQOCR.LOG
NET START "Aquarius OCR Service"
GOTO END


:STOPOCR
net stop "Aquarius OCR Service"
goto END

:END
EXIT

DAILY.BAT

  • Location: \\IBSFP\NETLOGON\DEFRAG
  • Explanation: Used to defragment the users hard drive daily, as a quick optimization job. Added to AT scheduler, and deployed through LOGON.BAT.
  • Schedule: Monday - Friday @ 10:00pm.
@ECHO OFF

:: Copy JKDefrag.exe to local hard drive
IF NOT EXIST C:\JKDefragCMD.exe COPY \\IBSFP\NETLOGON\defrag\JKDefragCMD.exe C:\

:: First stop the Virus Scanning Service
NET STOP "Symantec AntiVirus"

:: clean out some files
START /WAIT /MIN \\IBSFP\Netlogon\Logoff.bat
START /WAIT /MIN %WINDIR%\system32\cscript.exe \\IBSFP\Netlogon\defrag\HotfixCleanup.vbs //B
START /WAIT /MIN C:\jkdefragcmd.exe

:: Restart the scanning service
NET START "Symantec AntiVirus"

:: ----------------------------------------------
::   Get outta here
GOTO EOF


:EOF
EXIT

WEEKLY.BAT

  • Location: \\IBSFP\NETLOGON\DEFRAG
  • Explanation: Used to defragment the users hard drive weekly, as a full optimization job. Added to AT scheduler, and deployed through LOGON.BAT.
  • Schedule: Sunday @ 10:00pm.
@ECHO OFF

:: Copy JKDefrag.exe to local hard drive
IF NOT EXIST C:\JKDefragCMD.exe COPY \\IBSFP\NETLOGON\defrag\JKDefragCMD.exe C:\

:: First stop the Virus Scanning Service
NET STOP "Symantec AntiVirus"

:: clean out some files
START /WAIT /MIN \\IBSFP\Netlogon\Logoff.bat
START /WAIT /MIN %WINDIR%\system32\cscript.exe \\IBSFP\Netlogon\defrag\HotfixCleanup.vbs //B
START /WAIT /MIN C:\JkDefragcmd.exe -a 4

:: Restart the scanning service
NET START "Symantec AntiVirus"

:: ----------------------------------------------
::   Get outta here
GOTO EOF


:EOF
EXIT

REBOOT.VBS

  • Location: \\IBSFP\NETLOGON\DEFRAG
  • Explanation: Used to politely ask the user permission to reboot. Added to AT scheduler, and deployed through LOGON.BAT.
  • Schedule: Daily @ 7:30pm.
Option Explicit

Dim BtnCode, rtn, oShell, OpSysSet, strUserName, oNetwork
Set oShell = WScript.CreateObject ("WScript.shell")
Set oNetwork = WScript.CreateObject("WScript.Network")

strUserName = oNetwork.UserName

If strUserName <> "" Then

'Ask the user nicely...
BtnCode = oShell.PopUp("May I reboot now?", 1800, "REBOOT NOW?", 4 + 32)

 Select Case BtnCode
 ' Show an Yes (1) or No (2) button
 Case 6 rtn = oShell.PopUp("Thanks, be right back...", 5, "REBOOT APPROVED", 0)
   oShell.run "cmd /c shutdown.exe -r -t 0", 0

 Case 7 rtn = oShell.PopUp("Ok, we'll wait until the next time.", 5, "REBOOT DECLINED", 0)

 Case -1 rtn = oShell.PopUp("Rebooting Windows Now...", 5, "REBOOTING", 0)
   oShell.run "cmd /c shutdown.exe -r -t 0", 0

 End Select

Else
oShell.run "cmd /c shutdown.exe -r -t 0", 0
End If


Set oShell = Nothing

HOTFIXCLEANUP.VBS

  • Location: \\IBSFP\NETLOGON\DEFRAG
  • Explanation: Used to clean up hotfix directories and associated files, removing them along the Add Remove entry.
  • Called from LOGOFF.BAT, DAILY.BAT, and WEEKLY.BAT.
 ' HotfixCleanup.vbs
' Removes hotfix info from Add/Remove Programs, deletes uninstall folders, and
' deletes log files in systemroot dir. Hotfix install info is still available
' in system registry key "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\HotFix".
'
' Use computername as argument to clean remotely, or without any argument to
' clean the computer where it's being executed.
'
' 12/13/2003 John Eccles

option explicit

const HKEY_LOCAL_MACHINE = &H80000002

Dim OSRootDir, StrComputer, StdOut, oReg, OSRegKey, objWMIService, colSubfolders, objFolder
Dim strQueryString1, strQueryString2, ErrResult,strKeyPath, arrSubKeys, strValueName, subkey
Dim StrValue, CheckKey, strDirSearch, colFiles, regEx, objFile, retVal, ArgCheck, strReport

If Wscript.Arguments.Count = 0 Then
strComputer = "."
Else
strComputer = Wscript.Arguments.Item(0)
End If

strReport = ""

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")

Set regEx = New RegExp
regEx.Pattern = "hotfix|[KQ]B*\d\d\d\d\d\d"
regEx.IgnoreCase = True


OSRegKey = "SOFTWARE\Microsoft\Windows NT\CurrentVersion"
oReg.GetStringValue HKEY_LOCAL_MACHINE,OSRegKey,"SystemRoot",OSRootDir

'Delete Add/Remove Hotfix entries
strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
strValueName = "DisplayName"

For Each subkey In arrSubKeys
StrValue = ""
 CheckKey = strKeyPath & "\" & subkey
oReg.GetStringValue HKEY_LOCAL_MACHINE,CheckKey,strValueName,strValue

If Not IsNull(strValue) Then
retVal = regEx.Test(strValue)
If retVal Then
strReport = strReport & "Removed " & strValue & " entry from Add/Remove Programs" & vbCrLf
oReg.DeleteKey HKEY_LOCAL_MACHINE, CheckKey
End If
End If
Next

'Remove $ntuninstall dirs from SystemRoot
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
strQueryString1 = "Associators of {Win32_Directory.Name='" & OSRootDir & "'} " & "Where AssocClass = Win32_Subdirectory " & "ResultRole = PartComponent"
Set colSubfolders = objWMIService.ExecQuery (strQueryString1)
For Each objFolder in colSubfolders
If Instr( UCase(objFolder.Name), "$NTUNINSTALL" ) > 0 then
strReport = strReport & "Deleted " & objFolder.Name & " uninstall folder" & vbCrLf
ErrResult = objFolder.Delete
End If

Next

'Delete Hotfix log files
strDirSearch = "'\\" & Right( OSRootDir, (Len(OSRootDir) - 3)) & "\\'"
strQueryString2 = "Select * from CIM_DataFile where Path = " & strDirSearch
Set colFiles = objWMIService. ExecQuery(strQueryString2)

regEx.Pattern = regEx.Pattern & "\.log"

For Each objFile in colFiles
retVal = regEx.Test(objFile.Name)
If retVal Then
strReport = strReport & "Deleted " & objFile.Name & " Hotfix log file" & VbCrLf
ErrResult = objFile.Delete
End If
Next

If strReport = "" Then
'Wscript.Echo "No Hotfix uninstall information was found on this computer."
Else
'Wscript.Echo strReport
End If

EMPTYTRASH.CMD

  • Location: Terminal Server GPO
  • Explanation: Used to purge Recycle bin upon each users logout.
@ECHO OFF
RD /S /Q C:\Recycler

Comments

Popular posts from this blog

NPI Search Redundancy

freeFTPD

Using ImageMagick and Tesseract to sort TIFFs on Windows