
inthewayboy
Active Members-
Posts
34 -
Joined
-
Last visited
Everything posted by inthewayboy
-
Running a batch file in AutoIT
inthewayboy replied to jben's topic in AutoIt General Help and Support
Yeah, the .bat seems redundant at this point...using the Run() or RunWait() commands should yield positive results, and you could hide the GUI you are talking about by using the @SW_HIDE option for the command. It looks like MadBoy had the correct code on the first page to just run it natively in the script. That would be the direction I would take at least. I don't know about the Run32DLL, but I'm sure there is a way to execute that in AutoIt. -
GUI Newb Needs A Little Direction
inthewayboy replied to inthewayboy's topic in AutoIt GUI Help and Support
I was wondering what all that down there did, I'll review and beta some attempt at this and fill ya in. -
Hey guys, been using AutoIt for a few years now and never really got a chance to mess with the GUI stuff. But now I'm developing this simple reporting tools that I would like to open up with a GUI. The script is a basic Active Directory search and report script using dsquery.exe and dsget.exe. I know there is an adfunctions UDF but I'm trying to keep things as simple as possible without using third-party tools/scripts. Here is the script: #Region;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_outfile=beta.exe #EndRegion;**** Directives created by AutoIt3Wrapper_GUI **** #include<Array.au3> #include<File.au3> $root=ObjGet("LDAP://RootDSE") $domain=$root.Get("defaultNamingContext") $dsquery="bin\dsquery.exe" $dsget="bin\dsget.exe" $results="" $get="" $out="" $query=Run($dsquery&' user "OU=users,OU=jax,'&$domain&'" -limit 0 -scope subtree',"","", 2) Do $results&=StdOutRead($query) Until @error $array=StringSplit($results,@CRLF,1) _ArrayDelete($array,_ArrayMax($array)) For $item In $array $cmd=Run($dsget&" user "&$item&" -samid","","", 2) Do $get&=StdOutRead($cmd) Until @error Next $get=StringReplace($get,"samid","") $get=StringReplace($get,"dsget succeeded","") $get=StringStripWS($get,4) $get=StringReplace($get," ",@CRLF) $get=StringSplit($out,@CRLF,1) _ArrayDelete($out,_ArrayMax($out)) _ArrayDelete($out,1) _ArrayMaxIndex($out) $c=UBound($out) $get[0]=$c _ArraySort($out) _FileWriteFromArray("c:\test.txt",$out,1) And here is the basic GUI code I got from messing around with the Koda form designer: #include <GUIConstants.au3> #Region ### START Koda GUI section ### Form=C:\Documents and Settings\Administrator\Desktop\scripts\gui.kxf $Query=GUICreate("Query",201,251,193,115) GUICtrlCreateCombo("",8,32,150,25) GUICtrlSetData(-1,"jax\users|jax\desktops|jax\desktops\ormond|jax\mobile|jax\servers|jax\groups\security|jax\groups\exchange") $File=GUICtrlCreateInput("File",8,168,98,21) $Browse=GUICtrlCreateButton("Browse",108,169,50,20,0) $Recursive=GUICtrlCreateCheckbox("Recursive",8,56,75,17) GUICtrlCreateCombo("",8,8,150,25) GUICtrlSetData(-1,"user|computer|group|ou") $Email=GUICtrlCreateCheckbox("email",88,72,75,25) $Name=GUICtrlCreateCheckbox("name",8,96,75,25) $User=GUICtrlCreateCheckbox("user",8,72,75,25) $Dn=GUICtrlCreateCheckbox("dn",8,120,75,25) $Tel=GUICtrlCreateCheckbox("tel",88,96,75,25) $Fax=GUICtrlCreateCheckbox("fax",88,120,75,25) $Desc=GUICtrlCreateCheckbox("desc",8,144,75,25) $Progress=GUICtrlCreateProgress(8,216,150,25) $Run=GUICtrlCreateButton("Run",107,192,50,20,0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg=GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Browse Case $Run EndSwitch WEnd I really just have no idea how I structure those two, how I make it so when I click a check box it adds that variable to the script, etc. I'm not looking for anyone to do it for just maybe give me some basic pointers to get me going. Also, if anyone would like to help streamline the script that would be good, I'm sure I'm going about somethings the wrong way so help a brother out! *The script won't work unless you have dsquery and dsget in a 'bin' folder parallel to the script. I do this because the workstation I run it from isn't Server 2003 so it doesn't have it by default. If you run this from a server you can edit those variables so it uses the server's copy located in system32. Also don't forget to check the syntax for the dsquery part, since my OU structure is bound to be different than yours.*
-
I'm trying to impliment exmerge in our exchange 2003 backup scheme, just for those few people who require extra data protection. I've currently gotten a basic script that calls exmerge.exe with the correct exmerge.ini and other supporting TXT files. However, this means I have to a unique files for each user. So what I was looking to do is have a single script that would not only perform the actual exmerge execution, but would also create the necessary files before that. Of course the real power of this would come in the form of a UDF, which I'm looking forward to testing over the weekend. But I have no clue as to how to attack the TXT files. My first thought was to establish a 'temp' working directory...the script would create the necessary files in that location, then run the exmerge process, and finish up with deleting the files and the 'temp' working directory. But I can't help but think there is an easier way. The text files are really simple...one tells exmerge which file store to work with, the other tells it which mail boxes to work with...in both cases it's just a single line of text, two if you include the 'header' that exmerge puts in the files when it creates them (Don't think they are required, but you never know). Any tips or suggestions on how to handle this? I'm really not used to interacting with files like this, so any help would be appreciated. and please, don't hesitate to give an example I've attached the files I'm currently using, edited to protect the innocent (And you can't upload .ini files?)...I would hope it's not too hard to follow. And I would be shocked if I was the only exchange admin on here...thanx in advance! databases.txt mailboxes.txt exmerge.au3 exmerge.ini.txt
-
Logon Scripts Via Group Policy
inthewayboy replied to inthewayboy's topic in AutoIt General Help and Support
After digging through the forums a little more I found this: http://www.autoitscript.com/forum/index.ph...0814&hl=gpo Looks like a guy had a script that was working fine until recently...it doesn't say if he updated his autoit but I wonder if the mechanics for the workingdir have changed recently. Seems like his issue is similar to mine, as well as the previous post. Anyone have any info regarding that? I' guess I could check the release notes, I might do that and see what I can find...or it could be totally unrelated, can't rule that out! -
Logon Scripts Via Group Policy
inthewayboy replied to inthewayboy's topic in AutoIt General Help and Support
I did try that and I think that was when I got the error I mention above... \\corp.lan\dfs\tech\scripts\bin\autoit3.exe script1.udf = could not find script at all \\corp.lan\dfs\tech\scripts\bin\autoit3.exe \\corp.lan\dfs\tech\scripts\bin\script1.au3 = found script but error at line 0 I'm not at work at the moment so I can't play, but I've got a whole weekend to figure this out. Maybe this is a better question, what would be the most reliable way to establish a workingdir for this kinda scenario. Would that be something I edit in the UDF's or the actual scripts? Hmmm -
I've got a fair amount of scripts that I've created over time that I want to keep in one central location. I have a windows based network, all servers runninng Win2003 SP2 R2. I use DFS to make sure all the servers have the scripts as well as centralizing the network paths to our shares. To give an example I have the scripts located at \\corp.lan\dfs\tech\scripts\bin, it also has a copy of the autoit executable. The scripts are not compiled, and I would like to keep them that way so editing isn't such a chore. My goal was to be able to use GPO's to run these based on security filtering, with the autoit executable being the script and the script being the parameters, like so: \\corp.lan\dfs\tech\scripts\bin\autoit.exe script.au3 Now if the user is logged on that works as expected, at least from cmd. However when I run it via GPO, as a user logon script, I get an error about reading line 0, saying it can't find the file. I'll get a more verbose copy of the error message shortly. I don't want to copy the script to the NETLOGON or SYSVOL shares, because then I'm gonna have multiple versions. And I would like to stay away from running compiled scripts for various reasons. Is anyone else doing something like this? I did find this forum post: http://www.autoitscript.com/forum/index.php?showtopic=28378 Which seems to have similar issues, but I don't how to impliment the solution of using @temp. I have several files that are setup as UDF's, which are included in other scripts which are what I'm trying to run via GPO. A more visual representation: \\corp.lan\dfs\tech\scripts\bin\ _UDF1.au3 _UDF2.au3 _UDF3.au3 autoit3.exe script1.au3 script2.au3 So the GPO is running autoit3.exe as the script, with script1.au3 as the parameter, which would #include _UDF1.au3. When I #include _UDF1.au3 I'm using the "" around the filename so it looks in the same dir as the script: #include "_UDF1.au3" I'll try and get some more info and scripts to provide some investigation, but seems like this is a pretty simple problem that I'm just not noticing. Again, if a user is logged in it works. I've also tried using mapped drives instead of UNC's and that doesn't fair any better. Thanx in advance!!!
-
WinSCP is great freeware SFTP app that supports commandline: http://winscp.net/eng/docs/commandline I figure that would do you right for uploading files via AutoIt!
-
Creating Config File For Script
inthewayboy replied to Chobyhy's topic in AutoIt General Help and Support
Sounds like I'm in the same boat too, using AutoIt as my entry into scripting/programming. Granted, I'm still a newb but I feel like I'm getting better all the time. I find the help file amazing, it explains most everything clearly and gives some nice examples too! And like it has been mentioned already the forums are the other great resource, no end to the genius on here. Between the two I haven't had much issues I could resolve. Back to the first part, something that I've been trying to impliment is creating custom UDF's that my other scripts hook up to via the #include command. -
Path Issue When Integrating AutoIt3
inthewayboy replied to inthewayboy's topic in AutoIt General Help and Support
Notepad2...and yeah, it looked like you needed to recomile it or something and that's when I gave up. Otherwise it's a sweet light-weight single-file replacement for Notepad. -
Path Issue When Integrating AutoIt3
inthewayboy replied to inthewayboy's topic in AutoIt General Help and Support
Well it's tricky, because I really love Notepad2, but I can't for the life of me figure out how to get it to recognize the AutoIt lexer. So I keep SciTE around for that, but I'm really starting to think about moving over to using just SciTE. And now that it doesn't look so complicated (Just the app and the api folder) I might do it. -
Path Issue When Integrating AutoIt3
inthewayboy replied to inthewayboy's topic in AutoIt General Help and Support
I seem to recall in my research into the inf portion that the %* is something special...something cryptic I'm sure. I'll see if I can't dig it up again, but it had to do with parameters, and the %* was kinda like a catch-all. And in the mean time the installation has finished and all is well. The final code is: HKCR,".au3","",0x00000000,"AutoIt3" HKCR,"AutoIt3","",0x00000000,"" HKCR,"AutoIt3","BrowserFlags",0x00010001,0x00000008 HKCR,"AutoIt3","EditFlags",0x00010001,0x00000000 HKCR,"AutoIt3\DefaultIcon","",0x00000000,"C:\WINDOWS\system32\AutoIt3.exe,0" HKCR,"AutoIt3\Shell","",0x00000000,"Open" HKCR,"AutoIt3\Shell\Open\Command","",0x00000000,"C:\WINDOWS\system32\AutoIt3.exe ""%1""" HKCR,"AutoIt3\Shell\Edit\Command","",0x00000000,"C:\WINDOWS\notepad.exe ""%1""" Of course now that there looks to be a portable SciTE with the new version I think I might try including that too. -
Path Issue When Integrating AutoIt3
inthewayboy replied to inthewayboy's topic in AutoIt General Help and Support
Also, since you are very well versed at both, would this scenario be any problem when it comes time to update AutoIt? From what I've seen it's pretty clean, to the point where I could just copy over the newer AutoIt3.exe and all is well. And I forgot to mention I do copy over the "Includes" folder, which ends up at C:\WINDOWS\system32\Includes. Again, when upgrade time comes just replace the files in there with the newer versions and that's all? -
Path Issue When Integrating AutoIt3
inthewayboy replied to inthewayboy's topic in AutoIt General Help and Support
Oh wow, it's been so long since a new release I never even checked that...sweet! I'll nab that and swap out the files! As far as what you are suggesting MHz I think we are talking about the same thing, but I am trying to do this from the source and not through a script, so would my adjusted code in the second post work? It looks like it's the same as yours (Converted) but you added a %* to it...what's that for? Is that a way to pass info to the script from a command arguement or something? -
Path Issue When Integrating AutoIt3
inthewayboy replied to inthewayboy's topic in AutoIt General Help and Support
Well it looks like enclosing the %1 with "" does the trick...I changed the registry on the machine I'm testing on and it works, so I'm going to try this code: HKCR,".au3","",0x00000000,"AutoIt3" HKCR,"AutoIt3","",0x00000000,"" HKCR,"AutoIt3","BrowserFlags",0x00010001,0x00000008 HKCR,"AutoIt3","EditFlags",0x00010001,0x00000000 HKCR,"AutoIt3\DefaultIcon","",0x00000000,"C:\WINDOWS\system32\AutoIt3.exe,0" HKCR,"AutoIt3\Shell","",0x00000000,"Open" HKCR,"AutoIt3\Shell\Open\Command","",0x00000000,"C:\WINDOWS\system32\AutoIt3.exe ""%1""" HKCR,"AutoIt3\Shell\Edit\Command","",0x00000000,"C:\WINDOWS\notepad.exe ""%1""" And then I'll see what happens...hehe, sometimes it's the simpliest things. I wonder though why the edit command works without the "" but the open command doesn't...any thoughts? -
Ok, so what I'm trying to do is integrate AutoIt3.exe into my windows installation source for my corporate network. I would like to keep it clean and minimal, meaning no shortcuts or extra's...just the bare essentials. From what I know about it, all that is required is the the main AutoIt3.exe, but I've also included the help file too. So what I have done is taken the registry settings for the file associations and inserted them into the HIVECLS.INF of the installation source. The source is Windows XP Pro with SP2. If you don't know, there are several HIVE***.INF files in the source that are used during setup to create the registry. HIVECLS.INF handles things in the HKCR, which is where file associations happen. I've got two entries, one for opening with AutoIt3 and the other to edit with Notepad. Here's the code: HKCR,".au3","",0x00000000,"AutoIt3" HKCR,"AutoIt3","",0x00000000,"" HKCR,"AutoIt3","BrowserFlags",0x00010001,0x00000008 HKCR,"AutoIt3","EditFlags",0x00010001,0x00000000 HKCR,"AutoIt3\DefaultIcon","",0x00000000,"C:\WINDOWS\system32\AutoIt3.exe,0" HKCR,"AutoIt3\Shell","",0x00000000,"Open" HKCR,"AutoIt3\Shell\Open\Command","",0x00000000,"C:\WINDOWS\system32\AutoIt3.exe %1" HKCR,"AutoIt3\Shell\Edit\Command","",0x00000000,"C:\WINDOWS\notepad.exe %1" I put AutoIt3.exe and AutoIt3.chm into the correct $OEM$ folders and they copy over during installation. Now that works fine, after installation I can double-click or call au3 files and it will process it or I can right-click and edit it. The problem is when I try to run a script from the desktop. Instead of running it says: Error reading the file: C:\Documents So it looks like it's tripping up on spaces in the pathname...but I don't know why? If I move the file to a location that doesn't have a space it works like expected. Any ideas? Hmmm...as I'm writting this I'm looking at the code and wondering if I need to enclose the %1 with "". I'll try that and see, but other than that I have no idea. I just checked the edit line, which also has the %1 without "" and it works fine to edit from the desktop... Also, if anyone knows of a better way to do this that would be great. I don't mind getting dirty in editing stuff obviously, but I want something clean and transparent for the most part. Thanx in advance! Oh, and I forgot to mention I'm doing this using the latest beta of AutoIt3, 3.1.133 at the time of this posting.
-
Need Some Advice For Copying Files
inthewayboy replied to inthewayboy's topic in AutoIt General Help and Support
I'm almost done with the production version...the MsgBox's are only there to help for dev. I've got all the errors going to a log file now. I've also implimented a crude for of FileExists, but I'm still having some issue with that. Basically, I can find out if the file exists, and even initiate a rename...but then if that second file name exists, or more, then I don't know what to do. Thanx again for the tips, I'll post the file version when it's done. -
Need Some Advice For Copying Files
inthewayboy replied to inthewayboy's topic in AutoIt General Help and Support
Okay, so after some time with both suggestions heres what I have: $axFolderA=@ScriptDir&"\DSS_FLDA\" $axFolderB=@ScriptDir&"\DSS_FLDB\" $axFolderC=@ScriptDir&"\DSS_FLDC\" $axFolderD=@ScriptDir&"\DSS_FLDD\" $axFolderE=@ScriptDir&"\DSS_FLDE\" $axDestRoot="\\WARCRAFT\beta\" $axDate=@YEAR&"-"&@MON&"-"&@MDAY _axTransfer($axFolderA,"red") _axTransfer($axFolderB,"green") _axTransfer($axFolderC,"blue") _axTransfer($axFolderD,"yellow") _axTransfer($axFolderE,"white") Func _axTransfer($axFolder,$axColor) ;Check for files $axFind=FileFindFirstFile($axFolder&"*.wma") ;Check if files found If $axFind=-1 Then MsgBox(0,$axFolder,"No Files Found",5) Else MsgBox(0,$axFolder,"Files Found",5) EndIf ;$x is the incrimental number at the end of the filename $x=1 While $axFind<>-1 ;Find next file $axFile=FileFindNextFile($axFind) If @error Then ExitLoop MsgBox(0,"Results",$axFile) ;Copy file to network share FileCopy($axFolder&$axFile,$axDestRoot&$axColor&"\"&$axDate&"_"&$x&".wma",8) ;Open MD5 Plugin $axPlugin=PluginOpen(@ScriptDir&"\md5.dll") ;Create MD5 Hashes $axMD5Local=FileHash($axFolder&$axFile,1) $axMD5Remote=FileHash($axDestRoot&$axColor&"\"&$axDate&"_"&$x&".wma",1) ;Compare MD5 Hashes If $axMD5Local=$axMD5Remote Then MsgBox(0,"Status","File Verified") ;If MD5 match then move file to archive share FileMove($axFolder&$axFile,$axDestRoot&"archive\"&$axColor&"\"&$axDate&"_"&$x&".wma",8) Else MsgBox(0,"Status","File Error") EndIf ;Close MD5 Plugin PluginClose($axPlugin) ;Increase the number by 1 $x=$x+1 WEnd ; Close the search handle FileClose($axFind) EndFunc It's pretty much done for now...I have to tweak some things like paths and logging, but otherwise it does everything I need! I guess I do have one question...should the MD5 hash fail it leaves the file on the device. What would be a good way to try and retransfer the failed files without having to re-run the script? Thanx again to you two for the suggestions...both were excellent! -
Need Some Advice For Copying Files
inthewayboy replied to inthewayboy's topic in AutoIt General Help and Support
exodius - That looks interesting...I'll play with that and see what I get mr.underperson - Thanx for the link, that looks like what I need. As far as the time thing goes, I agree it shouldn't be a problem, but a lot of the end users are older nurses and such. So I try to minimize the learning curve for them, and even though it would sort them logically I know they would get confused. -
In a nutshell, I need to copy all wma's from a digital voice recorder to specific files on our server. I've tracked down this sweet unit that is recognized as a mass storage device, and it has the USB plug built-in! For those of you interested it's the Olympus WS-100, picked it up at Best Buy for $100. Since it acts like a normal USB drive I can keep the script on the unit and run it from there...might eventually autorun it if I can find a way. The units records to five seperate folders, which works well for my project as we have five categories...I don't know what I'll do when we hit six. In each folder is whatever recordings you made, called WS_100xx.wma, where xx is a number starting at 01 and going up to 99. On the server I have a share, and in that share I have five folders all with different names. Each of those folders will be mapped to different users using login scripts. The idea is to make it as easy as possible to transfer from the device to the server. The person recording onto the device isn't very computer literate, but she can follow directions. She's going to be recording several notes into each folder, so there will never be a set amount of files. In the end I would like to tell her to just plug the device in and run the compiled script. Right now this is what I have: $axFolderA=@ScriptDir&"\DSS_FLDA\" $axFolderB=@ScriptDir&"\DSS_FLDB\" $axFolderC=@ScriptDir&"\DSS_FLDC\" $axFolderD=@ScriptDir&"\DSS_FLDD\" $axFolderE=@ScriptDir&"\DSS_FLDE\" $axDestRoot="\\WARCRAFT\beta\" ; Shows the filenames of all files in the current directory. $axFindA=FileFindFirstFile($axFolderA&"*.wma") ; Check if the search was successful If $axFindA=-1 Then MsgBox(0,"FolderA","No Files Found",5) Else MsgBox(0,"FolderA","Files Found",5) EndIf While $axFindA<>-1 $axFileA=FileFindNextFile($axFindA) If @error Then ExitLoop MsgBox(0,"Results",$axFileA) FileCopy($axFolderA&$axFileA,$axDestRoot&"red\"&$axFileA,8) WEnd ; Close the search handle FileClose($axFindA) ; Shows the filenames of all files in the current directory. $axFindB=FileFindFirstFile($axFolderB&"*.wma") ; Check if the search was successful If $axFindB=-1 Then MsgBox(0,"FolderB","No Files Found",5) Else MsgBox(0,"FolderB","Files Found",5) EndIf While $axFindB<>-1 $axFileB=FileFindNextFile($axFindB) If @error Then ExitLoop MsgBox(0,"Results",$axFileB) FileCopy($axFolderB&$axFileB,$axDestRoot&"green\"&$axFileB,8) WEnd ; Close the search handle FileClose($axFindB) ; Shows the filenames of all files in the current directory. $axFindC=FileFindFirstFile($axFolderC&"*.wma") ; Check if the search was successful If $axFindC=-1 Then MsgBox(0,"FolderC","No Files Found",5) Else MsgBox(0,"FolderC","Files Found",5) EndIf While $axFindC<>-1 $axFileC=FileFindNextFile($axFindC) If @error Then ExitLoop MsgBox(0,"Results",$axFileC) FileCopy($axFolderC&$axFileC,$axDestRoot&"blue\"&$axFileC,8) WEnd ; Close the search handle FileClose($axFindC) ; Shows the filenames of all files in the current directory. $axFindD=FileFindFirstFile($axFolderD&"*.wma") ; Check if the search was successful If $axFindD=-1 Then MsgBox(0,"FolderD","No Files Found",5) Else MsgBox(0,"FolderD","Files Found",5) EndIf While $axFindD<>-1 $axFileD=FileFindNextFile($axFindD) If @error Then ExitLoop MsgBox(0,"Results",$axFileD) FileCopy($axFolderD&$axFileD,$axDestRoot&"yellow\"&$axFileD,8) WEnd ; Close the search handle FileClose($axFindD) ; Shows the filenames of all files in the current directory. $axFindE=FileFindFirstFile($axFolderE&"*.wma") ; Check if the search was successful If $axFindE=-1 Then MsgBox(0,"FolderE","No Files Found",5) Else MsgBox(0,"FolderE","Files Found",5) EndIf While $axFindE<>-1 $axFileE=FileFindNextFile($axFindE) If @error Then ExitLoop MsgBox(0,"Results",$axFileE) FileCopy($axFolderE&$axFileE,$axDestRoot&"white\"&$axFileE,8) WEnd ; Close the search handle FileClose($axFindE) I have several questions...the first should be obvious. I have the same steps repeating each time for each folder. Each time the variables change inside it, so I can't figure out a way to shrink that into a function or loop...any ideas or suggestions? The next question is verification. I have the MsgBox's for testing the basic syntax, but that doesn't really tell me if the file transfered correctly. I was thinking some kinda file comparison at the byte level...isn't that what MD5 is? Again, any suggestions as to a function or tool to use to help with this would be great! And the final question is dynamic renaming...each time the script runs it could have any number of files in each folder. My first thought was to rename it during the FileCopy to something based on the date, but then what happens when I have more than one in each folder? I guess I could incorporate the time as well, but this it's just too complicated for the end user. So I was thinking something like 20060602_xx, with xx starting at 01 and going up...and I don't know how to impliment that part. To be specific, how could I make the xx incriment in the FileCopy step, or is there a better way to handle that. Eventually I want to build a GUI to handle this, and allow the user to rename the files to something a little more relevant than just the date, but I'm taking baby steps still...thanx in advance!
-
See...it's always the simple things I didn't think to look for functions that started with something other than obj. To verify, the code you provided (Which works great!) basically checks the results of the $OutlookContact variable to see if it's an object? And if it's not a valid contact, then it's not a vaild object either, so that's sweet...thanx again!
-
Forgot to mention, using the latest beta (3.1.1.119)
-
All of our users run Outlook 2003 with a local PST, no Exchange server at all. Configuration and backup is done via other scripts, and now I'm trying to get past a contacts issue. I've only just learned about COM as of yesterday, so I'm very new at it. Using some vbs examples I've managed to create a script that will use an Excel file to load in new contacts, and it does this perfectly. However, the hurdle is trying to minimize duplicates. Currently it just adds new contacts, so if one already exists then it just adds another one. If I run the import script twice, then I get two sets of the contacts. In the examples I was referencing there is a section where the code checks to see if a contact exists. It uses the TypeName function, which for AutoIt is the ObjName function. However, I can't get any syntax to work. It will work the same if the contacts exists or not. Here's what I'm trying to run: If ProcessExists ( "OUTLOOK.EXE" ) Then ProcessClose ( "OUTLOOK.EXE" ) Sleep ( 5000 ) EndIf Run ( @ProgramFilesDir & "\Microsoft Office\OFFICE11\OUTLOOK.EXE" ) Sleep ( 5000 ) $objOutlook = ObjCreate ( "Outlook.Application" ) $objExcel = ObjCreate ( "Excel.Application" ) $objWorkbook = $objExcel.Workbooks.Open ( @ScriptDir & "\contacts.xls" ) $xxx = 2 Do $objContact = $objOutlook.CreateItem ( 2 ) $objContact.LastName = $objExcel.Cells($xxx,1).Value $objContact.FirstName = $objExcel.Cells($xxx,2).Value $objContact.FullName = $objExcel.Cells($xxx,3).Value ;$objContact.User = $objExcel.Cells($xxx,4).Value $objContact.BusinessTelephoneNumber = $objExcel.Cells($xxx,5).Value $objContact.MobileTelephoneNumber = $objExcel.Cells($xxx,6).Value $objContact.HomeTelephoneNumber = $objExcel.Cells($xxx,7).Value $objContact.BusinessFaxNumber = $objExcel.Cells($xxx,8).Value $objContact.Department = $objExcel.Cells($xxx,9).Value $objContact.JobTitle = $objExcel.Cells($xxx,10).Value $objContact.ManagerName = $objExcel.Cells($xxx,11).Value $objContact.Email1Address = $objExcel.Cells($xxx,12).Value $objContact.Email2Address = $objExcel.Cells($xxx,13).Value $objContact.OfficeLocation = $objExcel.Cells($xxx,14).Value $objContact.Save $xxx = $xxx + 1 Until $objExcel.Cells($xxx,1).Value = "" $objExcel.Quit $objOutlook.Quit And here is the item checking code, in vbs: Set olApp = CreateObject("Outlook.Application") Set objNameSpace = olApp.GetNamespace("MAPI") Set objContacts = objNameSpace.GetDefaultFolder(10) Set objContact = objContacts.Items.Find("[FileAs] = ""Doe, John""") If Not TypeName(objContact) = "Nothing" Then MsgBox "yyy" Else MsgBox "nnn" End If Now I've seen and tried some of the various COM error handling suggestions on the forum, but I can't figure out what I'm missing. If I can get an If/Then thing going that's all I need. From the example in vbs it looks like the error code for the value not being present is literally "Nothing", but I can't figure out what error code the ObjName function gives...again, using something like: $OutlookApplication = ObjCreate ( "Outlook.Application" ) $OutlookNamespace = $OutlookApplication.GetNamespace("MAPI") $OutlookContacts = $OutlookNamespace.GetDefaultFolder(10) $OutlookContact = $OutlookContacts.Items.Find( '[FileAs] = "Doe, John"' ) If ObjName ( $OutlookContact ) = "" Then MsgBox ( 0 , "Debug" , "Error" ) Else MsgBox ( 0 , "Debug" , "Success" ) EndIf Seems to give me the same result if the contact exists or not...help! I'm sure like the rest of my issues someone will reply with a simple fix, I thank you in advance!
-
String Missing Closing Quotes
inthewayboy replied to ioliver's topic in AutoIt General Help and Support
I still suck at this part, but wouldn't you need to use two ' in the folder name? Using two of them should result in only one, at least that's how it works with other things like $$. -
Help with _FTPCommand (ftp.au3)
inthewayboy replied to zichy's topic in AutoIt General Help and Support
I used the FTP.au3 in one of my original scripts, but found this to be easier: http://www.pacific.net/~ken/software/ The program is called wcl_ftp...the the wcl = windows command line. So it's very easy to integrate into a script using the Run command. It gives you the option of seeing a window that displays the progress and results and you HAVE to specify what mode to transfer in, which is both good and bad. It can also log all the screen info too. The website looks like crap but the application is pretty nice...otherwise I have no other suggestions...good luck!