1.

Solve : targeting workstations from a TXT file?

Answer»

Hi All
I NEED to execute a batch file on a few machines wich is listed in a text file -
What command do I have to put into my bat file to reference these workstations from the text file
- secondly I would only want to target these machines when the user is logged on (if it is not POSIBLE it is not to big a deal) and then I would like to keep a log file of which machines I have targeted sucsesfully
- the other problem is I cannot use psexec
Thank you
Why can´t you use psexec?
Are you not allowed, or is it not working on your system?

Read the textfile out. (With a for loop)
(There are very good offers at the moment)

Check with psloggedon which user is loggedon.
(might be a ittle work to analyze the return cause I don´t think it gives you a errorlevel if there is no user loggedon.)

The loop will be a bit tricky. Assumedly you need a sub.
Timeconsuming but worth. I didn´t do it yet.
I also don´t know if psexec executes batchfiles.
(But it´s on my tasklist since a while...)

hope this helps.
uli

Hi
Thx for the reply
we are not allowed to use psexec
as for my dos skills - it leaves much to be desired for this is what I have done up to now
first bat
bat1 is supposed to read from a text file the ws that I would like to target and then execute testbat2
testbat1
@echo off

for /f %%i in (c:\test1.txt) do test2.bat %%i

in testbat2 (I have build in the pauses to see where someting goes wrong - the problem is that it does not connect to the workstations in the text file - it only creates the "test" folder on the my workstation
@echo on
c:
cd\
pause
md test
pause
cd test
pause
echo Connecting...
net use b: /delete
pause
net use b: \\servershare\upgrade
pause
b:
copy b:\DeutzE.exe c:\test
pause

exitYour script can´t work cause you do md on your drive.
c:\ is on your HD. You have to use the mapped drive letter.

This script should work. I modified it a little.
Net use /delete deletes the drive mapping on your machine.
(not the users.) I use y cause it isn´t USED on my machine.
It copies your batch file to the machines. Use the at sheduler command to start it there. You only mapped the drive.
Save it as a cmd. You don´t need 2 scripts.
Please try it on a testsystem before copying to all machines in the network!!!

hope it helps
uli


@echo off
set source=folder where your files are in
set target=target folder where you want to copy
set LW=the drive letter from the target computer c d e or :: whatever


for /f %%i in (c:\test1.txt) do (

net use y: \\%%v\%LW%$
call :Sub %%i

)




set source=
set target=
set LW=
goto :EOF

:Sub %%i

IF %errorlevel% EQU 4 echo LW %LW%:\ from %1 couldn´t be mapped %errorlevel% >>%log% & GOTO fertig

echo. >>%log%

IF %errorlevel% EQU 2 echo LW %LW%:\ von %1 couldn´t be mapped cause it is not available%errorlevel%. >>%log% & GOTO fertig

echo. >>%log%


IF %errorlevel% EQU 0 echo LW %LW%:\ von %1could map drive >>%log%

REM ----- %source% copy %souce% to %target% ------

xcopy /q %source% %target%


IF ERRORLEVEL 1 echo Abbruch & GOTO fertig



IF %errorlevel% EQU 0 echo %source% COPIED %errorlevel% >>%log%

echo. >>%log%


: fertig

net use y: /delete


:EOFthank u
I will definetley test it in my lab
Groenie



Discussion

No Comment Found