We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

VBS Login script > copy file

maximaal
maximaal asked
on
Medium Priority
440 Views
Last Modified: 2012-06-27
Hi,

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.

tnx
Comment
Watch Question

PowerShell Developer
CERTIFIED EXPERT
Top Expert 2010
Commented:

Hi,

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.

HTH

Chris

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Sam PanwarSr. Server Administrator

Commented:
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
http://www.computerperformance.co.uk/vbscript/vbscript_file_create.htm

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

http://www.computerperformance.co.uk/vbscript/vbscript_file_opentextfile.htm

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
http://www.computerperformance.co.uk/vbscript/index.htm

Author

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
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.