views:

14

answers:

1

Hi, I'm trying to write a script which basically takes an array of lots of users and checks if the logged on user match. If it does, a different routine is run.

This is what I have so far:

Dim objNetwork
Dim Username

Set objNetwork = CreateObject("WScript.Network")
Username = objNetwork.UserName

What I have to do next is to assign each user to an array. And then check that array if any of the strings in the array matches the Username variable. How do I do this?

+2  A: 

Found out :p

Dim objNetwork
Dim Username
Dim UsersAffected
UsersAffected = Array("username", "test2", "test3")

Set objNetwork = CreateObject("WScript.Network")
Username = objNetwork.UserName

Dim c
For each c In UsersAffected
    if c = Username Then
        Msgbox "Match!"
    End if
Next
Kenny Bones
An `Exit For` is welcome.
Constantin