Solved

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

Posted on 2009-05-14
1
331 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 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

691 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