Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

VB Script to run executable file based on AD group membership

Posted on 2012-09-21
3
Medium Priority
?
645 Views
Last Modified: 2012-09-24
Need to invent a script
The script meant to run "C:\Program Files (x86)\Citrix\ICA Client\Receiver\Receiver.exe" if loggedon user is member of domain admins group
My script is below, but not working


On Error Resume Next

Set objDictionary = CreateObject("Scripting.Dictionary")

set shell=Createobject("WScript.Shell")

Set objADSysInfo = CreateObject("ADSystemInfo")

strUser = objADSysInfo.UserName

Set objUser = GetObject("LDAP://" & strUser)

For Each strGroup in objUser.memberOf
    Set objGroup = GetObject("LDAP://" & strGroup)
    strGroupName = objGroup.CN
    objDictionary.Add strGroupName, strGroupName  
Next

If objDictionary.Exists("Domain Admins") Then
    shell.run "C:\Program Files (x86)\Citrix\ICA Client\Receiver\Receiver.exe",1 ,true
    Wscript.Quit
End If
0
Comment
Question by:johnkim777
  • 2
3 Comments
 
LVL 14

Expert Comment

by:Justin Yeung
ID: 38422977
Move Next to the bottom, otherwise it will only read the first group in AD

On Error Resume Next

Set objDictionary = CreateObject("Scripting.Dictionary")

set shell=Createobject("WScript.Shell")

Set objADSysInfo = CreateObject("ADSystemInfo")

strUser = objADSysInfo.UserName

Set objUser = GetObject("LDAP://" & strUser)

For Each strGroup in objUser.memberOf
    Set objGroup = GetObject("LDAP://" & strGroup)
    strGroupName = objGroup.CN
    objDictionary.Add strGroupName, strGroupName  


If objDictionary.Exists("Domain Admins") Then
    shell.run "C:\Program Files (x86)\Citrix\ICA Client\Receiver\Receiver.exe",1 ,true
    Wscript.Quit
End If

Next
0
 

Author Comment

by:johnkim777
ID: 38428428
it didn't work
can you review the code again? please
0
 
LVL 14

Accepted Solution

by:
Justin Yeung earned 2000 total points
ID: 38428628
On Error Resume Next

set shell=Createobject("WScript.Shell")

Set objADSysInfo = CreateObject("ADSystemInfo")

strUser = objADSysInfo.UserName

Set objUser = GetObject("LDAP://" & strUser)

For Each strGroup in objUser.memberOf
    Set objGroup = GetObject("LDAP://" & strGroup)
    strGroupName = objGroup.CN

If strGroupName = "Domain Admins" Then
    shell.run "C:\Program Files (x86)\Citrix\ICA Client\Receiver\Receiver.exe",1 ,true
    Wscript.Quit
End If

Next
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This collection of functions covers all the normal rounding methods of just about any numeric value.
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

571 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