Solved

Variables not being passed correctly

Posted on 2006-11-10
4
758 Views
Last Modified: 2012-06-21
I am writing a script to automate the creation of a user's Outlook profile using a small tool called RichProfile.

http://desktopengineer.com/story_20011129081953709

the problem I'm having is the wrong parameters are being passed.

Dim vbExMailServer      : vbExMailServer = "MAILSERVER"
Dim      vbExMailbox            : vbExMailbox = "%USERNAME%"
Dim      vbExProfileName      : vbExProfileName = "%USERNAME%"
Dim      vbProfileDelete      : vbProfileDelete = "Y"
Dim      vbSetProfileTo      : vbSetProfileTo = "D"

Dim oShell
Set oShell = Wscript.CreateObject("WScript.Shell")

oShell.Run "RichProfile vbExMailserver vbExMailbox vbExProfileName vbProfileDelete vbSetProfileTo"

The above executes with success, but the mailserver is set to vbExMailServer, the mailbox is set to vbExMailbox, and the
profile name is set to vbExProfileName.

The .vbs file and the RichProfile.exe are both located in the same folder.

What am I overlooking?

0
Comment
Question by:trarthur
  • 2
4 Comments
 
LVL 67

Accepted Solution

by:
sirbounty earned 500 total points
ID: 17916021
Change this line:
oShell.Run "RichProfile vbExMailserver vbExMailbox vbExProfileName vbProfileDelete vbSetProfileTo"
to
oShell.Run "RichProfile " & vbExMailserver & " " & vbExMailbox  & " " & vbExProfileName  & " " & vbProfileDelete  & " " & vbSetProfileTo

so that you're using the variables instead...
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 17916041
Though, I don't think %USERNAME% will translate as expected...
Try adding this instead:

Set objNetwork = WScript.CreateObject("WScript.Network")

Dim vbExMailbox : vbExMailbox = objNetwork.UserName
Dim vbExProfileName : vbExProfileName = objNetwork.UserName
0
 
LVL 5

Author Comment

by:trarthur
ID: 17916331
>>Change this line:
oShell.Run "RichProfile vbExMailserver vbExMailbox vbExProfileName vbProfileDelete vbSetProfileTo"
to
oShell.Run "RichProfile " & vbExMailserver & " " & vbExMailbox  & " " & vbExProfileName  & " " & vbProfileDelete  & " " & vbSetProfileTo


That did the trick.  No need to change the %username%.  Seems to run just fine.  Thanks a million!
0
 

Expert Comment

by:TechResources
ID: 24875528
Wow, this is an old one but would like to be able to run script above minimized or hidden.  Any ideas?

THANK U
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question