Mapping Drives

I need to map three drives for users in a specific department

We have a VBS script that maps these drives if dropped inside the STARTUP of the All Users folder of every machine in that department.

My question is if their is an easy way to get the VBS in the startup folder of the All Users profile on every machine so that when anybody logs on it will map these three drives.

I would map the drive in ADUC but for some reason it only supports one drive.

Can someone help me out?
snyderkvAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ryansotoCommented:
Duplicate question my answer is also in the other thread


No ADUC supports any amount really.
Create a batch file in the batch file have something like below.
Once you have that batch file then stick it in the \\server\SYSVOL\domain\scripts
Now in ADUC you go to the profile tab then type the name of the script (no need to type the location)

@Echo Off
 
REM **** Map Network Drives
 
net use x: /delete
net use s: /delete
net use q: /delete
net use s: \\server\shared
net use q: \\server\acctg
net use x: \\server\hr
 
 
    

Open in new window

0
olifaragoCommented:
Or to use your existing VBS script:

1. Create a batch file in the NETLOGON directory of your DC (mylogonscript.bat).
2. From the logon script call your VBS script using the WSCRIPT command.
3. In the logon script section of the user in AD enter mylogonscript.bat

Now the batch file will load for the user which will cann the VBS script.

Hope this helps, let me know if you need more info,
Oli
0
snyderkvAuthor Commented:
Sorry I forgot to mention that I cannot drop anything into the SYSVOL or use GPO

I have to do this via scripts on the local machines or servers.

Like I said the VBS works on my local machine when you double click on it. I'm wondering how i can get this to run for all users when logging into any machine. I would think the only way is to somehow run a script that copies it to all machines startup folder
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

RobSampsonCommented:
As posted in:http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_23146399.html

Why can't you use Group Policy?  That's what Active Directory is for.....

You would just place your VBS file into
User Configuration/Windows Settings/Scripts/Logon

Regards,

Rob.
0
olifaragoCommented:
Ok, but my solution doesnt use sysvol or GPO, any good?

0
ryansotoCommented:
@ olifarago
If he can write to the netlogon why cant he write to the sysvol would be my question.
0
olifaragoCommented:
It's a fine point but surely it is always best to go with the simplest options and we have not been told otherwise so why make the assumption?  
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
snyderkvAuthor Commented:
No your ansewer does imply SYSVOL because you said NETLOGON and thats pretty much the same thing.

My question is how can I copy using a VBS or BATCh, a VBS script to the startup folder of all the machines in the All Users folder?

Thats my question. I don't care if using a domain controller is easier I'm asking how to do this specifically without using a domain controller.
0
olifaragoCommented:
OK, well without getting into symantics, to answer your question just using script I would need to know.

Are you in a domain environent? If so are you a domain admin?
If it is not all the PCs you want to apply this to then are all the machines in this department in the same OU?
0
RobSampsonCommented:
OK, do you have admin access to the C$ share of your computers?

If so, run this script. It will get all computers from your current domain, and copy the file specified by strFileToCopy into the StartUp folder of each computer.

'===============
strFileToCopy = "C:\Temp\MyVBS.vbs"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objNetwork = CreateObject("WScript.Network")
Set objComputers = GetObject("WinNT://" & objNetwork.UserDomain)
objComputers.Filter = Array("Computer")
For Each objComputer In objComputers
      strTargetDir = "\\" & objComputer.Name & "\C$\Documents and Settings\All Users\Start Menu\Programs\StartUp\"
      If objFSO.FolderExists(strTargetDir) Then objFSO.CopyFile strFileToCopy, strTargetDir, True
Next
MsgBox "Done"
'===============

Regards,

Rob.
0
olifaragoCommented:
Exactly, this is where I was going, and if it is not the whole domain and just a department then you could modify this script to filter just computers from a single OU.
0
snyderkvAuthor Commented:
Awsome man that would work. It's not every computer in the domain it's only in a specified OU. Could you please modify it to include the OU distinguished name? Once I see that I can easily modify it for each invididual department.

Thanks a lot
0
snyderkvAuthor Commented:
Olif,

Right thats what I just asked before I saw your comment

