Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Logon Script

Reply
 
Old 10-08-2008   #1 (permalink)
Martín Companucci


 
 

Logon Script

Buenas tardes,

Necesito ayuda para realizar un script que me permita seleccionar en usuario
que se logonea y que proceda de una determinada manera según quien se
logonee.
Ej:

Si es el usuario "juan" entonces
mapea h: \\servidor\home
mapea x: \\servidor\compras
fin si

Si es el usuario "pedro" entonces
mapea h: \\servidor\home
mapea p: \\servidor\servicios
fin sin

Muchas gracias!
Martín.



My System SpecsSystem Spec
Old 10-08-2008   #2 (permalink)
Pegasus \(MVP\)


 
 

Re: Logon Script


"Martín Companucci" <companucci@xxxxxx> wrote in message
news:64135B8E-4BE3-4A7A-A536-BBECD55A522D@xxxxxx
Quote:

> Buenas tardes,
>
> Necesito ayuda para realizar un script que me permita seleccionar en
> usuario
> que se logonea y que proceda de una determinada manera según quien se
> logonee.
> Ej:
>
> Si es el usuario "juan" entonces
> mapea h: \\servidor\home
> mapea x: \\servidor\compras
> fin si
>
> Si es el usuario "pedro" entonces
> mapea h: \\servidor\home
> mapea p: \\servidor\servicios
> fin sin
>
> Muchas gracias!
> Martín.
>
There are many ways to map shares based on user names. Here is a batch file
solution. It assumes that user JDoe has a share called \\Server\JDoe and
that user ASmith has a share \\Server\ASmith.

1. In your logon script you insert these lines:
@echo off
net use h: \\Server\home
if exist \\Server\%UserName%\netlogon\netlogon.bat call
\\Server\%UserName%\netlogon\netlogon.bat

2. You create this file, here shown for user JDoe:
\\Server\JDoe\netlogon\netlogon.bat
Inside this file you put the user-specific share commands:
net use P: \\Server\servicios
net use S: \\Server\sales
etc.

3. If you wish then you can hide the folder \\Server\JDoe\netlogon\.


My System SpecsSystem Spec
Old 10-09-2008   #3 (permalink)
heintz.larry


 
 

Re: Logon Script

On Oct 8, 2:27*pm, "Martín Companucci" <companu...@xxxxxx> wrote:
Quote:

> Buenas tardes,
>
> Necesito ayuda para realizar un script que me permita seleccionar en usuario
> que se logonea y que proceda de una determinada manera según quien se
> logonee.
> Ej:
>
> Si es el usuario "juan" entonces
> * * *mapea h: \\servidor\home
> * * *mapea x: \\servidor\compras
> fin si
>
> Si es el usuario "pedro" entonces
> * * mapea h: \\servidor\home
> * * mapea p: \\servidor\servicios
> fin sin
>
> Muchas gracias!
> Martín.
Try this you just need change the StrHData,StrPData,StrXData
varaiables for s vbscript solution

On Error Resume Next
'// Dims Variables
Dim objFSO,objSysInfo
Dim WshNetwork,WshShell
Dim strUserDN,strDrive
'// Sets Stuff
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objSysInfo = CreateObject("ADSystemInfo")
set WshNetwork = CreateObject("Wscript.Network")
Set WshShell = CreateObject("WScript.Shell")
strUserDN = WshNetwork.username
strHDrive = "H:"
StrHData = "\\servidor\home"
strXDrive = "X:"
StrXData = "\\servidor\compras"
strPDrive = "P:"
StrPData = "\\servidor\servicios"

'Call debug 'Used to debug user login information

''''''''' Starts Login Script '''''''''
if strUserDN = "juan" then
WshNetwork.RemoveNetworkDrive strHDrive 'Removes H Network Drive
Upon Login
WshNetwork.MapNetworkDrive strHDrive, strHData 'Adds H Network
Drive Upon Login
WshNetwork.RemoveNetworkDrive strXDrive 'Removes X Network Drive
Upon Login
WshNetwork.MapNetworkDrive strXDrive, strXData 'Adds X Network
Drive Upon Login
elseif strUserDN = "pedro" then
WshNetwork.RemoveNetworkDrive strHDrive 'Removes H Network Drive
Upon Login
WshNetwork.MapNetworkDrive strHDrive, strHData 'Adds H Network
Drive Upon Login
WshNetwork.RemoveNetworkDrive strPDrive 'Removes X Network Drive
Upon Login
WshNetwork.MapNetworkDrive strPDrive, strPData 'Adds X Network
Drive Upon Login
end if

