We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

How to create a .bat file that copies a file from one server to another under a particular user account?

Medium Priority
378 Views
Last Modified: 2012-05-11
Hello,
We have a need to copy a files from one location on a server to another location on a different server, however we need to impersonate or use the credentials of a particular service account.  Is it possible to get a .bat file to copy a file using the credentials of a particular user, not neccessarily the user the executed the .bat file?

Example:  We need File A to be copied from Server A Location A to Server B Location B.  The .bat file is run by James, but the file copy needs to occur under Joe's account.
Comment
Watch Question

Top Expert 2011

Commented:
Best way to do this would be to create a normal .bat account and then use Scheduled Tasks under Acessories -> system tools.

These tasks will let you run a .bat file from a specific user at specific interval.

I would avoid putting this info in the .bat file because that compromises that user's password.
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview

Author

Commented:
I believe inserting the password in plain text is permissible in this case.
alright...try this...Create a text file in the same folder where you batch file is and save as runa.vbs extension.
copy the code from above post and paste in that text file.save it.

Now run the vbs by double clicking on it or by running cscript filename.vbs

let us know if issues
CERTIFIED EXPERT
Top Expert 2016

Commented:
i wouldn't let the user's call batch files where the credentials of an account can be seen in plain text. even if you trust your users there can be malware which spies into those files.

i would let the user copy the file(s) to a share on the own computer (James). then at the destination account (Joe) there could be a local job in the task list (at) which periodically copies files from shares to that account.

Sara
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*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.