VBS Login script > copy file

Posted on 2006-03-20
Last Modified: 2012-06-27

We use a normal vb loginscript. It's working fine.
But i want to add some functions, like copying files etc.

This is what i want to establish.
I want to copy a file (test.scr) from the server to ALL workstations.
From: \\server\testing\
To: %Systemroot%\System32

How can i fix this?
Not necessary with login script.

Question by:maximaal
    LVL 70

    Accepted Solution



    If you're sticking with pure VbScript then this is how:

    Set objFileSystem = CreateObject("Scripting.FileSystemObject")
    Set objShell = CreateObject("WScript.Shell")

    Set objFile = objFileSystem.GetFile("\\server\testing\test2.scr")
    objFile.Copy objShell.ExpandEnvironmentStrings("%SystemRoot%") & "\System32\", True
    Set objFile = Nothing

    Set objShell = Nothing
    Set objFileSystem = Nothing

    You might find it's just easier to do it in a batch file, or call the command directly though:

    Set objShell = CreateObject("WScript.Shell")
    objShell.Run "copy \\server\testing\test.scr %SystemRoot%\System32", 1, True
    Set objShell = Nothing

    The main advantage of the VbScript method is that you can add additional code in to capture errors.


    LVL 18

    Expert Comment

    by:Sam Panwar
    I would suggest you another way for it if you can create file test.scr through the vb script on user login then use the following article for it you can urself easily create it :

    For create file

    enter the text or file data into file through the following script

    you can put this script in the user login event in GPO of  Active directory when user login in computer then its create the file

    all script
    LVL 1

    Author Comment

    Chris-Dent > tnx, I'll try it tomorrow and let you know.

    Abs_jaipur > tnx, But i think it's not the answer i'm waiting for. tnx anyway

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Suggested Solutions

    Title # Comments Views Activity
    Thomson router 3 41
    CRC and input errors 4 57
    Cisco USB Device Setup 8 38
    Cisco stacked switches monitoring 4 38
    Lets look at the default installation and configuration of FreeProxy 4.10 REQUIREMENTS 1. FreeProxy 4.10 Application - Can be downloaded here ( 2. Ensure that you disable the windows fi…
    This is an article about my experiences with remote access to my clients (so that I may serve them) and eventually to my home office system via Radmin Remote Control. I have been using remote access for over 10 years and have been improving my metho…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    779 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

    11 Experts available now in Live!

    Get 1:1 Help Now