Function debug
wscript.echo "Username: " & strUserDN
wscript.echo "UserPath: WinNT://" & strADDN & "/" & strGroupDN
End Function

'// Closes Stuff
Set objFSO = Nothing
Set objSysInfo = Nothing
set WshNetwork = Nothing
Set WshShell = Nothing
My System SpecsSystem Spec
Old 10-09-2008   #4 (permalink)
James Whitlow


 
 

Re: Logon Script

"Martín Companucci" <companucci@xxxxxx> wrote in message
news:64135B8E-4BE3-4A7A-A536-BBECD55A522D@xxxxxx
Quote:

> Buenas tardes,
>
> Necesito ayuda para realizar un script que me permita seleccionar en
> usuario
> que se logonea y que proceda de una determinada manera según quien se
> logonee.
> Ej:
>
> Si es el usuario "juan" entonces
> mapea h: \\servidor\home
> mapea x: \\servidor\compras
> fin si
>
> Si es el usuario "pedro" entonces
> mapea h: \\servidor\home
> mapea p: \\servidor\servicios
> fin sin
You could add your mapping to a dictionary object and then use this to
map your drive. Try the code below as an example:

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Option Explicit

Dim oWNT, oFSO, oDrives, sUsername, sDrive, sPath, sMapping

Set oWNT = CreateObject("WScript.Network")
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oDrives = CreateObject("Scripting.Dictionary")
oDrives.CompareMode = 1 'Case insensitive text compare

' Add your users to the dictionary. Separate mappings
' with the pipe (|) symbol
'____________________________________________________________
oDrives("juan") = "H:/Home|X:\\servidor\compras"
oDrives("pedro") = "H:/Home|P:\\servidor\servicios"
'¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

sUsername = oWNT.Username

For Each sMapping in Split(oDrives(sUsername), "|")
sDrive = Split(sMapping, ":")(0) & ":"
sPath = Split(sMapping, ":")(1)
If LCase(sPath) = "/home" Then sPath = FindHome(sUsername)
If oFSO.DriveExists(sDrive) Then
If oFSO.GetDrive(sDrive).DriveType = 3 Then
oWNT.RemoveNetworkDrive sDrive, True
End If
End If
oWNT.MapNetworkDrive sDrive, sPath, False
Next

Function FindHome(ByVal sUsername)
Dim oWSH, sDomain, oUser
Set oWSH = CreateObject("WScript.Shell")
sDomain = oWSH.Environment("Process").Item("UserDomain")
Set oUser = GetObject("WinNT://" & sDomain & "/" & sUsername)
FindHome = oUser.HomeDirectory
End Function
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


My System SpecsSystem Spec
Old 10-16-2008   #5 (permalink)
Martín


 
 

Re: Logon Script

Thanks for your help!



"Martín Companucci" <companucci@xxxxxx> escribió en el mensaje de
noticias:64135B8E-4BE3-4A7A-A536-BBECD55A522D@xxxxxx
| Buenas tardes,
|
| Necesito ayuda para realizar un script que me permita seleccionar en
usuario
| que se logonea y que proceda de una determinada manera según quien se
| logonee.
| Ej:
|
| Si es el usuario "juan" entonces
| mapea h: \\servidor\home
| mapea x: \\servidor\compras
| fin si
|
| Si es el usuario "pedro" entonces
| mapea h: \\servidor\home
| mapea p: \\servidor\servicios
| fin sin
|
| Muchas gracias!
| Martín.
|
|


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Logon script PowerShell
Logon Script Causing Laptops To Hang - Problems in script? VB Script
Logon script is not visible Vista networking & sharing
Logon Script - VBScript Vista General
Logon Script Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46