Today I was trying to create a script to copy files using runas, but it is failing with:
"C:\>runas /user:user "copy test.txt test2.txt””
Enter the password for user:
Attempting to start copy test.txt as user user…
RUNAS ERROR: Unable to run – copy test.txt
2: The system cannot find the file specified.
Of course the file exists, so after several attempts I found that the problem was not related to the file to be copied but to the copy command itself!
In order to solve I run the following command
"C:\>runas /user:user /env "cmd /k copy test.txt test2.txt
The /env flag is to use current environment instead of user’s.
The /k flag is to block the output shell in order to read the output of the command.