Page 1 of 1 1
Topic Options
#59512 - 2001-10-02 09:36 PM Delete and recreate Folders on User Home Dirs
Anonymous
Unregistered


Hi,

I currently trying to farth out how to the best way to delete a set of folders and re create them with a new contents, then log the if the folders have been deleted and skip the deletion/ recreation process on the next login.

The Reason why I need to do this is because we currently have a really really bad metaframe system that, some of our users in there home drives (H:\) have an office97 dir and windows dir in them. Others have all the favourites, cookies etc ( All the contents of the Windows dir on Metaframe) in the root of the drive. So because I trying to fix our metaframe system and basically rebuild them I need to delete the contents of the directories and recreate them.

I am not concerned about the contents of these dirs ( IE if a user has saved file in them) as we have a strict data usage policy and I can always restore them from Tape or CD.

I am also looking at running the user config for all the office locations from the script. Anyone one got any suggestions ????

Thanks in Advance

Bruce


bruce.taylor@wbp.org.uk

Top
#59513 - 2001-10-03 03:52 AM Re: Delete and recreate Folders on User Home Dirs
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
Hello Bruce,

Why can't you just do a DIR /B >users.txt on the folders from a DOS prompt. Then delete all the folders from Winfile or Explorer and then recreate them?

You could also shell out to DOS and use DELTREE to do this probably using a FOR command in a batch file.

I'm not saying you could not some how come up with a script, but why? Batch files and other Utilities would seem to be better suited for this task.

Am I missing something else here as to why you can not do it from Winfile?

Please post more information on the USER directory structure and what Server OS is MetaFrame running on.

Top
#59514 - 2001-10-03 04:47 AM Re: Delete and recreate Folders on User Home Dirs
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
How many user profiles are you talking about? Have you thought about blowing away their entire profile and get then to inherit a new-and-improved default user profile?

Sure you could use a utility like DelTree and blow away whatever folders. If one of these were never to return, you could use it as a flag. If exist DelTree else skip. This is basic batch prog, you don't even need KiX.

Since TS out-of-the-box already has scripts in place, you could do it all from the TS scripts.

ON my TS, I added a call in UsrLogn2.cmd to a batch file I wrote (1stLogin.Cmd) that does the setup of a new user including copying a bunch of folders and files.

WINNT\Application Compatibility Scripts\Logon\1stLogin.Cmd

code:

if exist G:\Windows\sysspc.mas goto SKIP
xcopy C:\Seed\Windows G:\Windows /s /e /y
if not exist G:\Lotus MD G:\Lotus
if not exist G:\Lotus\Notes MD G:\Lotus\Notes
if not exist G:\Lotus\Notes\Data MD G:\Lotus\Notes\Data
if not exist G:\Lotus\Notes\Data\Help MD G:\Lotus\Notes\Data\Help
if not exist G:\Lotus\Notes\Data\Modems MD G:\Lotus\Notes\Data\Modems
if not exist G:\Lotus\Notes\Data\W32 MD G:\Lotus\Notes\Data\W32
xcopy C:\Seed\Lotus G:\Lotus /s /e /y

:SKIP


_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#59515 - 2001-10-03 10:25 AM Re: Delete and recreate Folders on User Home Dirs
Anonymous
Unregistered


I looking at about 200 - 250 users on our network. The problem is not the profiles we are going to re generate them when we go live on our new metaframe system. The problem is really the home dirs.

I am not sure why someone has set the system up like this. I just something I have inherited when I started working for this company.

The Current Dir structure is
H:\

Scripts - Used for Debugging Scripts (Metaframe and NT)

Exchange - PST / PAB Location

My Documents - User Files

Windows - Old Metaframe Rubbish

Office97 - Old Metaframe Office 97 Rubbish

Some users also have the following in the root -

Application Data
Cookies
Favorites
Forms
History
PIF
system
Temporary Internet Files

We are using Windows TS 4 and Metaframe 1.8 FR1.

Top
#59516 - 2001-10-03 04:23 PM Re: Delete and recreate Folders on User Home Dirs
Anonymous
Unregistered


I tried writting this, but I can't seem to get it to work.

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


$sysenlog = "H:\Scripts\sysenviro.log"

