Link to home
Start Free TrialLog in
Avatar of lundrog
lundrogFlag for United States of America

asked on

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
ASKER CERTIFIED SOLUTION
Avatar of antonsigur
antonsigur
Flag of Iceland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of johnb6767
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


Avatar of lundrog

ASKER

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...