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.

Thanks
LVL 3
lundrogSr Cloud ArchitectAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

antonsigurCommented:
1. You should not keep the user and password of the less-restricted user in the login script...it 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
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
johnb6767Commented:
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"
exit

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


0
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
0
johnb6767Commented:
" -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....
0
johnb6767Commented:
Wow, just realized I goofed in this thread.....

Glad you got it though...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows XP

From novice to tech pro — start learning today.