IF Exist ("$sysenlog") =0
IF (OPEN (1,$sysenlog, 5) = 0)
$Dummy = WriteLine (10, "**** 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


$Dir = "H:\Windows\Forms"
if Exist("$Dir") = 0
Shell 'XCOPY "%SystemRoot%\Forms" "$Dir" /E /I'
if @ERROR
$Dummy = WriteLine (10, " Error Copying Files to $Dir" + Chr(13) + Chr(10))
Else
$Dummy = WriteLine (10, " Copied Files to $Dir" + Chr(13) + Chr(10))
endif
endif

$Dir = "H:\Windows\ARTGALRY.cag"
if Exist("$Dir") = 0
COPY "%SystemRoot%\ARTGALRY.cag" "$Dir"
if @ERROR
$Dummy = WriteLine (10, " Error Copying Files to $Dir" + Chr(13) + Chr(10))
Else
$Dummy = WriteLine (10, " Copied Files to $Dir" + Chr(13) + Chr(10))
endif
endif

$Dir = "H:\Office97\Custom.dic"
if Exist("$Dir") = 0
COPY "O:\Microsoft Office\Office\Custom.dic" "$Dir"
if @ERROR
$Dummy = WriteLine (10, " Error Copying Files to $Dir" + Chr(13) + Chr(10))
Else
$Dummy = WriteLine (10, " Copied Files to $Dir" + Chr(13) + Chr(10))
endif
endif

; Fix registry keys.

$RegType="REG_SZ"

$Key="Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders"
$Entry="Personal"
$Value="H:\My Documents"
gosub UpdateKey

$Office="Software\Microsoft\Office\8.0"

$Key="$Office\Common\Filenew\SharedTemplates"
$Entry=""
$Value="V:\"
gosub UpdateKey

$Key="$Office\Common\Filenew\LocalTemplates"
$Entry=""
$Value="H:\Office97\Templates"
gosub UpdateKey

$Key="$Office\Word\Stationery"
$Entry="Default Template"
$Value="H:\Office97\Templates\Email.dot"
gosub UpdateKey

$Key="$Office\Excel\Microsoft Excel"
$Entry="SavedQueriesFolder"
$Value="H:\My Documents"
gosub UpdateKey

$Entry="DefaultPath"
gosub UpdateKey

$Entry="CmdBarFile"
$Value="H:\Office97\"
gosub UpdateKey

$Entry="AltStartup"
$Value="H:\Office97\ExlStart"
gosub UpdateKey

$Key="$Office\PowerPoint\Command Bars"
$Entry="CmdBarFile"
$Value="H:\Office97\"
gosub UpdateKey

$Key="$Office\PowerPoint\Recent Folder List\Default"
$Entry=""
$Value="H:\My Documents"
gosub UpdateKey

$Key="$Office\Word\Options"
$Entry="AUTOSAVE-PATH"
$Value="H:\My Documents"
gosub UpdateKey

$Entry="STARTUP-PATH"
$Value="H:\Office97\WrdStart"
gosub UpdateKey

:RMDir
Shell '%COMPSEC% /c rmdir "$Dir" /q /s > NUL'
If @ERROR
$Dummy = WriteLine (10, "Error Removing contents $Dir - @SERROR" + Chr(13) + Chr(10))
Else
$Dummy = WriteLine (10, "Deleted $Dir " + Chr(13) + Chr(10))
Endif
RETURN

:MakeDir
if Exist("$Dir") = 0
Md "$Dir"
If @ERROR
$Dummy = WriteLine (10, "Error Creating $Dir - @SERROR" + Chr(13) + Chr(10))
Else
$Dummy = WriteLine (10, "Created $Dir " + Chr(13) + Chr(10))
Endif
Endif
Return

:UpdateKey
Writevalue($Key,$Entry,$Value,"$RegType")
If @ERROR
$Dummy = WriteLine (10, "Error Updating $Key,$Entry,$Value - @SERROR" + Chr(13) + Chr(10))
Else
$Dummy = WriteLine (10, "Updated $Key,$Entry,$Value " + Chr(13) + Chr(10))
Endif
Endif
Return

$Dummy = WriteLine (10, "**** Completed Processing System User Enviroment Setup **** " + Chr(13) + Chr(10))
$Dummy = CLOSE (1)
ENDIF

Return

Top
#59517 - 2001-10-03 04:43 PM Re: Delete and recreate Folders on User Home Dirs
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
I assume then that you don't have local profiles on the TS and that the HomeDirs are on another server. I also assume you may encounter in-use issues. Sounds like roaming profiles. I hate roamies (please, no mail on roamies).

You have a lot of code there to scrutinize. Perhaps you could enlighten as to what portion doesn't work.

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#59518 - 2001-10-03 04:58 PM Re: Delete and recreate Folders on User Home Dirs
Anonymous
Unregistered


Les,

I am not to sure. The Debugging doesn't start. It creates the file on the H:\scripts. But doesn't log anything. Then fails on deleting the files.

Yep we use roaming profiles as we have at the moment 3 servers in a farm using published applications for desktops. So we need to use the roaming.

As you can guess from my postings the metaframe servers cause us nothing but problems because of the way they have been set up. We are recreating the profiles and reseting the home drives up (Well trying to tidy them up). When we go live on our new build.

I fixed our mail problems by using a profile generator from www.redfox.co.uk.

[ 03 October 2001: Message edited by: Bruce ]

Top
#59519 - 2001-10-03 05:10 PM Re: Delete and recreate Folders on User Home Dirs
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Bruce,
The mail I was referring to was the stream of hate mail from roamie lovers. I understand about the necessary evil of roamies in a 'farm'.

Try breaking up your script into chunks by separating them with soem ? "somemessage" and Get $ lines, if you don't want to single step with debug.

You say "debugging doesn't start". I assume you are referring to the $sysenlog file. Have you tried running with the /d switch?

Try writing smaller "proof of concept" scripts before implementing it in the "big one".

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#59520 - 2001-10-05 04:26 PM Re: Delete and recreate Folders on User Home Dirs
Anonymous
Unregistered


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

Top
#59521 - 2001-10-21 06:05 AM Re: Delete and recreate Folders on User Home Dirs
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear,

We look at your script.
Some suggestions:

  • let RUN and SHELL call start with the prefix %comspec% /c.
  • strange structure of following code
    code:

    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
    EXIT



    (see next suggestion for more comment on this part)
  • your code means that a remove directory will be executed after last
    GOSUB updatekey.
    code:

    GOSUB updatekey

    :rmdir



    We were missing an EXIT statement and your subroutines are located within
    IF/ENDIF structure.
    Also you try to write to file unit 10, but it should be 1 by
    your WriteLine and Close calls.
    Something like
    code:

    IF .....
    IF .....
    GOSUB x1
    .....
    :1
    .....
    RETURN
    ENDIF
    ENDIF


    our suggestion is:
    code:

    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



See code for other ideas (reformatted with our tool kixstrip):

code:

: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



Greetings.

[ 21 October 2001: Message edited by: MCA ]

_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 302 anonymous users online.
Newest Members
Sir_Barrington, batdk82, StuTheCoder, M_Moore, BeeEm
17886 Registered Users

Generated in 0.058 seconds in which 0.024 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org