Solved

Variables not being passed correctly

Posted on 2006-11-10
4
762 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Suggested Solutions

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

752 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