Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Variables not being passed correctly

Posted on 2006-11-10
4
Medium Priority
?
769 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 2000 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…
Suggested Courses

916 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