Dobs78 Posted March 16, 2010 Share Posted March 16, 2010 (edited) Up to this point, the forums, online documentation and the Help File have answered or pointed me in the right direction on pretty much any question/issue I've run into. However, I'm completely dumbfounded by SRE's. Someone had put in a Noobie Guide to SRE's and I'm still just, "Duuuuuh!" And the thing is, is I'm not sure if using SRE's is something I need to do for this script I'm attempting, feebly, to write. So, if someone could offer some guidance or pat me on the head and say go here, that'd be awesome. The company I work for is upgrading our mail server that uses an outlook connector that has a config file found in: C:\Documents and Settings\@UserName\Application Data\Alt-N\Outlook Connector 2.0\Accounts\Outlook\first.last@domain.com\config.xml What has been done in the past is in the username field for this email account, in Outlook, is use just the username (everything before @domain.com). With this current upgrade, it is going to be required for the fully qualified email address be used as the username. Thus far, I've scripted our Corporate staff, whom are on a domain, easy peasy, no issues. However, where I'm mind boggled right now is, we have users in the field, not on our domain, and with different @UserNames, and possibly on a different version, or versions, of the Outlook Connector. Meaning, the file path has a significant chance of being randomized. Example: C:\Documents and Settings\@UserName\Application Data\Alt-N\Outlook Connector x.x\Accounts\Outlook\jim.smith@domain.com The 2 parts of the file path that can be random are the ...\Outlook Connector X.X\... and the jim.smith@domain.com. Thing is, is the "old" Outlook Connector software is pre-my time with the company and we don't even have any legacy software, that me or the IT Director, have found, so for all I know, this folder could say MDaemon Sucks after \Alt-N\, the only thing I do know, well 98% certain, is that there's going to be only one directory in the Alt-N folder. How do I script a path to open an UNK Directory? The second part of my issue is the email address, obviously this will always be first.last@domain.com, but how do I grab the folder name, put it in the path, so I can open this folder and get to the config.xml file? Summary, I'm having to build a file path in order to open a config.xml file, in which has 2 UNK directories. Any help or pointing in the right direction would be greatly appreciated. Thanks in advance. Dobs Edited March 21, 2010 by Dobs78 Link to comment Share on other sites More sharing options...
BrettF Posted March 17, 2010 Share Posted March 17, 2010 Hi Dobs, Any chance you could post a few sample lines of what you expect to encounter with the exact output for each? For people like me it makes it a bit easier to see what you want to extract... Cheers, Brett Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
Dobs78 Posted March 17, 2010 Author Share Posted March 17, 2010 (edited) Well, I'm "hoping" that Alt-N was consistent in that the Path to the config.xml will be the same, regardless of what version of their Outlook Connector was used, but again, this is an unknown as it is pre-my employment with the company. Basically, I would expect the file path to be- C:\Documents and Settings\@UserName\Application Data\Alt-N\Outlook Connector x.x\Accounts\Outlook\first.last@domain.com\config.xml I mean, all I'm really needing to do is create the path to the config.xml. In all of my previous scripts, I've always had a definitive path, so I've never had to deal with this issue. So I'm guessing what I'm looking to do is setting $sFilePath = C:\Documents and Settings\@UserName\Application Data\Atl-N Find what folder(s) are inside Alt-N, if a folder name contains "Outlook Connector", get that folder's full name and append it to $sFilePath, then go to \Accounts\Outlook, rinse repeat for the email folder so I can open the xml file for editing. If I could get help with the Outlook Connector folder, I'm certain I can figure out the email address folder. Probably not what you were looking for from me? =/ Edited March 17, 2010 by Dobs78 Link to comment Share on other sites More sharing options...
Dobs78 Posted March 17, 2010 Author Share Posted March 17, 2010 (edited) I don't know if this'll help you or not BrettF, but this is what I've got so far. I can pull the folder list inside of the Alt-N folder, just not entirely too sure how the heck to do the script to get the full folder name if it finds 'Outlook Connector' as part of a folder name of the sub-folder(s). Once I get that, I can append it to $OC_Config2 then continue the path til I hit the first.lastname@domain.com folder (which I'll need to repeat what was done to get the 'Outlook Connector' folder name) so I can append that folder name to the file path, then I can get into the config.xml file. #include <file.au3> #include <string.au3> #include <array.au3> ;On Domain Users $OC_Config = @UserProfileDir & "\Application Data\Alt-N\Outlook Connector 2.0\Accounts\Outlook\" & @UserName & "@domain.com\config.xml" ;Look for Outlook Connector config.xml file If FileExists($OC_Config) Then ;Found it! Opening for Edit $Config = FileRead($OC_Config) ;Find value in document between the <username> and </username> tags $CurUserName = _StringBetween($config, '<UserName>', '</UserName>') ;Append @domain.com to the username and create new value $New_UN = @UserName & "@domain.com" If $CurUserName[0] = $New_UN Then MsgBox(0, "Username Already Exits", "The username is already:" & $New_UN) Exit Else ;Input new value between the <username> and </username> tags _ReplaceStringInFile($OC_Config, $CurUserName[0], $New_UN) ;Display Success Message MsgBox(0, "Username Change Successful", "Your Outlook Username has been updated successfully.") EndIf ;Not on Domain Users Elseif Not FileExists($OC_Config) Then $OC_Config2 = @UserProfileDir & "\Application Data\Alt-N\" $FolderList = _FileListToArray($OC_Config2) _ArrayDisplay($FolderList, "Alt-N Contents");Beyond this point, I'm lost $GetNextDir = StringRegExp($FolderList, '(?s)Outlook Connector.*?([\.]+)', 3);This even remotely close to right? ;If config.xml cannot be found, display failed message MsgBox(0, "Config.xml Not Found", "Please contact the HelpDesk @ 555.555.5555") Exit EndIf Edited March 17, 2010 by Dobs78 Link to comment Share on other sites More sharing options...
Dobs78 Posted March 18, 2010 Author Share Posted March 18, 2010 bump Link to comment Share on other sites More sharing options...
GEOSoft Posted March 18, 2010 Share Posted March 18, 2010 You should be able to do it with my _FldrListToArray() which is a recursive function that returns the full path. expandcollapse popup;=============================================================================== ; Function Name: _FldrListToArray() ; Description: Recursivly find the folders in a given path (returns full path for each) ; Syntax: _FldrListToArray($szRoot, $nFlag = 1 ) ; Parameter(s): $szRoot - The base folder ; $sIgnore - Folders to exclude - MUST be pipe (|) separated ; $iRecurs - If 1 (default) search is recursive ; $iNoRoot - If 0 (default) $szRoot is included in the returned array ; else $szRoot is ignored. ; Requirements: ; Return Value(s): Success - A 0 based array of the folders with paths ; Failure - None ; Author(s): George (GEOSoft) Gedye ; Notes: ;Example(s): #cs ;; folders in C:\, ignore Windows and Recycler folders, recursive and don't include the root folder $aArray = _FldrListToArray("c:", "windows|recycler", 1, 1) _ArrayDisplay($aArray) #ce ;=============================================================================== Func _FldrListToArray($szRoot, $sIgnore = "", $iRecurs = 1, $iNoRoot = 0 ) If StringRight($szRoot, 1) <> '\' Then $szRoot &= '\' Local $szReturn = '', $szBuffer = '', $szPathlist = '*', $oRoot = $szRoot & '*', $sChk = $szRoot $Hfile = FileFindFirstFile ($szRoot &'*') If $Hfile >= 0 Then $szBuffer = FileFindNextFile ($Hfile) While NOT @Error If @Extended Then If $sIgnore AND StringRegExp($szBuffer, "(?i)" & $sIgnore) Then $szBuffer = FileFindNextFile ($Hfile) ContinueLoop EndIf If StringInStr($szRoot & $szBuffer, $sChk) Then $szPathlist &= $szRoot & $szBuffer & "\*" EndIf $szBuffer = FileFindNextFile ($Hfile) Wend FileClose ($Hfile) EndIf $szReturn = $szPathList If $iRecurs = 1 Then $szPathList = StringTrimLeft($szPathlist, 1) $szRoot = StringLeft($szPathList, StringInStr($szPathlist, '*') -1) While 1 $hFile = FileFindFirstFile ($szRoot & '*') If $hFile >= 0 Then $szBuffer = FileFindNextFile ($Hfile) While NOT @Error ;If StringInStr(FileGetAttrib($szRoot & $szBuffer), 'D') Then If @Extended Then If NOT $sIgnore Then If StringInStr($szRoot & $szBuffer, $sChk) Then $szPathlist &= $szRoot & $szBuffer & "\*" If StringInStr($szRoot & $szBuffer, $sChk) Then $szReturn &= $szRoot & $szBuffer & "\*" Else If NOT StringRegExp($szBuffer, "(?i)" & $sIgnore) Then If StringInStr($szRoot & $szBuffer, $sChk) Then $szPathlist &= $szRoot & $szBuffer & "\*" If StringInStr($szRoot & $szBuffer, $sChk) Then $szReturn &= $szRoot & $szBuffer & "\*" EndIf EndIf Else ;ContinueLoop EndIf $szBuffer = FileFindNextFile ($Hfile) If @Error Then ExitLoop Wend FileClose($hFile) $szPathList = StringReplace($szPathList, $szRoot, '') EndIf If $szPathList == '*' Then ExitLoop $szPathlist = StringTrimLeft ($szPathlist, 1) $szRoot = StringLeft ($szPathlist, StringInStr ($szPathlist, "*") - 1) & "\" $szPathlist = StringTrimLeft ($szPathlist, StringInStr ($szPathlist, "*") - 1) Wend EndIf If StringLeft($szReturn, 1) = '*' Then $szReturn = StringTrimLeft($szReturn, 1) $szReturn = StringReplace($szReturn, '\\', '\') If StringRight($szReturn, 1) = '*' Then $szReturn = StringTrimRight($szReturn,1) If $iNoRoot Then $szReturn = StringReplace($szReturn, $oRoot, "");$oRoot & $szReturn If $szReturn = '*' or $szReturn = '' Then Return 0 $szReturn = StringSplit($szReturn,'*', 2) ; _ArraySort($szReturn) ;; << uncomment and #include <array.au3> to return a sorted array Return $szReturn EndFunc ;<==> _FldrListToArray() George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Dobs78 Posted March 18, 2010 Author Share Posted March 18, 2010 Thank you GeoSoft, it is working properly for me, however, it's not quite getting the "whole" path. I set $szRoot = @UserProfileDir\Application Data\Alt-N\ Everything else is untouched from the script you provided. When I run the script on my machine, it should be finding: @UserProfileDir\Application Data\Alt-N\Outlook Connector 2.0\Accounts\Outlook\@username@domain.com But it's only going to: [1]|@UserProfileDir\Application Data\Alt-N\Outlook Connector 2.0\Accounts\ Is there something else I need to modify? Or should it "just work?" Link to comment Share on other sites More sharing options...
GEOSoft Posted March 18, 2010 Share Posted March 18, 2010 I gave you the wrong (as in old and crappy) version of that function anyway so please test it with this one. Using the default parameters it will ignore hidden folders but it will include system folders. I haven't found the round toit that I need to write the header for the function yet. Func _Fldr_ListToArray($s_Path, $b_Recurse = True, $b_Hidden = False, $b_System = True) If StringRight($s_Path, 1) <> "\" Then $s_Path &= "\" $s_Path = '"' & $s_Path & '"' Local $s_Working = @WorkingDir, $s_Env = "" FileChangeDir(@TempDir) Local $sFile = "dir.txt" If FileExists($sFile) Then FileDelete($sFile) If $b_Recurse Then $s_Env &= " /s" $s_Env &= " /b /o:n" Local $s_Attrib = " /a:d" If NOT $b_Hidden Then $s_Attrib &= "-h" If NOT $b_System Then $s_Attrib &= "-s" $s_Env &= $s_Attrib EnvSet("DIRCMD", $s_Env) $hPID = Run(@ComSpec & ' /c dir ' & $s_Path & " > " & $sFile , "", @SW_HIDE, 0x02) While ProcessExists($hPID) If @error Then ExitLoop WEnd Local $s_Str = FileRead($sFile) FileDelete($sFile) EnvSet("DIRCMD", "") FileChangeDir($s_Working) If $s_Str Then $a_Fldrs = StringRegExp($s_Str, "(?i)(?m:^)(.+)(?:\v+|$)", 3) If Not @error Then For $i = 0 To UBound($a_Fldrs) -1 $a_Fldrs[$i] &= "\" Next Return $a_Fldrs EndIf EndIf Return SetError(1) EndFunc ;;<===>_Fldr_ListToArray George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Dobs78 Posted March 18, 2010 Author Share Posted March 18, 2010 (edited) GeoSoft, I'm so close I can taste it on getting this working, thank you very much. I'm running your script, I'm getting the folder paths, all the way down until there are no more directories. I'm getting the following results, from your script: [0]|C:\Documents and Settings\michael.dobney\Application Data\Alt-N\Outlook Connector 1.2 \ [1]|C:\Documents and Settings\michael.dobney\Application Data\Alt-N\Outlook Connector 1.2\Accounts \ [2]|C:\Documents and Settings\michael.dobney\Application Data\Alt-N\Outlook Connector 1.2\Accounts\Outlook \ [3]|C:\Documents and Settings\michael.dobney\Application Data\Alt-N\Outlook Connector 1.2\Accounts\Outlook\michael.dobney@domain.com \ [4]|C:\Documents and Settings\michael.dobney\Application Data\Alt-N\Outlook Connector 1.2\Accounts\Outlook\michael.dobney@domain.com\Attachments \ Looks like there's a space before the last "\" of each path found. I've done a trimright to get rid of it. Thought I'd let you know. Edited March 18, 2010 by Dobs78 Link to comment Share on other sites More sharing options...
Dobs78 Posted March 18, 2010 Author Share Posted March 18, 2010 (edited) GeoSoft, somebody, I am this || close to having this script completed. Thank you very much for the help Geo. I am however, stuck, and do not know why the below is not working. I've commented the line I'm having issues with. For some reason, on $CurUserName2 = _StringBetween($Config2, '<UserName>', '</UserName>') it's not looking for, or seeing?, the <UserName> tags in the config.xml. The MsgBox comes up with a blank value, when on the FileRead, it's clearly populated. This part of the script is pretty close to identical as the first part of the script (see my 3rd post in this thread), just different variables. Let me know if you need any more information or slap me upside the head if I have an extra char in there. Thanks again for any assistance. GeoSoft, thank you, thank you. Elseif Not FileExists($OC_Config) Then ;If config.xml not found, let's try looking for it ;Do a recursive search in C:\Documents and Settings\Application Data\Alt-N\ and find all sub-directories $FolderList = _Fldr_ListToArray($s_Path, $b_Recurse, $b_Hidden, $b_System) ;Found all sub-directories, hoping that there's only ever been 1 Outlook Connector account created on this machine, grab the 3rd entry by default ;Ooops, got an extra space before the last "\", take of the last 2 chars $OC_ConfigFixPath = StringTrimRight($FolderList[3], 2) ;Create path to config.xml, should be C:\Documents and Settings\Application Data\Alt-N\Outlook Connector x.x\Accounts\Outlook\first.lastname@domain.com\config.xml $OC_Config2 = $OC_ConfigFixPath & "\config.xml" ;Open the config.xml file for editing $Config2 = FileRead($OC_Config2) MsgBox(0, "blah", $Config2);This opens the config.xml file and is being read ;Find value in document between the <username> and </username> tags $CurUserName2 = _StringBetween($Config2, '<UserName>', '</UserName>') MsgBox(0, "blah", $CurUserName2);This is where I'm getting stuck now, it doesn't seem to be pulling the value between the tags. ;If config.xml cannot be found, display failed message MsgBox(0, "Config.xml Not Found", "Please contact the HelpDesk @ 555.555.5555") Exit EndIf Edited March 18, 2010 by Dobs78 Link to comment Share on other sites More sharing options...
GEOSoft Posted March 18, 2010 Share Posted March 18, 2010 GeoSoft, somebody, I am this || close to having this script completed. Thank you very much for the help Geo. I am however, stuck, and do not know why the below is not working. I've commented the line I'm having issues with. For some reason, on $CurUserName2 = _StringBetween($Config2, '<UserName>', '</UserName>') it's not looking for, or seeing?, the <UserName> tags in the config.xml. The MsgBox comes up with a blank value, when on the FileRead, it's clearly populated. This part of the script is pretty close to identical as the first part of the script (see my 3rd post in this thread), just different variables. Let me know if you need any more information or slap me upside the head if I have an extra char in there. Thanks again for any assistance. GeoSoft, thank you, thank you. Elseif Not FileExists($OC_Config) Then ;If config.xml not found, let's try looking for it ;Do a recursive search in C:\Documents and Settings\Application Data\Alt-N\ and find all sub-directories $FolderList = _Fldr_ListToArray($s_Path, $b_Recurse, $b_Hidden, $b_System) ;Found all sub-directories, hoping that there's only ever been 1 Outlook Connector account created on this machine, grab the 3rd entry by default ;Ooops, got an extra space before the last "\", take of the last 2 chars $OC_ConfigFixPath = StringTrimRight($FolderList[3], 2) ;Create path to config.xml, should be C:\Documents and Settings\Application Data\Alt-N\Outlook Connector x.x\Accounts\Outlook\first.lastname@domain.com\config.xml $OC_Config2 = $OC_ConfigFixPath & "\config.xml" ;Open the config.xml file for editing $Config2 = FileRead($OC_Config2) MsgBox(0, "blah", $Config2);This opens the config.xml file and is being read ;Find value in document between the <username> and </username> tags $CurUserName2 = _StringBetween($Config2, '<UserName>', '</UserName>') MsgBox(0, "blah", $CurUserName2);This is where I'm getting stuck now, it doesn't seem to be pulling the value between the tags. ;If config.xml cannot be found, display failed message MsgBox(0, "Config.xml Not Found", "Please contact the HelpDesk @ 555.555.5555") Exit EndIf In the last version I gave you change $a_Fldrs[$i] &= "\" to $a_Fldrs[$i] = StringStripWS($a_Fldrs[$i], 2) & "\" There is a better fix by doing it in the SRE but I don't have the time today. Try changing the line $CurUserName2 = _StringBetween($Config2, '<UserName>', '</UserName>') To $CurUserName2 = StringRegExpReplace($Config2, "(?i)<UserName>(.+?)</UserName>", "$1") That's off the top of my head but I think it's right. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
BrettF Posted March 18, 2010 Share Posted March 18, 2010 _StringBetween returns an array. Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
GEOSoft Posted March 18, 2010 Share Posted March 18, 2010 _StringBetween returns an array.Thanks for the reminder. Personally I never use it but I did know that at one time and forgot about it. SRER should do the same, that is unless there is more than 1 <username> in the file then we have to go another rout that will also return an array so you may as well stick with _StringBetween() in that case. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Dobs78 Posted March 18, 2010 Author Share Posted March 18, 2010 I'll give those a shot when I get into work tomorrow morning and let you know how it went. Thanks again for the help with this. Link to comment Share on other sites More sharing options...
Dobs78 Posted March 19, 2010 Author Share Posted March 19, 2010 (edited) Finally! Got it working. Don't think I could've done it without your function GeoSoft. I appreciate the help with this. Here's what I ended up with. Not sure how to do it or if I can, but this thread can be flagged as Solved. expandcollapse popup#include <file.au3> #include <string.au3> #include <array.au3> Func _Fldr_ListToArray($s_Path, $b_Recurse = True, $b_Hidden = False, $b_System = True) If StringRight($s_Path, 1) <> "\" Then $s_Path &= "\" $s_Path = '"' & $s_Path & '"' Local $s_Working = @WorkingDir, $s_Env = "" FileChangeDir(@TempDir) Local $sFile = "dir.txt" If FileExists($sFile) Then FileDelete($sFile) If $b_Recurse Then $s_Env &= " /s" $s_Env &= " /b /o:n" Local $s_Attrib = " /a:d" If NOT $b_Hidden Then $s_Attrib &= "-h" If NOT $b_System Then $s_Attrib &= "-s" $s_Env &= $s_Attrib EnvSet("DIRCMD", $s_Env) $hPID = Run(@ComSpec & ' /c dir ' & $s_Path & " > " & $sFile , "", @SW_HIDE, 0x02) While ProcessExists($hPID) If @error Then ExitLoop WEnd Local $s_Str = FileRead($sFile) FileDelete($sFile) EnvSet("DIRCMD", "") FileChangeDir($s_Working) If $s_Str Then $a_Fldrs = StringRegExp($s_Str, "(?i)(?m:^)(.+)(?:\v+|$)", 3) If Not @error Then For $i = 0 To UBound($a_Fldrs) -1 $a_Fldrs[$i] = StringStripWS($a_Fldrs[$i], 2) & "\" Next Return $a_Fldrs EndIf EndIf Return SetError(1) EndFunc ;;<===>_Fldr_ListToArray $s_Path = @UserProfileDir & "\Application Data\Alt-N\" $b_Recurse = True $b_Hidden = False $b_System = True $OC_Config = @UserProfileDir & "\Application Data\Alt-N\Outlook Connector 2.0\Accounts\Outlook\" & @UserName & "@domain.com\config.xml" ;Look for Outlook Connector config.xml file If FileExists($OC_Config) Then ;Found it! Opening for Edit $Config = FileRead($OC_Config) ;Find value in config.xml between the <username> and </username> tags $CurUserName = _StringBetween($Config, '<UserName>', '</UserName>') ;Find value in config.xml between the <emailaddress and </emailaddress> tags $EmailAddr = _StringBetween($Config, '<EmailAddress>', '</EmailAddress>') ;Compare value of emailaddr to curusername If $CurUserName[0] = $EmailAddr[0] Then ;If they match, then display Success message MsgBox(0, "Username Already Exits", "The username is already:" & " " & $CurUserName[0]) Exit ;If they don't match Else ;Trim @domain.com of the emailaddr value (only done because the OC somehow appends another @domain.com after changing the username) $FixEmailAddr = StringTrimRight($EmailAddr[0], 11) ;Put the new value of the emailaddr in between the <emailaddress> tags the @domain.com will auto-append internal to the OC once the username is changed _ReplaceStringInFile($OC_Config, $EmailAddr[0], $FixEmailAddr) ;Put the new value of emailaddr between the <username> tags and append @domain.com _ReplaceStringInFile($OC_Config, $CurUserName[0], $FixEmailAddr & "@domain.com") ;Close config.xml FileClose($OC_Config) MsgBox(0, "Username Change Successful", "Your Outlook Username has been updated successfully.") EndIf Elseif Not FileExists($OC_Config) Then ;If config.xml not found, let's try looking for it ;Do a recursive search in C:\Documents and Settings\Application Data\Alt-N\ and find all sub-directories. Thank you GeoSoft for the function do to this! $FolderList = _Fldr_ListToArray($s_Path, $b_Recurse, $b_Hidden, $b_System) ;Found all sub-directories, hoping that there's only ever been 1 Outlook Connector account created on this machine, grab the 3rd entry by default $OC_Config2 = $FolderList[3] & "\config.xml" ;Open the config.xml file for editing $Config2 = FileRead($OC_Config2) ;Find value in config.xml between the <username> and </username> tags $CurUserName2 = _StringBetween($Config2, '<UserName>', '</UserName>') ;Find value in config.xml between the <emailaddress and </emailaddress> tags $EmailAddr2 = _StringBetween($Config2, '<EmailAddress>', '</EmailAddress>') ;Look for @cusinc.com If $CurUserName2[0] = $EmailAddr2[0] Then ;If they match, then display Success message MsgBox(0, "Username Already Exits", "The username is already:" & " " & $CurUserName2[0]) Exit ;If they don't match Else ;Trim @domain.com off the emailaddr2 value (only done because the OC somehow appends another @domain.com after changing the username) $FixEmailAddr2 = StringTrimRight($EmailAddr2[0], 11) ;Put the new value of the emailaddr2 in between the <emailaddress> tags the @domain.com will auto-append somehow internal to the OC once the username is changed _ReplaceStringInFile($OC_Config2, $EmailAddr2[0], $FixEmailAddr2) ;Put the new value of emailaddr2 between the <username> tags and append @domain.com _ReplaceStringInFile($OC_Config2, $CurUserName2[0], $FixEmailAddr2 & "@domain.com") ;Close config.xml FileClose($OC_Config2) MsgBox(0, "Username Change Successful", "Your Outlook Username has been updated successfully.") EndIf Exit EndIf Edited March 19, 2010 by Dobs78 Link to comment Share on other sites More sharing options...
GEOSoft Posted March 19, 2010 Share Posted March 19, 2010 As long as you're happy with it, then all is good. Glad to be of assistance. You can mark it solved by going to the first post, click edit and add the word Solved to the title. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now