Link to home
Create AccountLog in
Avatar of alisafia
alisafia

asked on

batch

Its monday, my brain is freezed.

REM QUEST PUTTY INSTALL
@echo on
for /f %%m in (C:\temp2\machines.txt) do (
xcopy "\\support\support\Software\Putty\questputty\Quest PuTTY.exe.lnk" "\\%%m\%ALLUSERSPROFILE%\desktop" /y
)

error

C:\scripts>(xcopy "\\support\support\Software\Putty\questputty\Quest PuTTY.exe.lnk" "\\xptest\C:\Documents and Settings\All Users\desktop" /y )
Invalid drive specification
0 File(s) copied
Avatar of Steve Knight
Steve Knight
Flag of United Kingdom of Great Britain and Northern Ireland image

You need to connect to the c$ share not c:\... path, i.e. just put the path directly not the %allusersprofile% variable.  That will be the variable on your machine anyway not the remote one.

Try

REM QUEST PUTTY INSTALL
@echo on
for /f %%m in (C:\temp2\machines.txt) call :install %%m
goto :eof

:install
if not exist "\\%1\c$\Documents and Settings\All Users\$\desktop" echo %1 not found & goto end
xcopy "\\support\support\Software\Putty\questputty\Quest PuTTY.exe.lnk" "\\%1\c$\Documents and Settings\All Users\$\desktop" /y /d

Have added it as a subroutine as I find that clearer and an /d so that if the file hasn't changed it doesn't copy again.  You don't need to do that if you don't want to.

Steve
I may be wrong, but I don't think you can have the drive letter C: in the destination in this case. You'd have to strip out the "C:\" from %ALLUSERPROFILE%.
ASKER CERTIFIED SOLUTION
Avatar of leecett
leecett
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Scuse me for answering first.... that is a way but pointless as the allusersprofile variable is from the LOCAL machine not the remote one so there is no point or advantage in specifying it rather than directly, as I said above as it is quite possibly a different directory name anyway.  If you want to guarentee to pickup the correct %allusersprofile% on a remote machine then run the batch using PSEXEC on the remote machine.

Steve