Usuário com melhor resposta
Pular um IF / EndiF de um script

Pergunta
-
Pessoal, usamos o script de login.vbs abaixo e funciona certim. O problema está nos usuarios que usam Terminal Service (ou Citrix).
Na linha 31 do script é feita a instalação ou atualização do script, e essa parte não poderia ser executada nos servidores.
Queria saber se tem como colocar alguma condição do tipô:
1 - Se a estação que está logando estiver no grupo sem_antivirus, então pular esse IF/EndIF (linha 41 a 47) e continuar a executar o resto do script.
ou:
2 - Se o micro que está logando estiver na OU=Computers seguir com o script, Caso contrário abortar essa parte. (Os servidores estão em outra OU)
Tem como ?
1 Option Explicit
2
3 Dim objNetwork, objSysInfo, strUserDN
4 Dim objGroupList, objUser, objFSO
5 Dim strComputerDN, objComputer
6
7 Set objNetwork = CreateObject("Wscript.Network")
8 Set objFSO = CreateObject("Scripting.FileSystemObject")
9 Set objSysInfo = CreateObject("ADSystemInfo")
10 strUserDN = objSysInfo.userName
11 strComputerDN = objSysInfo.computerName
12
13 strUserDN = Replace(strUserDN, "/", "\/")
14 strComputerDN = Replace(strComputerDN, "/", "\/")
15
16 Set objUser = GetObject("LDAP://" & strUserDN)
17 Set objComputer = GetObject("LDAP://" & strComputerDN)
18
19 ' Mapear Drive F:.
20 ' Em caso de erro exibe um alerta.
21 'If (IsMember(objUser, "GR_FIN") = True) Then
22 If (MapDrive("F:", "\\server1\" & objUser.sAMAccountName) = False) Then
23 MsgBox "Não foi possível mapear o drive F:"
24 End If
25 'End If
26
27 If (IsMember(objUser, "setor2") = True) Then
28 objNetwork.AddWindowsPrinterConnection "\\printserver\xerox2"
29 End If
30
31 'Instalacao / Atualização da TREND
32 Dim fso
33 Dim trend
34 Dim trend1
35
36 Set fso = CreateObject("Scripting.FileSystemObject")
37 Set trend = CreateObject("Wscript.Shell")
38 Set trend1 = CreateObject("Wscript.Shell")
39
40 'Atualizando o antivírus
41 If (fso.FileExists("C:\Arquivos de programas\Trend Micro\OfficeScan Client\PccNTMon.exe")) Then
42 trend.run "\\server\ofcscan\Admin\Utility\IpXfer\ipXfer.exe -m 1 -s 10.10.5.15 -p 8080 -c 43652 -m1"
43 WScript.Quit()
44 Else
45 'Instalando o antivírus
46 trend1.run "\\server\ofcscan\install-trend.exe"
47 End If
48
49 Set trend=Nothing
50 Set trend1=Nothing
51
52 ' *****************
53
54 ' Clean up.
55 Set objNetwork = Nothing
56 Set objFSO = Nothing
57 Set objSysInfo = Nothing
58 Set objGroupList = Nothing
59 Set objUser = Nothing
60 Set objComputer = Nothing
61
62 Function IsMember(ByVal objADObject, ByVal strGroup)
63 If (IsEmpty(objGroupList) = True) Then
64 Set objGroupList = CreateObject("Scripting.Dictionary")
65 End If
66 If (objGroupList.Exists(objADObject.sAMAccountName & "\") = False) Then
67 Call LoadGroups(objADObject, objADObject)
68 objGroupList.Add objADObject.sAMAccountName & "\", True
69 End If
70 IsMember = objGroupList.Exists(objADObject.sAMAccountName & "\" _
71 & strGroup)
72 End Function
73
74 Function MapDrive(ByVal strDrive, ByVal strShare)
75 Dim objDrive
76
77 On Error Resume Next
78 If (objFSO.DriveExists(strDrive) = True) Then
79 Set objDrive = objFSO.GetDrive(strDrive)
80 If (Err.Number <> 0) Then
81 On Error GoTo 0
82 MapDrive = False
83 Exit Function
84 End If
85 If (objDrive.DriveType = 3) Then
86 objNetwork.RemoveNetworkDrive strDrive, True, True
87 Else
88 MapDrive = False
89 Exit Function
90 End If
91 Set objDrive = Nothing
92 End If
93 objNetwork.MapNetworkDrive strDrive, strShare
94 If (Err.Number = 0) Then
95 MapDrive = True
96 Else
97 Err.Clear
98 MapDrive = False
99 End If
100 On Error GoTo 0
101 End Function
102
Aldiko- Editado Aldiko terça-feira, 26 de maio de 2009 15:56 erro
Respostas
-
Olá,
São muitas maquinas que não irão receber o script???
Se for poucas, tente utilizar o array abaixo:
aNomes = Array("cpucontoso","dellnwtraders")Set WshNetwork = WScript.CreateObject("WScript.Network")
For x = 0 to UBOUND(aNomes)
if UCASE(aNomes(x)) <> UCASE(WshNetwork.ComputerName) Then
41 If (fso.FileExists("C:\Arquivos de programas\Trend Micro\OfficeScan Client\PccNTMon.exe")) Then
42 trend.run "\\server\ofcscan\Admin\Utility\IpXfer\ipXfer.exe -m 1 -s 10.10.5.15 -p 8080 -c 43652 -m1"
43 WScript.Quit()
44 Else
45 'Instalando o antivírus
46 trend1.run "\\server\ofcscan\install-trend.exe"
47 End If
exit FOR
Else
exit For
End if
Next
Deixei os numeros para ficar mais fácil pra você localizar onde colocar as linhas alteradas.
Faça os testes e nos retorne.
Até mais,
Jesiel
Obs.: Se útil, classifique- Editado Jesiel S. Pereira quarta-feira, 27 de maio de 2009 03:10
- Marcado como Resposta Fábio JrModerator quinta-feira, 19 de janeiro de 2012 00:23