Hi guys please can you help me out here, I have a script that copies a file to the pc's system32 directory but I am having difficulty, I would like to set the %netlogon% as the source folder.

at the moment is errors saying "source folder not found" however I replace the source folder with a UNC server name and path it all works fine. I am in a desperate hurry for this so I have put 500 points on it, I would put 10,000 if I could thanks in advanced !!!

dim strSource, strDestination
strSource = "\\wfflongham01\netlogon\logo\"
strDestination = "c:\windows\system32\logo\"

SynchroniseFiles strSource, strDestination

function SynchroniseFiles(byval strSourceFolder, byval strDestinationFolder)

      CheckForBackSlash strSourceFolder
      CheckForBackSlash strDestinationFolder
      dim objFSO
      set objFSO = Createobject("scripting.filesystemobject")
      if not objFSO.folderexists(strDestinationFolder) then
      end if

      dim file
      for each file in objFSO.getfolder(strSourceFolder).files
            if not objFSO.fileexists(strDestinationFolder & file.name) then
                  objFSO.copyfile file, strDestinationFolder & file.name
                  if file.DateLastModified > objFSO.getfile(strDestinationFolder & file.name).DateLastModified then
                        objFSO.copyfile file, strDestinationFolder & file.name
                  end if
            end if

      set objFSO = nothing

end function

function CheckForBackSlash(byref strFolder)
      if right(strFolder, 1) <> "\" then
            strFolder = strFolder & "\"
      end if
end function

Who is Participating?
TheMCSEConnect With a Mentor Commented:
I suspect that the problem you were having is with the expansion of the %LOGONSERVER% environment variable.  If you were to use something like this:

Set objWSHShell = WScript.CreateObject("WScript.Shell")
strSource = objWSHShell.ExpandEnvironmentStrings("%LOGONSERVER%\netlogon\logo\")

You would probably be able to overcome this.  Good luck!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.