/build/static/layout/Breadcrumb_cap_w.png

VBScript Regwrite within a For loop

Hi,
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)
Next


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
Jimmy

0 Comments   [ + ] Show comments

Answers (1)

Posted by: jimmyx 15 years ago
Purple Belt
0
Sorted now! I had a sneaky ampersand in one of my variables!
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