Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Logon Script to delete Faves subfolder and copy new info from share

Status
Not open for further replies.

XYZdragon

Technical User
Dec 14, 2004
16
US
Hi I don't know much about scripting and the little I know is enough to do simple things like mapping a drive and printers and I do using a logon script regenarator. However, I will like to know if anybody can help me with this request. I will like to add the following routine to this script.

I will like the script to look into the following user's favorite folder and delete anything in a particular subfolder (see below). Then I will like the script to copy new info from a share folder into the favorite subfolder of users.

So

delete c:\Documents and Settings\%username%\Favorites\Links\MyCurrentprojects\*.*

Copy \\SERVER\SHARE\%USERNAME%\*.* c:\Documents and Settings\%username%\Favorites\Links\MyCurrentprojects\*.*

Thanks in advance to anybody that can help. Below is an example of the current scrip I use.

'Created: 10/10/2008 2:27:04 PM
'Author: DOMAIN\user
'Created by SAPIEN Technologies, Inc. Logon Script Generator
'**********************

On Error Resume Next
Dim objFSO,objFILE,objShell,objNetwork
set objFSO=CreateObject("Scripting.FileSystemObject")
set objShell=CreateObject("Wscript.Shell")
set objNetwork=CreateObject("Wscript.Network")


'Map network drives
MapIt "D:","\\FILE01\USERS\" & objNetwork.Username & ""
MapIt "D:","\\FILE02\Public"

'Map printers
AddPrinterConnection "\\Print01\HpLaserJ"
AddPrinterConnection "\\Print01\BrotherM"
objNetwork.SetDefaultPrinter "\\Print01\BrotherM"



'End of main script

'//////////////////////////////////////////////////
Function PasswordExpires(strDomain,strUser)
On Error Resume Next
Dim objUser
Set objUser=GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
PassExp=INT(objUser.MaxPasswordAge/86400)-INT(objUser.PasswordAge/86400)

If PassExp<0 Then
strPassMsg="Your password never expires."
Else
strPassMsg="Your password expires in " & PassExp & " day(s)"
end If

PasswordExpires=strPassMsg
End Function

Function IsAMemberOf(strDomain,strUser,strGroup)
On Error Resume Next
Set objUser=GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
Set objGrp=GetObject("WinNT://" & strDomain & "/" & strGroup & ",group")

If objGrp.IsMember(objUser.ADsPath) Then
IsAMemberOf=True
Else
IsAMemberOf=False
End If

End Function

Sub MapIt(strDrive,strMap)
On Error Resume Next
If objFSO.DriveExists(strDrive) Then objNetwork.RemoveNetworkDrive(strDrive)

objNetwork.MapNetworkDrive strDrive,strMap

If Err.Number<>0 And blnShowError Then
strMsg="There was a problem mapping drive " & UCase(strDrive) & " to " &_
strMap & VbCrLf & strHelpMsg & VbCrLf & "Error#:" & Hex(err.Number) &_
VbCrLf & Err.Description
objShell.Popup strMsg,iErrorTimeOut,"Error",vbOKOnly+vbExclamation
Err.Clear
End If

End Sub

Sub AddPrinterConnection(strPrinterUNC)
On Error Resume Next

objNetwork.AddWindowsPrinterConnection strPrinterUNC

If Err.Number<>0 And blnShowError Then
strMsg="There was a problem mapping " & UCase(strPrinterUNC) & ". " &_
vbcrlf & VbCrLf & strHelpMsg & VbCrLf & "Error#:" & Hex(err.Number) &_
VbCrLf & Err.Description

objShell.Popup strMsg,iErrorTimeOut,"Error",vbOKOnly+vbExclamation
Err.Clear
End If

end sub

Sub AddPrinterPortConnection(strPort,strPrinterUNC)
On Error Resume Next

objNetwork.AddPrinterConnection strPort,strPrinterUNC

If Err.Number<>0 And blnShowError Then
strMsg="There was a problem mapping " & UCase(strPrinterUNC) & " to " &_
strPort & vbcrlf & VbCrLf & strHelpMsg & VbCrLf & "Error#:" & Hex(err.Number) &_
VbCrLf & Err.Description

objShell.Popup strMsg,iErrorTimeOut,"Error",vbOKOnly+vbExclamation
Err.Clear
End If

end sub


 
Why not use GPO to push out the favorites?

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top