:sysenviro
; REM **********************************************************************************
; REM **
; REM ** Sets the System Enviroment - Checks for the Existance of the Office and Windows
; REM ** Dirs in the Home Drive and recreates it if it is the first login or it doesn't
; REM ** exist.
; REM **
; REM **********************************************************************************
$sysenlog = "H:\Scripts\sysenviro.log"
$office="HKEY_CURRENT_USER\Software\Microsoft\Office\8.0"
$curver="HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion"
$appoff="\\nt-pdc01\NETLOGON\login\Application Data\Office97"
$appwin="\\nt-pdc01\NETLOGON\login\Application Data\Windows"
IF Exist ("$sysenlog") =0
IF (Open (1,$sysenlog, 5) = 0)
$dummy = WriteLine (1, "**** Processing System User Enviroment Setup ****"+ Chr(13) + Chr(10))
IF Exist ("H:\Application Data")
$dir = "H:\Application Data"
GOSUB rmdir
ENDIF
IF Exist ("h:\Cookies")
$dir = "h:\Cookies"
GOSUB rmdir
ENDIF
IF Exist ("h:\Favorites")
$dir = "h:\Favorites"
GOSUB rmdir
ENDIF
IF Exist ("h:\Forms")
$dir = "h:\Forms"
GOSUB rmdir
ENDIF
IF Exist ("h:\history")
$dir = "h:\history"
GOSUB rmdir
ENDIF
IF Exist ("h:\pif")
$dir = "h:\pif"
GOSUB rmdir
ENDIF
IF Exist ("h:\system")
$dir = "h:\system"
GOSUB rmdir
ENDIF
IF Exist ("h:\Temporary Internet Files")
$dir = "h:\Temporary Internet Files"
GOSUB rmdir
ENDIF
IF Exist ("h:\Windows")
$dir = "h:\Windows"
GOSUB rmdir
ENDIF
IF Exist ("h:\Office97")
$dir = "h:\Office97"
GOSUB rmdir
ENDIF
$dir = "H:\My Documents"
GOSUB makedir
$dir = "H:\Office97"
GOSUB makedir
$dir = "H:\Office97\Templates"
GOSUB makedir
$dir = "H:\Office97\ExlStart"
GOSUB makedir
$dir = "H:\Office97\WrdStart"
GOSUB makedir
$dir = "H:\Windows"
GOSUB makedir
$dir = "H:\Windows\Forms"
GOSUB makedir
IF Exist ("H:\Windows\Forms") = 1 ; -- If the folder exists do an action
SHELL '%comspec% /c XCOPY "%SystemRoot%\Forms" "$Dir" /E /I'
IF @error <> 0
$ = WriteLine (10, " Error Copying Files to $Dir" + Chr(13) + Chr(10))
ELSE
$ = WriteLine (10, " Copied Files to $Dir" + Chr(13) + Chr(10))
ENDIF
ENDIF
IF Exist("H:\Windows\ARTGALRY.cag") = 0 ; -- If this file does not exist copy it
COPY "%SystemRoot%\ARTGALRY.cag" "$Dir"
IF @error
$ = WriteLine (10, " Error Copying Files to $Dir" + Chr(13) + Chr(10))
ELSE
$ = WriteLine (10, " Copied Files to $Dir" + Chr(13) + Chr(10))
ENDIF
ENDIF
IF Exist ("H:\Office97\Custom.dic") = 0 ; -- If this file does not exist copy it
COPY "$appoff\Custom.dic" "$Dir"
IF @error = 0
$ = WriteLine (10, " Error Copying Files to $Dir" + Chr(13) + Chr(10))
ELSE
$ = WriteLine (10, " Copied Files to $Dir" + Chr(13) + Chr(10))
ENDIF
ENDIF
$dir = "H:\Office97\Templates\"
IF Exist("$Dir") = 0
COPY "$appoff\Templates\*.*" "$Dir"
IF @error
$dummy = WriteLine (1, " Error Copying Files to $Dir"+ Chr(13) + Chr(10))
ELSE
$dummy = WriteLine (1, " Copied Files to $Dir"+ Chr(13) + Chr(10))
ENDIF
ENDIF
$dir = "H:\Windows\"
IF Exist("$Dir") = 0
COPY "$appwin\*.*" "$Dir"
IF @error
$dummy = WriteLine (1, " Error Copying Files to $Dir"+ Chr(13) + Chr(10))
ELSE
$dummy = WriteLine (1, " Copied Files to $Dir"+ Chr(13) + Chr(10))
ENDIF
ENDIF
; Fix registry keys.
$key="Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders"
$entry="Personal"
$value="H:\My Documents"
$regtype="REG_SZ"
GOSUB updatekey
$key="$Office\Common\Filenew"
$entry="SharedTemplates"
$value="V:\"
$regtype="REG_SZ"
GOSUB updatekey
$key="$Office\Common\Filenew\LocalTemplates"
$entry=""
$value="H:\Office97\Templates"
$regtype="REG_SZ"
GOSUB updatekey
$key="$Office\Word\Stationery"
$entry="Default Template"
$value="H:\Office97\Templates\Email.dot"
$regtype="REG_SZ"
GOSUB updatekey
$key="$Office\Excel\Microsoft Excel"
$entry="SavedQueriesFolder"
$value="H:\My Documents"
$regtype="REG_SZ"
GOSUB updatekey
$entry="DefaultPath"
$regtype="REG_SZ"
GOSUB updatekey
$entry="CmdBarFile"
$value="H:\Office97\"
$regtype="REG_SZ"
GOSUB updatekey
$entry="AltStartup"
$value="H:\Office97\ExlStart"
$regtype="REG_SZ"
GOSUB updatekey
$key="$Office\PowerPoint\Recent Folder List\Default"
$entry=""
$value="H:\My Documents"
$regtype="REG_SZ"
GOSUB updatekey
$key="$Office\Word\Options"
$entry="AUTOSAVE-PATH"
$value="H:\My Documents"
$regtype="REG_SZ"
GOSUB updatekey
$entry="STARTUP-PATH"
$value="H:\Office97\WrdStart"
$regtype="REG_SZ"
GOSUB updatekey
;Disable Folder Options Menus
$key="$CurVer\Policies\Explorer"
$entry="NoFolderOptions"
$value="0"
$regtype="REG_DWORD"
GOSUB updatekey
;Disable Disconnect Option on Start Menu
$key="$CurVer\Policies\Explorer"
$entry="NoDisconnect"
$value="1"
$regtype="REG_DWORD"
GOSUB updatekey
;Disable Control Panel
$key="$CurVer\Policies\Explorer"
$entry="NoControlPanel"
$value="1"
$regtype="REG_DWORD"
GOSUB updatekey
;Disable Personal Dir Change
$key="$CurVer\Policies\Explorer"
$entry="DisablePersonalDirChange"
$value="1"
$regtype="REG_DWORD"
GOSUB updatekey
;Disable Temp IE Files, Personal, Temp being uploaded from the Profiles
$key="HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Winlogon"
$entry="ExcludeProfileDirs"
$value="Temporary Internet Files;Temp;Personal"
$regtype="REG_SZ"
GOSUB updatekey
$ = WriteLine (1, "**** Completed Processing System User Enviroment Setup **** " + Chr(13) + Chr(10))
$ = Close (1)
ENDIF ; -- End of the file check being open
ENDIF ; -- End of the log check existing
EXIT
:rmdir
SHELL '%comspec% /c RD /s /q "$Dir"'
IF @error <> 0
$dummy = WriteLine (1, "Error Removing contents $Dir - @SERROR"+ Chr(13) + Chr(10))
ELSE
$dummy = WriteLine (1, "Deleted $Dir "+ Chr(13) + Chr(10))
ENDIF
RETURN
:makedir
IF Exist("$Dir") = 0
MD "$Dir"
IF @error <> 0
$dummy = WriteLine (1, "Error Creating $Dir - @SERROR"+ Chr(13) + Chr(10))
ELSE
$dummy = WriteLine (1, "Created $Dir "+ Chr(13) + Chr(10))
ENDIF
ENDIF
RETURN
:updatekey
$dummy = WriteValue($key,$entry,$value,"$RegType")
IF @error <> 0
$dummy = WriteLine (1, "Error Updating $Key,$Entry,$Value - @SERROR"+ Chr(13) + Chr(10))
ELSE
$dummy = WriteLine (1, "Updated $Key,$Entry,$Value "+ Chr(13) + Chr(10))
ENDIF
RETURN