Use a política de grupo local.
caminho do script de login:
%windir%\system32\GroupPolicy\User\Scripts\Logon\
caminho do script de logoff:
%windir%\system32\GroupPolicy\User\Scripts\Logoff\
Caminho do script de inicialização:
%windir%\system32\GroupPolicy\Machine\Scripts\Startup\
Caminho do script de encerramento:
%windir%\system32\GroupPolicy\Machine\Scripts\Shutdown\
Adicionar chave de registro de logon:
regedit /s \PDC-Kerberos-Server-Samba\profiles\logon.reg
logon.reg:
[HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\System\Scripts]
[HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\System\Scripts\Logon]
[HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\System\Scripts\Logon dsquery * -filter "(samAccountName=Tcheburator)" -attr distinguishedName | more +1
]
"GPO-ID"="LocalGPO"
"SOM-ID"="Local"
"FileSysPath"="C:\WINDOWS\System32\GroupPolicy\User"
"DisplayName"="Local Group Policy"
"GPOName"="Local Group Policy"
[HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\System\Scripts\Logon CN=Tcheburator,OU=In App,OU=View App,DC=ht,DC=local
dsquery * -filter "(samAccountName=%username%)" -attr distinguishedName | more +1
]
"Script"="logon.bat"
"Parameters"=""
"ExecTime"=hex(b):00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
Script de logon GPO, modo GUI:
Melhormaneira: LabTracker
-
Crie um cenário comum que determinará o nome do usuário e as variáveis de ambiente, incluindo - departamento, se ele for levado ao servidor LDAP ou ao Active Directory.
-
Depois disso, neste cenário, com base nos dados, chame outros scripts. Abaixo estão exemplos de determinar o entorno do usuário. Nesses dados, você pode criar as condições necessárias para executar scripts.
-
Roteiro de chamadas forma o ambiente do usuário.
A melhor opção, na minha opinião, WSH (vbscript), mas você também pode usar somente comandos.
Se você precisa de uma plataforma cruzada, o python, o perl e o java estão bem em todos os sistemas operacionais.
DN do usuário de consulta real:
dsquery user -samid %username% | dsget user -memberof | dsget group -sid -samid
Output, (OU - Orgainazation Unit):
dsquery user -samid %username% | dsget user -memberof -expand | dsget group -sid -samid
consulta no DN do usuário do script:
dsquery user -samid Tcheburator | dsget user -memberof | dsget group -sid -samid
consulta no grupo de usuários de script:
samid sid
Nected Tche S-1-5-21-2191659736-2261162383-3034376108-1153
Tche S-1-5-21-2191659736-2261162383-3034376108-1152
Domain Users S-1-5-21-2191659736-2261162383-3034376108-513
dsget succeeded
consulta no usuário do script Grupos de aninhamento:
dsquery user -samid Tcheburator | dsget user -memberof -expand | dsget group -sid -samid
amostra real, grupo de usuários de consulta:
samid sid
Nected Tche S-1-5-21-2191659736-2261162383-3034376108-1153
Tche S-1-5-21-2191659736-2261162383-3034376108-1152
Domain Users S-1-5-21-2191659736-2261162383-3034376108-513
DHCP Administrators S-1-5-21-2191659736-2261162383-3034376108-1129
dsget succeeded
Saída:
dsquery * -filter "(samAccountName=Tcheburator)" -attr name objectSid msNPAllowDialin adminCount whenChanged whenCreated department l telephoneNumber
amostra real, usuário de consulta Grupos de aninhamento:
name objectSid msNPAllowDialin adminCount whenChanged whenCreated department l telephoneNumber
Tcheburator S-1-5-21-2191659736-2261162383-3034376108-1151 06/12/2013 14:53:08 06/12/2013 10:18:36 View IT New Vasyki (322) 223-322
Saída:
dsquery * -filter "(samAccountName=Tcheburator)" -attr *
departamento de consulta:
wmic OS get Caption, Version, BuildNumber, CSDVersion, CodeSet, CSName, LocalDateTime
Saída:
BuildNumber Caption CodeSet CSDVersion CSName LocalDateTime Version
3790 Microsoft(R) Windows(R) Server 2003 Enterprise x64 Edition 1251 Service Pack 2 W2K3R2VIRT-2ECA 20130612191856.656000+240 5.2.3790
consulta tudo:
wmic os get BootDevice,BuildNumber,CSDVersion,Version,CSName,InstallDate,LastBootUpTime,OSLanguage,Locale,SystemDevice,SystemDirectory,SystemDrive
obter sistema operacional, service pack, nome do computador:
wmic nicconfig get MACAddress, IPAddress, IPSubnet, DefaultIPGateway, Index, ServiceName, Description, SettingID
Saída:
DefaultIPGateway Description Index IPAddress IPSubnet MACAddress ServiceName SettingID
RAS Async Adapter 1 AsyncMac {06CDF9C4-7DFE-4CF0-8DF4-08D86275188F}
WAN Miniport (L2TP) 2 Rasl2tp {2F53E6CE-FE90-41FF-9346-7FE854731431}
WAN Miniport (PPTP) 3 50:50:54:50:30:30 PptpMiniport {FA6F7372-8CCB-4DAC-9B74-51501B322F83}
WAN Miniport (PPPOE) 4 33:50:6F:45:30:30 RasPppoe {075EB914-2B27-42AA-8176-7A58987C7FA9}
Direct Parallel 5 Raspti {F992BAE1-1E06-4069-A8AE-6FFA487BC9CC}
WAN Miniport (IP) 6 NdisWan {61EC9DB7-4374-4917-B7DA-A9182B6332DE}
{"10.120.10.1"} Atheros AR8121/AR8113/AR8114 PCI-E Ethernet Controller 7 {"10.120.10.100"} {"255.255.240.0"} 6В:77:C7:7A:79:BB L1e {4EB8AC6D-15EE-4922-94F6-3FB0CED90635}
Broadcom 802.11g Network Adapter 8 BCM43XX {A245F36E-6EAA-4880-9CE1-A536C2F2A000}
Packet Scheduler Miniport 9 34:B3:20:52:41:53 {CE21D017-A6B3-4275-9BC5-3060B4F017A0}
VMware Virtual Ethernet Adapter for VMnet1 10 {"192.168.18.1"} {"255.255.255.0"} 00:50:56:C0:00:01 VMnetAdapter {EB270DB9-E2B1-4689-86BF-4CBC4E30A93B}
VMware Virtual Ethernet Adapter for VMnet8 11 {"192.168.232.1"} {"255.255.255.0"} 00:50:56:C0:00:08 VMnetAdapter {90EDFB26-FF76-4FF8-8E25-A847F7179F34}
Packet Scheduler Miniport 12 {A95F18B8-8423-4DDF-84C0-240BEF25B647}
1394 Net Adapter 13 NIC1394 {9C5F9D9E-9BA5-4C2F-AB8C-6A7EDC7A1C78}
TAP-Win32 Adapter V9 14 tap0901 {63D6E2AA-FDC6-41A4-B3CD-B3460D63A5E8}
Packet Scheduler Miniport 15 {7F4D8138-D586-4511-B737-7E05168430AB}
Windows Mobile-based Internet Sharing Device 16 usb_rndisx {3E7051D2-8097-4986-8EE3-E88F028C9E07}
Packet Scheduler Miniport 17 {3909CC6A-B904-4BEA-9CEE-E6801BFF4694}
Windows Mobile-based Internet Sharing Device 18 usb_rndisx {284F5467-6DE8-4398-9881-C22AEB44A0B7}
Packet Scheduler Miniport 19 {27EED4EC-0B03-4D39-B120-45C24E8BB0CE}
obter sistema operacional, service pack, nome do computador ... data de instalação, disco do sistema:
%windir%\system32\GroupPolicy\User\Scripts\Logon\
obtenha endereço IP, endereço MAC, GW ...:
%windir%\system32\GroupPolicy\User\Scripts\Logoff\
Saída:
%windir%\system32\GroupPolicy\Machine\Scripts\Startup\