remote access - batch file creation pse -


i'm trying run batch file connect list of ip's on network, open cmd run list of commands: ipconfig /all, nbstat -c, arp -a. must save results folder renamed "computername".

i have batch file made can commands want , create folder computer, input different commands txt files within folder.

here windowscommands batch file:

md %computername%  echo off  echo arp command arp -a >> %cd%\%computername%\arp-a.txt  echo nbstat command nbtstat -c  >> %cd%\%computername%\nbstat.txt  echo ipconfig command ipconfig /all  >> %cd%\%computername%\ipconfig-all.txt  echo ipconfig dns command ipconfig /displaydns  >> %cd%\%computername%\ipconfig-displaydns.txt  echo netstat command netstat -ano  >> %cd%\%computername%\netstat-ano.txt  echo tasklist command tasklist /v  >> %cd%\%computername%\tasklist.txt  echo lg admin command net localgroup administrators >> %cd%\%computername%\netlocalgroupadmin.txt  echo directory command  dir c:\windows\prefetch >> %cd%\%computername%\prefetch.txt  exit 

i created hosts.txt file contains local ip addresses want run commands on.

i created batch file name psexec running loop.

now troubles , arising when trying run psexec batch file.

here psexec file:

for /f %%a in (hosts.txt) ( psexec \\%%a c:\users\issg\documents\windowscommands.bat ) 

now rough draft i'm not entirely sure if how should coded. 1 of first automated scripts have ever wrote.

so in nutshell need able run batch file local computer- psexec ip's. gather information , output txt files on local computer.

if point me in right direction great! thanks!

if batch file doesn't exist in system directory on of computers, have use -c switch copy them in order run it. it's idea try ping computer first save time trying connect it.

for /f %%a in (hosts.txt) (   /f "tokens=2 delims=:" %%b in ('ping -n 1 %%a ^| find "ttl="') (     if errorlevel 0 (       psexec \\%%a -c -f -u username -p password c:\users\issg\documents\windowscommands.bat     )   ) ) 

also, keep in mind create folder in system32 directory on remote computer. if want on local drive, this:

@echo off  /f "tokens=2" %%a in (   'net use * "\\computer\share"' ) if not %%a.==command. set dl=%%a  if not exist "%dl%\%computername%" md "%dl%\%computername%"  echo arp command arp -a >> %dl%\%computername%\arp-a.txt  echo nbstat command nbtstat -c  >> %dl%\%computername%\nbstat.txt  echo ipconfig command ipconfig /all  >> %dl%\%computername%\ipconfig-all.txt  echo ipconfig dns command ipconfig /displaydns  >> %dl%\%computername%\ipconfig-displaydns.txt  echo netstat command netstat -ano  >> %dl%\%computername%\netstat-ano.txt  echo tasklist command tasklist /v  >> %dl%\%computername%\tasklist.txt  echo lg admin command net localgroup administrators >> %dl%\%computername%\netlocalgroupadmin.txt  echo directory command  dir c:\windows\prefetch >> %dl%\%computername%\prefetch.txt  net use %dl% /delete 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -