Solved

Variables not being passed correctly

Posted on 2006-11-10
4
752 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
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…

707 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now