?
Solved

Need vbscript to copy files from SYSVOL GPO folder to local c: drive

Posted on 2008-10-30
1
Medium Priority
?
1,562 Views
Last Modified: 2012-05-05
Hi Folks,

What's the recommended method to copy files from the SYSVOL\...USER\SCRIPTS\LOGON folder to the local c:\ drive (user's XP or Vista machines).  In the past I've used the the method shown.  But since the GPO has such a long character string for the folder, I was wondering if I need to put that full string in the code.  

Sort of related, can I refer to a file share (such as \\server\share) instead of having to use drive letter?  If I could use a share name I'd just copy the file(s) from that location and be done with it.

Suggestions appreciated.
strComputer = "."
 
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
 
 
Set colFiles = _
   objWMIService.ExecQuery("Select * From CIM_DataFile Where Name = 'f:\\HIPAAScreenSaver\\HNNCSB-HIPAA-SAVER.scr'")
 
 
For Each objFile in colFiles
    objFile.Copy ("C:\windows\system32\HNNCSB-HIPAA-SAVER.scr")
Next

Open in new window

0
Comment
Question by:hnncsb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 17

Accepted Solution

by:
Jared Luker earned 500 total points
ID: 22845174
You can use the ExpandEnvironmentStrings method to get the name of the domain controller that you are authenticated to.  That way, you could use that variable along with the sysvol share in UNC notation in order to point to the file that you are wanting to copy.
Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshSysEnv = WshShell.Environment("SYSTEM")
Set objFSO = CreateObject("Scripting.FileSystemObject")
 
LogonServer = wshshell.ExpandEnvironmentStrings("%LOGONSERVER%")
 
objFSO.CopyFile LogonServer & "\sysvol\WhatEverElse","c:\destination",True

Open in new window

0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question