• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 364
  • Last Modified:

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

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.
0
endrec
Asked:
endrec
1 Solution
 
jonahzonaCommented:
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.
0
 
subhashchyCommented:
you can do that..but the RUNAS user's password will has to be inserted in the batch as plain text. Will that be OK ?

Set ws = CreateObject("WScript.Shell")
ws.Run "runas.exe /user:joe cmd.exe /c batch.bat" 
wscript.sleep 2000
ws.SendKeys "password"
ws.SendKeys "{ENTER}"

Open in new window

run this VBS from the same folder where the batch file is present..
0
 
endrecAuthor Commented:
I believe inserting the password in plain text is permissible in this case.
0
 
subhashchyCommented:
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
0
 
sarabandeCommented:
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
0

Featured Post

Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

Tackle projects and never again get stuck behind a technical roadblock.
Join Now