Could you or someone add this piece in the script so I can easily modify it for other departments?
Thanks a lot
0
RobSampsonCommented:
Using the WinNT provider you don't see the OU (unless you use NameTranslate), so you'd have to use an LDAP function.....olifarago, do you want to take it from here, or shall I continue?

Regards,

Rob.
0
olifaragoCommented:
:) You started and I really need to go to bed so go for it!

snyderkvm good luck with it all.

o
0
snyderkvAuthor Commented:
Stop arguing just do it :)

Thanks and get some sleep Your all a bunch of rock stars in my book
0
RobSampsonCommented:
Ok then, try this script.  Change this line
strOUPath = "ou=test computers,ou=computers,ou=civic centre,ou=sites,"

to match the target OU you're after, including the trailing comma on it.

And change this:
strFileToCopy = "C:\Temp\MyVBS.vbs"

to point to the file you need to copy there.

Also uncomment this line
'objFSO.CopyFile strFileToCopy, strTargetDir, True

when you're ready to actually copy the files....as it won't copy it with that commented out.

'==============
If Right(LCase(WScript.FullName), 11) = "wscript.exe" Then
      Set objShell = CreateObject("WScript.Shell")
      objShell.Run "cmd /k cscript """ & WScript.ScriptFullName & """", 1, False
      Set objShell = Nothing
      WScript.Quit
End If

strFileToCopy = "C:\Temp\MyVBS.vbs"

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set adoCommand = CreateObject("ADODB.Command")
Set adoConnection = CreateObject("ADODB.Connection")
adoConnection.Provider = "ADsDSOObject"
adoConnection.Open "Active Directory Provider"
adoCommand.ActiveConnection = adoConnection

 ' Search entire Active Directory domain.
Set objRootDSE = GetObject("LDAP://RootDSE")

strDNSDomain = objRootDSE.Get("defaultNamingContext")
strOUPath = "ou=test computers,ou=computers,ou=civic centre,ou=sites,"
strBase = "<LDAP://" & strOUPath & strDNSDomain & ">"

strFilter = "(&(objectClass=computer))"
'strFilter = "(&(objectClass=computer)(cn=" & strComputer & "))"

' Comma delimited list of attribute values to retrieve.
'strAttributes = "sAMAccountName,cn"
strAttributes = "distinguishedName"

' Construct the LDAP syntax query.
strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
adoCommand.CommandText = strQuery
adoCommand.Properties("Page Size") = 100
adoCommand.Properties("Timeout") = 30
adoCommand.Properties("Cache Results") = False

' Run the query.
Set adoRecordset = adoCommand.Execute
 
' Enumerate the resulting recordset.
Do Until adoRecordset.EOF
    ' Retrieve values and display.
      strDN = adoRecordset.Fields("distinguishedName").Value
      strComputerName = Mid(strDN, 4, InStr(strDN, ",") - 4)
      If Ping(strComputerName) = True Then
            Set objFSO = CreateObject("Scripting.FileSystemObject")
            strTargetDir = "\\" & strComputerName & "\C$\Documents and Settings\All Users\Start Menu\Programs\StartUp\"
            If objFSO.FolderExists(strTargetDir) Then
                  WScript.Echo "Copying " & strFileToCopy & " to " & strTargetDir
                  'objFSO.CopyFile strFileToCopy, strTargetDir, True
            Else
                  WScript.Echo "Could not find " & strTargetDir
            End If
      Else
            WScript.Echo "Could not ping " & strComputerName
      End If

    ' Move to the next record in the recordset.
    adoRecordset.MoveNext
Loop

' Clean up.
adoRecordset.Close
Set adoRecordset = Nothing

adoConnection.Close

WScript.Echo "Done"

Function Ping(strComputer)
      Dim objShell, boolCode
      Set objShell = CreateObject("WScript.Shell")
      boolCode = objShell.Run("Ping -n 1 -w 300 " & strComputer, 0, True)
      If boolCode = 0 Then
            Ping = True
      Else
            Ping = False
      End If
End Function
'==============

Regards,

Rob.
0
snyderkvAuthor Commented:
Got it

Thanks again
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Active Directory

From novice to tech pro — start learning today.