oritronen
asked on
Script to create PRF then Edit it.
Hello all,
Our company is move to a new email domain name, and we need to create new email accounts within an existing email profile. I have created a vbscript to edit a dummy PRF file and have the user info be populated by the user. Below is my vbscript.
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- -----
Const ForReading = 1
Const ForWriting = 2
'Get the users name
sName = InputBox("What is your first and last name?")
sPOP = InputBox("Please enter the beginging of your email address, not @domain.com")
'Display the user's name
'MsgBox "Your first and last name is " & sName
Wscript.Echo "Your first and last name is " & sName
Wscript.Echo "Your email is " & sPOP & "@domain.com"
Function Domain()
Set objFSO = CreateObject("Scripting.Fi leSystemOb ject")
Set objFile = objFSO.OpenTextFile("C:\Sc ripts\outl ook\testpr f.PRF", ForReading)
strText = objFile.ReadAll
objFile.Close
strNewText = Replace(strText, "@domain.com", "@Newdomain.com")
Set objFile = objFSO.OpenTextFile("C:\Sc ripts\outl ook\testpr f.PRF", ForWriting)
objFile.WriteLine strNewText
objFile.Close
End Function
Domain()
Function Name()
Set objFSO = CreateObject("Scripting.Fi leSystemOb ject")
Set objFile = objFSO.OpenTextFile("C:\Sc ripts\outl ook\testpr f.PRF", ForReading)
strText = objFile.ReadAll
objFile.Close
strNewText = Replace(strText, "ReplaceDisplayName", sName)
Set objFile = objFSO.OpenTextFile("C:\Sc ripts\outl ook\testpr f.PRF", ForWriting)
objFile.WriteLine strNewText
objFile.Close
End Function
Name()
Function POP3Name()
Set objFSO = CreateObject("Scripting.Fi leSystemOb ject")
Set objFile = objFSO.OpenTextFile("C:\Sc ripts\outl ook\testpr f.PRF", ForReading)
strText = objFile.ReadAll
objFile.Close
strNewText = Replace(strText, "POP3Name", sPOP)
Set objFile = objFSO.OpenTextFile("C:\Sc ripts\outl ook\testpr f.PRF", ForWriting)
objFile.WriteLine strNewText
objFile.Close
End Function
POP3Name()
Function Folder()
Dim filesys, newfolder
Dim objWSH
Dim objUserVariables
Dim objSystemVariables
Set objWSH = CreateObject("WScript.Shel l")
'This actually returns all the User Variables, and you either loop through all, or simply print what you want
WScript.Echo "UserProfile=" & objWsh.Environment("PROCES S")("UserP rofile")
strUP = objWsh.Environment("PROCES S")("UserP rofile") & "\My Documents\pst"
WScript.Echo "PST location" & strUP
set filesys=CreateObject("Scri pting.File SystemObje ct")
If Not filesys.FolderExists (strUP) Then
WScript.StdOut.Write( vbCrlf )
newfolder = filesys.CreateFolder (strUP)
WScript.StdOut.Write "A new folder '" & newfolder & "' has been created"
End If
Set objFSO = CreateObject("Scripting.Fi leSystemOb ject")
Set objFile = objFSO.OpenTextFile("C:\Sc ripts\outl ook\testpr f.PRF", ForReading)
strText = objFile.ReadAll
objFile.Close
strNewText = Replace(strText, "ReplacePath", strUP)
Set objFile = objFSO.OpenTextFile("C:\Sc ripts\outl ook\testpr f.PRF", ForWriting)
objFile.WriteLine strNewText
objFile.Close
End Function
Folder()
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- -----
and here is the section of the PRF I am changing
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- -----
[Account1]
UniqueService=No
AccountName=Account1
POP3Server=server
SMTPServer=server
POP3UserName=POP3Name
EmailAddress=POP3Name@doma in.com
POP3UseSPA=0
DisplayName=ReplaceDisplay Name
ReplyEMailAddress=
SMTPUseAuth=1
SMTPAuthMethod=0
ConnectionType=0
LeaveOnServer=0x0
ConnectionOID=MyConnection
POP3Port=110
POP3UseSSL=0
ServerTimeOut=60
SMTPPort=25
SMTPUseSSL=0
Name=My Personal Folder
PathToPersonalFolders=Repl acePath\fi ndme.pst
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- -----
I would like to completely automate this process, without the need for any user input. Is there a way to script the creation of a PRF file containing the users info and then use my vbscript to edit it.
Thank you.
Our company is move to a new email domain name, and we need to create new email accounts within an existing email profile. I have created a vbscript to edit a dummy PRF file and have the user info be populated by the user. Below is my vbscript.
--------------------------
Const ForReading = 1
Const ForWriting = 2
'Get the users name
sName = InputBox("What is your first and last name?")
sPOP = InputBox("Please enter the beginging of your email address, not @domain.com")
'Display the user's name
'MsgBox "Your first and last name is " & sName
Wscript.Echo "Your first and last name is " & sName
Wscript.Echo "Your email is " & sPOP & "@domain.com"
Function Domain()
Set objFSO = CreateObject("Scripting.Fi
Set objFile = objFSO.OpenTextFile("C:\Sc
strText = objFile.ReadAll
objFile.Close
strNewText = Replace(strText, "@domain.com", "@Newdomain.com")
Set objFile = objFSO.OpenTextFile("C:\Sc
objFile.WriteLine strNewText
objFile.Close
End Function
Domain()
Function Name()
Set objFSO = CreateObject("Scripting.Fi
Set objFile = objFSO.OpenTextFile("C:\Sc
strText = objFile.ReadAll
objFile.Close
strNewText = Replace(strText, "ReplaceDisplayName", sName)
Set objFile = objFSO.OpenTextFile("C:\Sc
objFile.WriteLine strNewText
objFile.Close
End Function
Name()
Function POP3Name()
Set objFSO = CreateObject("Scripting.Fi
Set objFile = objFSO.OpenTextFile("C:\Sc
strText = objFile.ReadAll
objFile.Close
strNewText = Replace(strText, "POP3Name", sPOP)
Set objFile = objFSO.OpenTextFile("C:\Sc
objFile.WriteLine strNewText
objFile.Close
End Function
POP3Name()
Function Folder()
Dim filesys, newfolder
Dim objWSH
Dim objUserVariables
Dim objSystemVariables
Set objWSH = CreateObject("WScript.Shel
'This actually returns all the User Variables, and you either loop through all, or simply print what you want
WScript.Echo "UserProfile=" & objWsh.Environment("PROCES
strUP = objWsh.Environment("PROCES
WScript.Echo "PST location" & strUP
set filesys=CreateObject("Scri
If Not filesys.FolderExists (strUP) Then
WScript.StdOut.Write( vbCrlf )
newfolder = filesys.CreateFolder (strUP)
WScript.StdOut.Write "A new folder '" & newfolder & "' has been created"
End If
Set objFSO = CreateObject("Scripting.Fi
Set objFile = objFSO.OpenTextFile("C:\Sc
strText = objFile.ReadAll
objFile.Close
strNewText = Replace(strText, "ReplacePath", strUP)
Set objFile = objFSO.OpenTextFile("C:\Sc
objFile.WriteLine strNewText
objFile.Close
End Function
Folder()
--------------------------
and here is the section of the PRF I am changing
--------------------------
[Account1]
UniqueService=No
AccountName=Account1
POP3Server=server
SMTPServer=server
POP3UserName=POP3Name
EmailAddress=POP3Name@doma
POP3UseSPA=0
DisplayName=ReplaceDisplay
ReplyEMailAddress=
SMTPUseAuth=1
SMTPAuthMethod=0
ConnectionType=0
LeaveOnServer=0x0
ConnectionOID=MyConnection
POP3Port=110
POP3UseSSL=0
ServerTimeOut=60
SMTPPort=25
SMTPUseSSL=0
Name=My Personal Folder
PathToPersonalFolders=Repl
--------------------------
I would like to completely automate this process, without the need for any user input. Is there a way to script the creation of a PRF file containing the users info and then use my vbscript to edit it.
Thank you.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.