I am trying to write some registry values using an array I am having problems when calling Regwrite from within the for loop, I get an invalid procedure or argument message.
Here is part of the code

arrMailReg(0) = "Account Name,"&strMailAccountName&",REG_SZ"
arrMailReg(1) = "Connection Type,3,REG_DWORD"
arrMailReg(2) = "Server Read Only,1,REG_DWORD"
arrMailReg(3) = "IMAP Use Sicily,0,REG_DWORD"
arrMailReg(4) = "IMAP Server,"&strIMAPServer&",REG_SZ"
arrMailReg(5) = "IMAP User Name,"&strUsername&",REG_SZ"
arrMailReg(6) = "IMAP Root Folder,,REG_SZ"
arrMailReg(7) = "IMAP Dirty,0,REG_SZ"
arrMailReg(8) = "IMAP Polling,1,REG_DWORD"
arrMailReg(9) = "IMAP Prompt for Password,1,REG_DWORD"
arrMailReg(10) = "IMAP Sent Items Folder,sentmail,REG_SZ"
arrMailReg(11) = "IMAP Drafts Folder,drafts,REG_SZ"
arrMailReg(12) = "SMTP Server,"&strSMTPServer&",REG_SZ"
arrMailReg(13) = "SMTP Display Name,"&strUserFullName&",REG_SZ"
arrMailReg(14) = "SMTP Email Address,"&strUserEmailAddress&",REG_SZ&"
arrMailReg(15) = "SMTP Organization Name,"&strOrgName&",REG_SZ"
arrMailReg(16) = "SMTP Reply to Email Address,"&strUserEmailAddress&",REG_SZ"
arrMailReg(17) = "SMTP Use Sicily,0,REG_DWORD"

For Each strMailSetting In arrMailReg
arrMailVal = Split(strMailSetting,",")
strRegKey = MailRegKey & "\" & arrMailval(0)
objshell.RegWrite strRegKey, arrMailVal(1),arrMailval(2)

If I place

objshell.RegWrite strRegKey, arrMailVal(1),arrMailval(2)

below the for loop then it works OK with the correct values, but obviously only writes the last array element to the registry.

So RegWrite must not like being called from within the for loop
Can anyone suggest a way around this?

Many Thanks in advance
0 Comments   [ + ] Show Comments


Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.


Sorted now! I had a sneaky ampersand in one of my variables!
Answered 04/27/2009 by: jimmyx
Purple Belt

Please log in to comment
Answer this question or Comment on this question for clarity
Admin Script Editor
Admin Script Editor is an integrated scripting environment available free here at ITNinja