Solved

Variables not being passed correctly

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…

863 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

26 Experts available now in Live!

Get 1:1 Help Now