[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 615
  • Last Modified:

VBS and %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

0
Blackduke77
Asked:
Blackduke77
1 Solution
 
TheMCSECommented:
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!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now