"Phil Robyn [MVP]" wrote:
>Dave Nagalia wrote:
>> I have a script that is supposed to copy a shortcut from
>> my machine to all user's machines.
>>
>> I have icon.bat, allusers.txt, and the icon.lnk file
>> located in a folder called "Scripts" in the root of C:. I
>> can run the script, but the icon does not copy. Here is my
>> script:
>>
>> c:
>> cd c:\Scripts\
>> FOR /f "tokens=1 delims= " %%o in
>> (c:\Scripts\allusers.txt) do call :doit
>> %%o
>> goto end
>>
>> :do it
>> set machine=%1
>> IF NOT EXIST c:\Scripts\icon.lnk copy c:\Scripts\icon.lnk
>> "\\%machine%\c$\Documents and Settings\All
>> Users\Desktop\icon.lnk"
>> goto end
>>
>> :end
>>
>> Any ideas on what went wrong? I have a feeling it may just
>> be an oversight, but I can't pinpoint it.
>':doit' is not the same as ':do it'
Hi Dave,
to add to that, if you don't pass an argument directly following the
call, %1 in the sub will be empty.
Looks like you retyped a script you didn't understand.
You iterate through a file allusers and name that argument machine?
Mark is right that the "if NOT EXIST" is nonsens. If the source doesn't
exist, you can't copy it.
If writing/posting code which exceeds a normal line length you should
insert the break character "^"
"tokens=1 and delims= " are standard and may be omitted.
In the nt line you may use the predefined label :eof and the last
command in a batch doesn't need goto :eof since it's at the end of file.
cd /D c:\Scripts\
FOR /f %%o in (allusers.txt) do call :doit %%o
goto :eof
:doit
set machine=%1
IF EXIST c:\Scripts\icon.lnk copy c:\Scripts\icon.lnk ^
"\\%machine%\c$\Documents and Settings\All Users\Desktop\icon.lnk"
goto :eof
--
Greetings
Matthias________________________________________
For help on nt commands enter in a cmd window:
W2K>HH windows.chm::ntcmds.htm XP>HH ntcmds.chm
|