Is there a smarter way of doing this? What I am trying to do is first check for the existence of the WinDart.ini file in the users S:\Windows folder. If it exists I want to verify that the INI file has all three sections. If the INI file is missing a section, I check for the existence of the backup file (in Citrix the extension is .ctx) and verify that it has all three sections. If it does then I use the backup. If it doesn’t I use a generic template file and copy it to the user’s S:\Windows folder.

If the WinDart.ini file does not exist, I check for the existence of the backup file. Well, you see what I’m doing. Just seems to me that I could be using less code to perform the repetition.

Code:

If Exist ("S:\Windows\WinDart.ini")
$RC = ReadProfileString("S:\Windows\WinDart.ini","","")
If InStr($RC,"ENV") And InStr($RC,"Shell") And InStr($RC,"Components")
? "WinDart.ini file checks out OK"
Else
If Exist ("S:\Windows\WinDart.ctx")
$RC = ReadProfileString("S:\Windows\WinDart.ctx","","")
If InStr($RC,"ENV") And InStr($RC,"Shell") And InStr($RC,"Components")
? "WinDart.ctx file being copied to WinDart.ini"
Shell 'cmd /c Copy "S:\Windows\WinDart.ctx" "S:\Windows\WinDart.ini" >nul 2>&1'
Else
Shell 'cmd /c Copy "F:\Template\WinDart\WinDart.ini" "S:\Windows" >nul 2>&1'
EndIf
EndIf
EndIf
Else
If Exist ("S:\Windows\WinDart.ctx")
$RC = ReadProfileString("S:\Windows\WinDart.ctx","","")
If InStr($RC,"ENV") And InStr($RC,"Shell") And InStr($RC,"Components")
? "WinDart.ctx file being copied to WinDart.ini"
Shell 'cmd /c Copy "S:\Windows\WinDart.ctx" "S:\Windows\WinDart.ini" >nul 2>&1'
Else
Shell 'cmd /c Copy "F:\Template\WinDart\WinDart.ini" "S:\Windows" >nul 2>&1'
EndIf
EndIf
EndIf