SeeDk
asked on
Passing credentials through NET USE without hard coding the password?
What I am trying to do is setup a scheduled job that copies files from a server not joined to the corporate domain to a server that is in the domain.
I am using robocopy.
It would be very easy to do:
But I do not want to leave the password to this account hardcoded in a .bat file. Is there a more secure way I can store and pass credentials to the domain computer?
I am using robocopy.
It would be very easy to do:
net use \\IP\c$ /user:myuser mypassword
robocopy C:\mydir "\\IP\c$\copydir" /copyall
But I do not want to leave the password to this account hardcoded in a .bat file. Is there a more secure way I can store and pass credentials to the domain computer?
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
The passthru authentication suggested by Qlemo will work, but you might also try the Credential Manager in Control Panel > Users. It might let you securely store a password that Net Use would use.
The Credential Manager needs to be called as the task user for that to work, of course.
I assume you don't want to use a persistent connection (mapped drive) for security reasons? Also, you said that you were using this as a scheduled job/task, so what if you set the credentials in the task itself. The command to run robocopy could be reduced to just one command, since the process would already have the right credentials.
Kevin, because of
from a server not joined to the corporate domain to a server that is in the domainit isn't that simple ;-).
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
If RoboCopy is your only or last command, the result code is from RoboCopy, see https://ss64.com/nt/robocopy-exit.html.
0x3 means 0x1 (new files on source) and 0x2 (extra files on destination not being on source).
In a batch file you can override that by running exit /b 0 as very last statement. Then your task will result in 0 if the batch ran.
0x3 means 0x1 (new files on source) and 0x2 (extra files on destination not being on source).
In a batch file you can override that by running exit /b 0 as very last statement. Then your task will result in 0 if the batch ran.
ASKER
Thanks again!