Solved

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

Posted on 2008-10-30
1
1,488 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
1 Comment
 
LVL 17

Accepted Solution

by:
Jared Luker earned 125 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

In this article we want to have a look at the directory attributes which are used by Microsoft to store the so called Security Identifiers (SID). These SIDs plays an important role in delegating and granting permissions and in authentication of trus…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

747 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now