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

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.

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

Try this.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
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 Select All
Random Solutions  
 
programming4us programming4us