Usuário com melhor resposta
mapear impressora ao logar na rede

Pergunta
-
Galera,
Segue abaixo meu scrip. Quero que o usuário logar no domínio seja mapeado a impressora para ele. Não sei como fazer isso, tentei usar alguns scripts postados anteriormente mas sem sucesso. o exemplo que podem me ajudar é com o meu usuário ficticio e impressora. Pertenco ao grupo GSTI e a impressora a ser mapeada para meu usuário está em \\10.1.0.4\ADM02
Podem me ajudar por favor.
[]'s
Ricardo
Respostas
-
Olá galera,
Faltou meu script:
ON ERROR RESUME NEXTDim WSHShell, WSHNetwork, objDomain, DomainString, UserString, UserObj, Path
Set WSHShell = CreateObject("WScript.Shell")
Set WSHNetwork = CreateObject("WScript.Network")
'Automatically find the domain name
Set objDomain = getObject("LDAP://rootDse")
DomainString = objDomain.Get("dnsHostName")'Grab the user name
UserString = WSHNetwork.UserName
'Bind to the user object to get user name and check for group memberships later
Set UserObj = GetObject("WinNT://" & DomainString & "/" & UserString)'Grab the computer name for use in add-on code later
strComputer = WSHNetwork.ComputerName
'Synchronizes the time with Server our NTP Server
WSHShell.Run "NET TIME \\srvcmaa /set /y"
'WSHShell.Run "\\srvcmaa\ofcscan\autopcc.exe"
'Map drives needed by all
'Note the first command uses the user name as a variable to map to a user share.
'WSHNetwork.MapNetworkDrive "H:", "\\server\users\" & UserString,True
WSHNetwork.MapNetworkDrive "P:", "\\srvcmaa\publico",True
'WSHNetwork.MapNetworkDrive "H:", "\\srvcmaa\software",True
WSHNetwork.MapNetworkDrive "J:", "\\srvcmaa\sistemas",True
WSHNetwork.MapNetworkDrive "l:", "\\srvcmaa\f2c",True'Now check for group memberships and map appropriate drives
For Each GroupObj In UserObj.Groups
Select Case GroupObj.Name
'Check for group memberships and take needed action
'In this example below, ADMIN and WORKERB are groups.
Case "GSDiretoria"
WSHNetwork.MapNetworkDrive "I:", "\\srvcmaa\diretoria",TrueCase "GSAgricola"
WSHNetwork.MapNetworkDrive "I:", "\\srvcmaa\agricola",True
Case "GSAdministrativo"
WSHNetwork.MapNetworkDrive "I:", "\\srvcmaa\administrativo",TrueCase "GSJuridico"
WSHNetwork.MapNetworkDrive "I:", "\\srvcmaa\juridico",True
Case "GSFinanceiro"
WSHNetwork.MapNetworkDrive "I:", "\\srvcmaa\financeiro",TrueCase "GSIndustrial"
WSHNetwork.MapNetworkDrive "I:", "\\srvcmaa\industrial",TrueCase "GSRh"
WSHNetwork.MapNetworkDrive "I:", "\\srvcmaa\rh",TrueCase "GSContabilidade"
WSHNetwork.MapNetworkDrive "I:", "\\srvcmaa\contabilidade",TrueCase "GSTI"
WSHNetwork.MapNetworkDrive "I:", "\\srvcmaa\ti",TrueCase "GSSeguranca_trabalho"
WSHNetwork.MapNetworkDrive "I:", "\\srvcmaa\sesmt",TrueCase "GSSuprimentos"
WSHNetwork.MapNetworkDrive "I:", "\\srvcmaa\suprimentos",True' Case "GSAdmAgricola"
' WSHNetwork.MapNetworkDrive "K:", "\\srvcmaa\admagricola",TrueCase "GSJuridicoAgricola"
WSHNetwork.MapNetworkDrive "K:", "\\srvcmaa\juridicoagricola",TrueCase "GSFinanContabil"
WSHNetwork.MapNetworkDrive "K:", "\\srvcmaa\financontabil",True' Case "GSProjeto"
' WSHNetwork.MapNetworkDrive "L:", "\\srvcmaa\financontabil",True
End Select
Next'Add On Code goes below this line
'=====================================
' This section of script will prevent the balloon window
' that appears when printing to a network shared printer
' after XP Service Pack 2 is installed.
'====================================='Path = "HKCU\Printers\Settings\EnableBalloonNotificationsRemote"
'WshShell.RegWrite Path, 0 ,"REG_DWORD"' This Add On demonstates the Microsoft Speach API (SAPI)
'=====================================
' Dim oVo
' Set oVo = Wscript.CreateObject("SAPI.SpVoice")
' oVo.speak "Bom Trabalho " & WSHNetwork.username'=====================================
'Add On Code goes above this line'Clean Up Memory We Used
set UserObj = Nothing
set GroupObj = Nothing
set WSHNetwork = Nothing
set DomainString = Nothing
set WSHSHell = Nothing
Set WSHPrinters = Nothing
'Quit the Script
wscript.quit
Jesiel este é meu script, pode me ajudar onde eu coloco as informações que me passou??
Exemplo, trecho retirado..
For Each GroupObj In UserObj.Groups
Select Case GroupObj.Name
'Check for group memberships and take needed action
'In this example below, ADMIN and WORKERB are groups.
Case "GSDiretoria"
WSHNetwork.MapNetworkDrive "I:", "\\srvcmaa\diretoria",True
WSHNetwork.AddWindowsPrinterConnection "\\ServidordeImpressao\HP2180"
WSHNetwork.SetDefaultPrinter "\\ServidordeImpressao\HP2180"
Case "GSAgricola"
WSHNetwork.MapNetworkDrive "I:", "\\srvcmaa\agricola",True
WSHNetwork.AddWindowsPrinterConnection "\\ServidordeImpressao\HP2015"
WSHNetwork.SetDefaultPrinter "\\ServidordeImpressao\HP2015"
Poste os resultados!
[]s,
" Qm tem boca vai a roma, meu fogão tem 6 e não saiu da cozinha ainda"- Marcado como Resposta Fábio JrModerator sábado, 3 de dezembro de 2011 13:21
Todas as Respostas
-
Olá,
Verifique o script abaixo:
Option Explicit
Dim objNetwork, strAntiga, strNova
'VARIAVEIS QUE PRECISA ALTERAR
strImpressora = "\\eduardo\cpd"
Set objNetwork = CreateObject("WScript.Network")
'CONECTA A NOVA IMPRESSORA (TEM QUE TER O DRIVER INSTALADO)
ObjNetWork.AddWindowsPrinterConnection strImpressora
'DEIXA A NOVA IMPRESSORA COMO PADRAO
objNetwork.SetDefaultPrinter strImpressora
Até mais,
Jesiel
Obs.: Se útil, classifique
- Sugerido como Resposta Marcellus Bockorny sexta-feira, 4 de dezembro de 2009 12:04
-
Galera,
Segue abaixo meu scrip. Quero que o usuário logar no domínio seja mapeado a impressora para ele. Não sei como fazer isso, tentei usar alguns scripts postados anteriormente mas sem sucesso. o exemplo que podem me ajudar é com o meu usuário ficticio e impressora. Pertenco ao grupo GSTI e a impressora a ser mapeada para meu usuário está em \\10.1.0.4\ADM02
Podem me ajudar por favor.
[]'s
Ricardo
Caso precise de uma solução por Grupos veja o exemplo o link abaixo.
http://social.technet.microsoft.com/Forums/pt-BR/scriptadminpt/thread/3fbd7b32-ce54-4afa-a5f6-b7ec5f8b3348
Poste os resultados
[]s,
" Qm tem boca vai a roma, meu fogão tem 6 e não saiu da cozinha ainda" -
Olá galera,
Faltou meu script:
ON ERROR RESUME NEXTDim WSHShell, WSHNetwork, objDomain, DomainString, UserString, UserObj, Path
Set WSHShell = CreateObject("WScript.Shell")
Set WSHNetwork = CreateObject("WScript.Network")
'Automatically find the domain name
Set objDomain = getObject("LDAP://rootDse")
DomainString = objDomain.Get("dnsHostName")'Grab the user name
UserString = WSHNetwork.UserName
'Bind to the user object to get user name and check for group memberships later
Set UserObj = GetObject("WinNT://" & DomainString & "/" & UserString)'Grab the computer name for use in add-on code later
strComputer = WSHNetwork.ComputerName
'Synchronizes the time with Server our NTP Server
WSHShell.Run "NET TIME \\srvcmaa /set /y"
'WSHShell.Run "\\srvcmaa\ofcscan\autopcc.exe"
'Map drives needed by all
'Note the first command uses the user name as a variable to map to a user share.
'WSHNetwork.MapNetworkDrive "H:", "\\server\users\" & UserString,True
WSHNetwork.MapNetworkDrive "P:", "\\srvcmaa\publico",True
'WSHNetwork.MapNetworkDrive "H:", "\\srvcmaa\software",True
WSHNetwork.MapNetworkDrive "J:", "\\srvcmaa\sistemas",True
WSHNetwork.MapNetworkDrive "l:", "\\srvcmaa\f2c",True'Now check for group memberships and map appropriate drives
For Each GroupObj In UserObj.Groups
Select Case GroupObj.Name
'Check for group memberships and take needed action
'In this example below, ADMIN and WORKERB are groups.
Case "GSDiretoria"
WSHNetwork.MapNetworkDrive "I:", "\\srvcmaa\diretoria",TrueCase "GSAgricola"
WSHNetwork.MapNetworkDrive "I:", "\\srvcmaa\agricola",True
Case "GSAdministrativo"
WSHNetwork.MapNetworkDrive "I:", "\\srvcmaa\administrativo",TrueCase "GSJuridico"
WSHNetwork.MapNetworkDrive "I:", "\\srvcmaa\juridico",True
Case "GSFinanceiro"
WSHNetwork.MapNetworkDrive "I:", "\\srvcmaa\financeiro",TrueCase "GSIndustrial"
WSHNetwork.MapNetworkDrive "I:", "\\srvcmaa\industrial",TrueCase "GSRh"
WSHNetwork.MapNetworkDrive "I:", "\\srvcmaa\rh",TrueCase "GSContabilidade"
WSHNetwork.MapNetworkDrive "I:", "\\srvcmaa\contabilidade",TrueCase "GSTI"
WSHNetwork.MapNetworkDrive "I:", "\\srvcmaa\ti",TrueCase "GSSeguranca_trabalho"
WSHNetwork.MapNetworkDrive "I:", "\\srvcmaa\sesmt",TrueCase "GSSuprimentos"
WSHNetwork.MapNetworkDrive "I:", "\\srvcmaa\suprimentos",True' Case "GSAdmAgricola"
' WSHNetwork.MapNetworkDrive "K:", "\\srvcmaa\admagricola",TrueCase "GSJuridicoAgricola"
WSHNetwork.MapNetworkDrive "K:", "\\srvcmaa\juridicoagricola",TrueCase "GSFinanContabil"
WSHNetwork.MapNetworkDrive "K:", "\\srvcmaa\financontabil",True' Case "GSProjeto"
' WSHNetwork.MapNetworkDrive "L:", "\\srvcmaa\financontabil",True
End Select
Next'Add On Code goes below this line
'=====================================
' This section of script will prevent the balloon window
' that appears when printing to a network shared printer
' after XP Service Pack 2 is installed.
'====================================='Path = "HKCU\Printers\Settings\EnableBalloonNotificationsRemote"
'WshShell.RegWrite Path, 0 ,"REG_DWORD"' This Add On demonstates the Microsoft Speach API (SAPI)
'=====================================
' Dim oVo
' Set oVo = Wscript.CreateObject("SAPI.SpVoice")
' oVo.speak "Bom Trabalho " & WSHNetwork.username'=====================================
'Add On Code goes above this line'Clean Up Memory We Used
set UserObj = Nothing
set GroupObj = Nothing
set WSHNetwork = Nothing
set DomainString = Nothing
set WSHSHell = Nothing
Set WSHPrinters = Nothing
'Quit the Script
wscript.quit
Jesiel este é meu script, pode me ajudar onde eu coloco as informações que me passou?? -
Olá galera,
Faltou meu script:
ON ERROR RESUME NEXTDim WSHShell, WSHNetwork, objDomain, DomainString, UserString, UserObj, Path
Set WSHShell = CreateObject("WScript.Shell")
Set WSHNetwork = CreateObject("WScript.Network")
'Automatically find the domain name
Set objDomain = getObject("LDAP://rootDse")
DomainString = objDomain.Get("dnsHostName")'Grab the user name
UserString = WSHNetwork.UserName
'Bind to the user object to get user name and check for group memberships later
Set UserObj = GetObject("WinNT://" & DomainString & "/" & UserString)'Grab the computer name for use in add-on code later
strComputer = WSHNetwork.ComputerName
'Synchronizes the time with Server our NTP Server
WSHShell.Run "NET TIME \\srvcmaa /set /y"
'WSHShell.Run "\\srvcmaa\ofcscan\autopcc.exe"
'Map drives needed by all
'Note the first command uses the user name as a variable to map to a user share.
'WSHNetwork.MapNetworkDrive "H:", "\\server\users\" & UserString,True
WSHNetwork.MapNetworkDrive "P:", "\\srvcmaa\publico",True
'WSHNetwork.MapNetworkDrive "H:", "\\srvcmaa\software",True
WSHNetwork.MapNetworkDrive "J:", "\\srvcmaa\sistemas",True
WSHNetwork.MapNetworkDrive "l:", "\\srvcmaa\f2c",True'Now check for group memberships and map appropriate drives
For Each GroupObj In UserObj.Groups
Select Case GroupObj.Name
'Check for group memberships and take needed action
'In this example below, ADMIN and WORKERB are groups.
Case "GSDiretoria"
WSHNetwork.MapNetworkDrive "I:", "\\srvcmaa\diretoria",TrueCase "GSAgricola"
WSHNetwork.MapNetworkDrive "I:", "\\srvcmaa\agricola",True
Case "GSAdministrativo"
WSHNetwork.MapNetworkDrive "I:", "\\srvcmaa\administrativo",TrueCase "GSJuridico"
WSHNetwork.MapNetworkDrive "I:", "\\srvcmaa\juridico",True
Case "GSFinanceiro"
WSHNetwork.MapNetworkDrive "I:", "\\srvcmaa\financeiro",TrueCase "GSIndustrial"
WSHNetwork.MapNetworkDrive "I:", "\\srvcmaa\industrial",TrueCase "GSRh"
WSHNetwork.MapNetworkDrive "I:", "\\srvcmaa\rh",TrueCase "GSContabilidade"
WSHNetwork.MapNetworkDrive "I:", "\\srvcmaa\contabilidade",TrueCase "GSTI"
WSHNetwork.MapNetworkDrive "I:", "\\srvcmaa\ti",TrueCase "GSSeguranca_trabalho"
WSHNetwork.MapNetworkDrive "I:", "\\srvcmaa\sesmt",TrueCase "GSSuprimentos"
WSHNetwork.MapNetworkDrive "I:", "\\srvcmaa\suprimentos",True' Case "GSAdmAgricola"
' WSHNetwork.MapNetworkDrive "K:", "\\srvcmaa\admagricola",TrueCase "GSJuridicoAgricola"
WSHNetwork.MapNetworkDrive "K:", "\\srvcmaa\juridicoagricola",TrueCase "GSFinanContabil"
WSHNetwork.MapNetworkDrive "K:", "\\srvcmaa\financontabil",True' Case "GSProjeto"
' WSHNetwork.MapNetworkDrive "L:", "\\srvcmaa\financontabil",True
End Select
Next'Add On Code goes below this line
'=====================================
' This section of script will prevent the balloon window
' that appears when printing to a network shared printer
' after XP Service Pack 2 is installed.
'====================================='Path = "HKCU\Printers\Settings\EnableBalloonNotificationsRemote"
'WshShell.RegWrite Path, 0 ,"REG_DWORD"' This Add On demonstates the Microsoft Speach API (SAPI)
'=====================================
' Dim oVo
' Set oVo = Wscript.CreateObject("SAPI.SpVoice")
' oVo.speak "Bom Trabalho " & WSHNetwork.username'=====================================
'Add On Code goes above this line'Clean Up Memory We Used
set UserObj = Nothing
set GroupObj = Nothing
set WSHNetwork = Nothing
set DomainString = Nothing
set WSHSHell = Nothing
Set WSHPrinters = Nothing
'Quit the Script
wscript.quit
Jesiel este é meu script, pode me ajudar onde eu coloco as informações que me passou??
Exemplo, trecho retirado..
For Each GroupObj In UserObj.Groups
Select Case GroupObj.Name
'Check for group memberships and take needed action
'In this example below, ADMIN and WORKERB are groups.
Case "GSDiretoria"
WSHNetwork.MapNetworkDrive "I:", "\\srvcmaa\diretoria",True
WSHNetwork.AddWindowsPrinterConnection "\\ServidordeImpressao\HP2180"
WSHNetwork.SetDefaultPrinter "\\ServidordeImpressao\HP2180"
Case "GSAgricola"
WSHNetwork.MapNetworkDrive "I:", "\\srvcmaa\agricola",True
WSHNetwork.AddWindowsPrinterConnection "\\ServidordeImpressao\HP2015"
WSHNetwork.SetDefaultPrinter "\\ServidordeImpressao\HP2015"
Poste os resultados!
[]s,
" Qm tem boca vai a roma, meu fogão tem 6 e não saiu da cozinha ainda"- Marcado como Resposta Fábio JrModerator sábado, 3 de dezembro de 2011 13:21
-
Segue o script abaixo altere as impressoras e salve com vbs ;
Set WshNetwork = CreateObject("WScript.Network") WshNetwork.AddWindowsPrinterConnection "\\debrfsba1\debrprbaits1" WshNetwork.SetDefaultPrinter "\\debrfsba1\debrprbaits1"
Denis Faustino