Hi,
This code works for me. Only the CMD windows are visible.
Does somebody nows how to hide these?
Thx
Mickey
This code works for me. Only the CMD windows are visible.
Does somebody nows how to hide these?
Thx
Mickey
Code:
On error Resume Next
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshProcessEnvironment = WshShell.Environment("Process")
LogonServer = WshProcessEnvironment("LogonServer")
'Msgbox(GetMac("10.1.252.2")) 'Msgbox the results of the GetMac Function, passings an IP Address to it
Function GetMac(ip) 'Begin GetMac function
Set WshExec = WshShell.Exec("ping -n 4 -w 1000 " & ip) 'Run the PING command in command shell to build ARP table
WScript.Sleep(2000) 'Sleep 2 seconds, allows ARP table to catch up
Set WshExec = WshShell.Exec("arp -a") 'List the ARP table
strPingResults = LCase(WshExec.StdOut.ReadAll) 'Drop the entire ARP table into a variable
strARPList = Split(strPingResults) 'Break variable into an Array
n = UBound(strARPList,1) 'Get the size of the Array
For X = 0 To n 'Loop from 0 to the size of the Array
If strARPList(x) = ip Then 'Compare the Array single variable to the IP address, if they match...
For y = 1 To 16 'Loop for 16 (this is used to hunt down the MAC address)
If strARPList(x+y) <> "" Then 'If the array variable is NOT empty (must be the MAC ID)....
GetMac = strARPList(x+y) 'Return the MAC ID
Exit For 'Exit For Next Loop
End If
Next
End If
Next
End Function
'PRODUKTIE OMGEVING (FIREWALL MAC PROD)
If (GetMac("10.1.252.2")) = "00-10-db-ff-25-21" Then
WshShell.Run chr(34) & LogonServer & "\Netlogon\Software\Bginfo\Bginfo.exe " & chr(34) & LogonServer & "\Netlogon\Software\Bginfo\BG_PRODUKTIE.bgi /timer:0 /nolicprompt" & chr(34), 1, True
MsgBox "Je bent ingelogd op het PRODUKTIE Netwerk1"
Else
'MsgBox "not ok"
End If
'TEST OMGEVING (FIREWALL MAC TEST)
If (GetMac("10.1.252.2")) = "00-1f-12-48-2a-4b" Then
WshShell.Run chr(34) & LogonServer & "\Netlogon\Software\Bginfo\Bginfo.exe " & chr(34) & LogonServer & "\Netlogon\Software\Bginfo\BG_TEST.bgi /timer:0 /nolicprompt" & chr(34), 1, True
MsgBox "Je bent ingelogd op het TEST Netwerk2"
Else
'MsgBox "not ok"
End If
'UITWIJK OMGEVING (FIREWALL MAC UITW)
If (GetMac("10.1.252.2")) = "00-1f-12-4a-1d-0b" Then
WshShell.Run chr(34) & LogonServer & "\Netlogon\Software\Bginfo\Bginfo.exe " & chr(34) & LogonServer & "\Netlogon\Software\Bginfo\BG_UITWIJK.bgi /timer:0 /nolicprompt" & chr(34), 1, True
MsgBox "Je bent ingelogd op het TEST Netwerk3"
Else
'MsgBox "not ok"
End If