VBS Login script > copy file


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.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Chris DentPowerShell DeveloperCommented:


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.



Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Sam PanwarSr. Server AdministratorCommented:
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
maximaalAuthor Commented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.