WellingtonIS
asked on
PSexec Command
I'm trying to user the following command and suddenly it's not working???
PSexec \\@%var% -s cmd /c copy "C:\Icon\xxx.url" "%allusersprofile%\Desktop " /Y
It's saying can't find the file specified.
It is copying to the C:\icon I can see it but suddenly it's not going from C:\icon\ to the all users desktop???
The @%var% is from a multiple machine text file but for testing I was using the computer name in the command.
PSexec \\@%var% -s cmd /c copy "C:\Icon\xxx.url" "%allusersprofile%\Desktop
It's saying can't find the file specified.
It is copying to the C:\icon I can see it but suddenly it's not going from C:\icon\ to the all users desktop???
The @%var% is from a multiple machine text file but for testing I was using the computer name in the command.
The %allusersprofile% var is expanded on the machine before executing psexec, so if you execute from W7 to XP or reversed it will not work. You'll need either to escape the % (^%), or use cmd with delayed expansion to postpone %allusersprofile% substitution to the latest possible point in time:
PSexec \\PC -s cmd /c /e:on /v:on copy "C:\Icon\xxx.url" "!allusersprofile!\Desktop\" /Y
Also note that I have added an backslash to the target. That way "Desktop" cannot be misinterpreted to be the target file name instead of a folder.
ASKER
When I try to run the command it tells me that the file name or volume label syntax is incorrect.
ASKER
As for the permissions problem I'm running it as a system command. I also tried with my user name and password and it's the same thing. However I can do an administrative share with my user name and password.
ASKER
For some strange reason that I can't explain when I try to copy to %allusersprofile% is says the system can't find the path specified????
PSexec \\pc -s cmd /c copy "c:\icon\xxx.url" "%allusersprofile% \desktop" /Y
Stranger still is I can run this on my test machine without issue???
PSexec \\pc -s cmd /c copy "c:\icon\xxx.url" "%allusersprofile% \desktop" /Y
Stranger still is I can run this on my test machine without issue???
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I'm not sure why the "old' way doesn't work but I modified the PSexec script to copy the bat file to the C drive of the PC run it and then delete the bat file. thanks.
PSexec \\@%var% -s cmd /c dir "C:\Icon\xxx.url"
or in the machine @%var% try to open a cmd and run dir "C:\Icon\xxx.url" to verify if the path exists
Maybe it could be permissions problem
Which account are you using? this account has permission to "C:\Icon\xxx.url"?