I have been trying to find a script to make a simple file copy at login that has turned out to be not so simple. I dont write code myself but I can usually find something on line that I can manipulate to fit my needs. In this case it seems I am doing something out of the ordinary and while I am not above begging for help I would be glad to have someone point me towards something that can do what I need or if it is simple enough to write something me. What I am doing is trying to copy a user signature file into the c:\Documents and Settings\" & StrUsername & "\Application Data\Microsoft\Signatures\ directory at logon. The problem is the files for these users are named by their user names so in my case my signature file is bwall.htm. I have tried using typical vbscript wildcards regarding usernames and while they work in a directory string I cant get them to call the filename and copy it. I can make the scripts I have used copy a simple text file with a generic name just to prove to myself that the scripts work but I cant get it to see the user name with it being a user name. These files are all in one directory on our network to make it easier for us to edit and keep track of them. So I am copy from a network share to a local folder within the user profile so there are several variables here.
*Copying from a network location that the user does have access to
*copying to the users profile so there is a wildcard in the folder string
*copying a files with the username as the file name. 3 Files (<username>.htm, <username>.rtf and <username>.txt)
Option Explicit
Dim objFSO, objNetwork, strUserName
Dim strShare, strSource
' Specify source for file to copy.
'strShare = "\\VEOFS02\emailsigs"
strSource = "\\VEOFS02\emailsigs\ & StrUsername & *.*"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objNetwork = CreateObject("Wscript.Network")
' Retrieve user name.
strUserName = objNetwork.UserName
' Map drive.
' objNetwork.MapNetworkDrive "S:", strShare
' Copy file.
objFSO.CopyFile strSource, "c:\Documents and Settings\" & StrUsername & "\Application Data\Microsoft\Signatures\"
' Clean up.
' objNetwork.RemoveNetworkDrive "S:", True, True
*Copying from a network location that the user does have access to
*copying to the users profile so there is a wildcard in the folder string
*copying a files with the username as the file name. 3 Files (<username>.htm, <username>.rtf and <username>.txt)
Option Explicit
Dim objFSO, objNetwork, strUserName
Dim strShare, strSource
' Specify source for file to copy.
'strShare = "\\VEOFS02\emailsigs"
strSource = "\\VEOFS02\emailsigs\ & StrUsername & *.*"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objNetwork = CreateObject("Wscript.Network")
' Retrieve user name.
strUserName = objNetwork.UserName
' Map drive.
' objNetwork.MapNetworkDrive "S:", strShare
' Copy file.
objFSO.CopyFile strSource, "c:\Documents and Settings\" & StrUsername & "\Application Data\Microsoft\Signatures\"
' Clean up.
' objNetwork.RemoveNetworkDrive "S:", True, True