Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

i'm creating scheduled tasks on windows7 to copy some files to a shared folder on another computer. however, the shared folder required a username and password to have copy permissions. how can i automatically provide the login credentials from the batch file i'm using?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

There are a couple of ways, though they are relatively simple:

  1. Create an account on your computer with the same user name and password as the remote computer and have the bat file run as that account. (Or create an account on the remote machine with the same user name and password as your local machine)
  2. Connect to the remote machine and chose the option to save your credentials. Then run the schedule task under you user account so it will use the saved credentials.
  3. In the batch file use the net use command to connect to the share with a user name and password. The password will be in plain text in the batch file so this is not as secure as 1 or 2.

The syntax of net use is:

NET USE
[devicename | *] [\\computername\sharename[\volume] [password | *]]
        [/USER:[domainname\]username]
        [/USER:[dotted domain name\]username]
        [/USER:[username@dotted domain name]
        [/SMARTCARD]
        [/SAVECRED]
        [[/DELETE] | [/PERSISTENT:{YES | NO}]]

NET USE {devicename | *} [password | *] /HOME

NET USE [/PERSISTENT:{YES | NO}]
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.