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


VBS Login script > copy file

Posted on 2006-03-20
Medium Priority
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 71

Accepted Solution

Chris Dent earned 1000 total points
ID: 16234866


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
ID: 16234892
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

Author Comment

ID: 16239392
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

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

This article will show you step-by-step instructions to build your own NTP CentOS server.  The network diagram shows the best practice to setup the NTP server farm for redundancy.  This article also serves as your NTP server documentation.
In this article I will be showing you how to subnet the easiest way possible for IPv4 (Internet Protocol version 4). This article does not cover IPv6. Keep in mind that subnetting requires lots of practice and time.
Viewers will learn how to connect to a wireless network using the network security key. They will also learn how to access the IP address and DNS server for connections that must be done manually. After setting up a router, find the network security…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) 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…

865 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