Link to home
Start Free TrialLog in
Avatar of Blackduke77
Blackduke77

asked on

VBS script need to replace server name with logonserver

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
          objFSO.createfolder(strDestinationFolder)
     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
          else
               if file.DateLastModified > objFSO.getfile(strDestinationFolder & file.name).DateLastModified then
                    objFSO.copyfile file, strDestinationFolder & file.name
               end if
          end if
     next

     set objFSO = nothing

end function


function CheckForBackSlash(byref strFolder)
     if right(strFolder, 1) <> "\" then
          strFolder = strFolder & "\"
     end if
end function
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial