seem to be having some problems with this.. can somone look it over and tell me where im going wrong??
Dim compname As String
compname = Environment.MachineName
If compname = "laptop1" Or "laptop2" Or "laptop3" Then
MsgBox("YAY!!! IT WORKED!")
what i need todo is make a startup script that copys some files from a mapped network drive down to somones all users folder if there computer name match's..
id love to beable to put the computer name in some array, but thats even harder for me to get my head around!!
also. while iv got a post open.. is there any(easy) way of getting and doing this through AD groups instead of computer names?
so if the person logging on is in the "BLAH BLAH" group, it copys the folder down to the all users folder?
hope you can help!
thanks in advance!
A couple of things that may need changing if it is a VBS script.
VBS it typeless so it should just be as the variable will remain typeless untill data is put into it.
You may also need to add brackets around your conditional
I think that the conditional may also need to evaluate each individually ie:
If (compname = "laptop1" Or "laptop2" Or "laptop3") Then
This may also be a quicker way of resolving the hostname:
If (compname = "laptop1" Or compname = "laptop2" Or compname = "laptop3") Then
Not 100% sure about the speed but this is the way that I have always done it.
Set WshNetwork = WScript.CreateObject("WScript.Network")
compname = WshNetwork.ComputerName
There is also WshNetwork.UserName and WshNetwork.UserDomain which will let you get the username and domain while your at it.
Just re-read the post and there is an easy way to do it via groups:
usage is just:
Dim sAdsPath, oUser, oGroup
If IsEmpty(oGroupDict) Then
Set oGroupDict = CreateObject("Scripting.Dictionary")
oGroupDict.CompareMode = vbTextCompare
sAdsPath = WshNetwork.UserDomain & "/" & WshNetwork.UserName
Set oUser = GetObject("WinNT://" & sAdsPath & ",user")
For Each oGroup In oUser.Groups
oGroupDict.Add oGroup.Name, "-"
Set oUser = Nothing
IsMember = CBool(oGroupDict.Exists(sGroup))
'if (IsMember) then
' inputFile.WriteLine(Now() & ": Success: User is member of " & sGroup)
I can't take credit for this I got it of a site of system admin scripts by this guy:
if ismember("Office") then
Can't remember the site now though. It might also be worth looking in the WIKI here as I think that most of this stuff is covered under the scripting section.
in the end, i bit the bullet, and just used autoIT.. what iv never used before. and have now coded quite a nice script!!
think im going to be using autoIT for most of my jobs now,
who else uses autoIT?
The Edugeek admin bar is all AutoIT, I think. :)
Originally Posted by Tom-Kirby