?
Solved

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

Posted on 2009-05-14
1
Medium Priority
?
334 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 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

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

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

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses
Course of the Month17 days, 1 hour left to enroll

862 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