?
Solved

How to read city from Active Directory and use as parameter to startup exe

Posted on 2009-05-14
1
Medium Priority
?
332 Views
Last Modified: 2013-12-26
Hi guys,

I need some scripting help an I was hoping to find help on this great site. Not sure if this is can be done with a regular batch file, or if a VBS script is needed. Basicly this is what I want to accomplish:

1. User starts script.
2. Script looks at active directory to find the City value of the logged in user.
3. Script creates a user variable named CITY with this value
4. Script starts another tool, application.exe CITY.
5. Script closes as soon as the "application.exe city" has started.
0
Comment
Question by:AACCosmos
[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
1 Comment
 
LVL 22

Accepted Solution

by:
Paka earned 1500 total points
ID: 24395945
Try this.
option explicit
Dim objADInfo, objUser, strUser, strCity, wshshell
 
'get the username in DN format
Set objADInfo = CreateObject("ADSystemInfo") 
strUser = objADInfo.UserName
 
'query the city from AD
Set objUser = GetObject("LDAP://" & strUser)
strCity = objUser.Get("l")
 
'invoke a shell calling application.exe
Set WshShell = WScript.CreateObject("WScript.Shell")
wshShell.Run "application.exe " & strCity, 1, TRUE

Open in new window

0

Featured Post

Not sure which OpenStack Certification to get?

So you’ve realized you might want to get certified in OpenStack, but you’re not sure what the benefits might be or even which one you should take. You know there are several certification courses you can choose from, but how do you know which one is right for you?

Question has a verified solution.

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

It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

765 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