Hello Again,

I have managed to get the script working with thanks to the script that Kent sent me but I am having problems now with a loop in it. It appears to go through the script ok but it loops and gives the following output

-------------------


**** Processing System User Enviroment Setup ****
Deleted h:\Office97
Created H:\Office97
Created H:\Office97\Templates
Created H:\Office97\ExlStart
Created H:\Office97\WrdStart
Created H:\Windows
Created H:\Windows\Forms
Updated Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders,Personal,H:\My Documents
Updated HKEY_CURRENT_USER\Software\Microsoft\Office\8.0\Common\Filenew,SharedTemplates,V:\
Updated HKEY_CURRENT_USER\Software\Microsoft\Office\8.0\Common\Filenew\LocalTemplates,,H:\Office97\Templates
Updated HKEY_CURRENT_USER\Software\Microsoft\Office\8.0\Word\Stationery,Default Template,H:\Office97\Templates\Email.dot
Updated HKEY_CURRENT_USER\Software\Microsoft\Office\8.0\Excel\Microsoft Excel,SavedQueriesFolder,H:\My Documents
Updated HKEY_CURRENT_USER\Software\Microsoft\Office\8.0\Excel\Microsoft Excel,DefaultPath,H:\My Documents
Updated HKEY_CURRENT_USER\Software\Microsoft\Office\8.0\Excel\Microsoft Excel,CmdBarFile,H:\Office97\
Updated HKEY_CURRENT_USER\Software\Microsoft\Office\8.0\Excel\Microsoft Excel,AltStartup,H:\Office97\ExlStart
Updated HKEY_CURRENT_USER\Software\Microsoft\Office\8.0\PowerPoint\Recent Folder List\Default,,H:\My Documents
Updated HKEY_CURRENT_USER\Software\Microsoft\Office\8.0\Word\Options,AUTOSAVE-PATH,H:\My Documents
Updated HKEY_CURRENT_USER\Software\Microsoft\Office\8.0\Word\Options,STARTUP-PATH,H:\Office97\WrdStart
Updated HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer,NoFolderOptions,0
Updated HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer,NoDisconnect,1
Updated HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer,NoControlPanel,1
Updated HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer,DisablePersonalDirChange,1
Updated HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Winlogon,ExcludeProfileDirs,Temporary Internet Files;Temp;Personal
Deleted H:\Windows\


--------------------

The section Script is as follows ----


: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 '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") <> 1 ; -- 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") <> 1 ; -- 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

:RMDir

Shell '%comspec% /c RD /s /q "$Dir" '
If @ERROR
$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
$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
Writevalue($Key,$Entry,$Value,"$RegType")
If @ERROR
$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

$ = WriteLine (10, "**** Completed Processing System User Enviroment Setup **** " + Chr(13) + Chr(10))
$ = CLOSE (10)
RETURN
ENDIF ; -- End of the file check being open
ENDIF ; -- End of the log check existing

********************************************

Any one got any suggestions ????