Psexec to copy file using cmd "restricted user"

I am trying to copy a file via login script, under a restricted user

I was trying the below from a share X:\
psexec /accepteula -u user -p pass cmd /c mkdir C:\tmp ( this works)
psexec /accepteula -u user -p pass cmd /c copy "X:\2.reg" "C:\tmp\2.reg"
gives me a cmd exited with error code 1.
and it does not copy the file.

lundrogSr Cloud ArchitectAsked:
Who is Participating?
antonsigurConnect With a Mentor Commented:
1. You should not keep the user and password of the less-restricted user in the login is a security breach

2. This is not working because the "profile" the psexec is using does not see the network drive X: - try using UNC paths like \\server\share
Are you trying to get the 2.reg to each machine on the network?

Save the following as reg.bat. Save in the same location as psexec....

echo off
mkdir C:\tmp
copy "\\server\share\2.reg" "C:\tmp\2.reg"

then run ....

psexec @c:\pcnames.txt -c -d reg.bat

names.txt would be a flat text file of your computer names needing this file....

You could even include a command to import the file....

regedit c:\tmp\2.reg /s

lundrogSr Cloud ArchitectAuthor Commented:
This is a temporary over night operation, where the user will be disabled once this is complete,  and yes to every machine on the network,

So, psexec /accepteula -u user -p pass cmd /c copy "\\servername\sharename\2.reg" "C:\tmp\2.reg"
Should work?

 Johnb6767, these are restricted users, they can't make a directory or use the copy command.

Hence, psexec
" -u user -p pass"

Thats the purpose of parsing the user/pass in the command line switch.....

And yes, the above should work fine, as long as you either enter the @c:\pcnames.txt or the \\pcname component....
Wow, just realized I goofed in this thread.....

Glad you got it though...
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.