Ive not made a VBS Script before but i want copy a file from our server to local hard drives on clients and have made this:

StackOverflow https://stackoverflow.com/questions/13027949

  •  13-07-2021
  •  | 
  •  

Question

I've made a logon vbs (first ever) so when someone logs on to the domain it copies a file from a network drive to each local machine. Would this work (as long as the directories are correct)?

<% 
dim filesys
set filesys=CreateObject("Scripting.FileSystemObject")
If filesys.FileExists("W:\Student Shared Area\SBN\registration.xml") Then
  filesys.CopyFile "W:\Student Shared Area\SBN\registration.xml"  _
    , "C:\Program Files\New-Media-Learning\Logicator\"
End If
%>
Was it helpful?

Solution

I see two potential issues with your code:

  • Drive W: is not (yet) mapped when the logon script runs. This won't be an issue when you map the drive before copying the file, but it might still be better to use a UNC path for the source:

    filesys.CopyFile "\\server\share\Student Shared Area\SBN\registration.xml", "C:\Program Files\New-Media-Learning\Logicator\"

    Personally I'd prefer Group Policy Preferences, though, if that's an option for you.

  • Users don't have write permissions on C:\Program Files\New-Media-Learning\Logicator\ (the logon script runs in the user's context). This can be mitigated by changing permissions on that folder with a GPO.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top