Solved

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

Posted on 2009-05-14
1
326 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
1 Comment
 
LVL 22

Accepted Solution

by:
Paka earned 500 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
Utilizing an array to gracefully append to a list of EmailAddresses
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

708 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

19 Experts available now in Live!

Get 1:1 Help Now