Batch file across network

Discussion in 'Software' started by MechGeek, Jul 27, 2004.

  1. MechGeek

    MechGeek Private First Class

    I wrote a quick and dirty little batch file that runs a couple of netstat commands and a current running process list and dumps it to all to a log file. I oversee a couple of computers on a small office network and would like to be able to run this batch file and get the same info for the other machines on the network, without leaving my desk. Currently no matter what i do it only tells me the info for my machine. Unless i copy it the the target computer and run it sitting at that computer. Any suggestions? Is this possible using these particular commands? The batch file is as follows

    echo. |time |find "current" >>log >c:\netcheck.log
    netstat.exe -an -o >>c:\netcheck.log
    netstat.exe -e >>c:\netcheck.log
    tasklist.exe >>c:\netcheck.log
    start c:\windows\notepad.exe c:\netcheck.log

    I'm sure that there is a program already available that does this, but i don't want to install any additional software.

    Thanks
     
  2. NeoNemesis

    NeoNemesis Moutharrhea

    Batch files can't be run across networks. The only way is to run it on each computer.
     
  3. goldfish

    goldfish Lt. Sushi.DC

    You'll need to have it run on the remove computer. put it on a network share and set up a scheduled task to have it run at set intervals, and it will create a log on each of the machines C drive.

    You could then write another batch file to copy the logs for each computer to your own drive, using a timestamped folder name, and copying the log files over the network, if thats what you want to do.

    so just add at the end : copylog.bat
    and on each machine, have a batch file that says :

    copy C:\netcheck.log \\yourpc\logfiles\%timestampfolder%\PC1.log

    or whatever. Obviously you'll need to set the variable %timestampfolder% using the time command.
     
  4. MechGeek

    MechGeek Private First Class

    We'll I learn something new every day. Kinda figured that was the case, but i thought i would ask. Could i do it using a vb script. I don't know vb, but i have always been looking for an excuse to learn.
     
  5. MechGeek

    MechGeek Private First Class

    I'd thought about that goldfish, but i want to be able to access it at any time. Kinda like the poor mans network monitor.<img>
     
  6. goldfish

    goldfish Lt. Sushi.DC

    No, wait, you can use \\mymachine\logs\Logs-%time%\PC1.log

    Argh! Right, okay... well, I can't think of any other way to do it, other than keep a permenat log like that.
     
  7. goldfish

    goldfish Lt. Sushi.DC

    second thoughts... thats not gunna work. %date% has \'s in it and %time% has .'s in it... so it makes it invalid. I'm looking for a way to make the \'s -'s ... so its valid for a folder name.
     
  8. virtualchaos

    virtualchaos Private E-2

    you can do a replace text command for characters within strings in batch files... it involves a : but i forget exactly what it is... might work to replace those invalid chars.
     
  9. goldfish

    goldfish Lt. Sushi.DC

    Yes, there is, it uses the SET command... but unfortunatley that won't work because what you're storing is %DATE% .... not that actual output string of %date%. Its easier just to extract the variables from the "date /t" function.
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds