Prev: Detect Win Logon
Next: IPconfig script
From: Dan on 5 Mar 2010 18:43 I have a script that is working pretty well but I don't understand what's happening when I try to output a file (sort of acting as my log file). My hope is to get each created contact to be listed in the file but it only seems to be writing one of the names that get created. Essentially, the script looks at a few things and decides what contacts to create. Here's the part causing me problems (the second part of the If statement): Else ' Build the actual contacts. Set objContact = objOU.Create("Contact",_ "cn=" & strContactName) objContact.Put "Mail", (strMail(0)) + "@subdomain.domain.com" objContact.Put "givenName", strGivenName objContact.Put "DisplayName", strContactName objContact.Put "msExchHideFromAddressLists", True objContact.Put "sn", strSN objContact.Put "targetAddress", "SMTP:" + (strMail(0)) + "@subdomain.domain.com" objContact.Put "mailNickname", strCN objContact.SetInfo 'Write out the log file Set fso = CreateObject("Scripting.FileSystemObject") Set ContactFile = fso.CreateTextFile("c:\Contacts.txt", True) ContactFile.Write(strContactName & vbTab) ContactFile.WriteLine("Contactt Created") ContactFile.Close End If Next I'm guessing I have something super simple missing in the bottom section that would allow for appending but I'm not seeing it from the tutorials I'm finding online. Thanks for any help.
From: LikeToCode on 5 Mar 2010 19:02 Hi Dan, I would use the OpenTextFile Method. http://msdn.microsoft.com/en-us/library/314cz14s(VS.85).aspx
From: "Dave "Crash" Dummy" on 5 Mar 2010 21:07 Dan wrote: > I have a script that is working pretty well but I don't understand what's > happening when I try to output a file (sort of acting as my log file). > > My hope is to get each created contact to be listed in the file but it only > seems to be writing one of the names that get created. > > Essentially, the script looks at a few things and decides what contacts to > create. Here's the part causing me problems (the second part of the If > statement): > > > Else > > ' Build the actual contacts. > > Set objContact = objOU.Create("Contact",_ > "cn=" & strContactName) > objContact.Put "Mail", (strMail(0)) + "@subdomain.domain.com" > objContact.Put "givenName", strGivenName > objContact.Put "DisplayName", strContactName > objContact.Put "msExchHideFromAddressLists", True > objContact.Put "sn", strSN > objContact.Put "targetAddress", "SMTP:" + (strMail(0)) + > "@subdomain.domain.com" > objContact.Put "mailNickname", strCN > objContact.SetInfo > > > 'Write out the log file > > Set fso = CreateObject("Scripting.FileSystemObject") > Set ContactFile = fso.CreateTextFile("c:\Contacts.txt", True) > > ContactFile.Write(strContactName & vbTab) > ContactFile.WriteLine("Contactt Created") > ContactFile.Close > > End If > > Next > > I'm guessing I have something super simple missing in the bottom section > that would allow for appending but I'm not seeing it from the tutorials I'm > finding online. > > Thanks for any help. Replace this: Set ContactFile = fso.CreateTextFile("c:\Contacts.txt", True) With this: Set ContactFile = fso.OpenTextFile("c:\Contacts.txt", 8, True) -- Crash "The real question is not whether machines think but whether men do." ~ B. F. Skinner ~
|
Pages: 1 Prev: Detect Win Logon Next: IPconfig script |