PSEXEC help - execute .bat
Posted on 2007-10-10
I'm trying to execute a batch file using PSEXEC on a remote system to map shortcuts to the users desktop. The syntax in my .bat is:
echo F|xcopy "F:\Shortcut to Controlled Documents.lnk" "%userprofile%\desktop\Shortcut to Controlled Documents.lnk" /d /y
I know this works. I've used it hundreds of times.
My syntax for PSEXEC is:
PSEXEC @C:\systemlist.txt -c C:\ConDocs.bat
The connection is made but I get an "invalid drive specification" from PSEXEC when attempting to copy the shortcuts. The return shows that it's trying to copy the shortcut to "C:\Documents and Settings\NetworkService\Desktop\Shortcut to Controlled Documents.lnk" and the NetworkService profile has no "desktop" directory.
What I want PSEXEC to do is run the bat file on the current active user that's logged on to the PC. I know I can do this via GPO at the next logon, but I was trying to just get it out of the way without waiting for users to log off/log on again. Can this be done using the %userprofile% wildcard?