Loading ...
Sorry, an error occurred while loading the content.
 

RE: [BATCH WORLD] Echo to Log file help

Expand Messages
  • Morris, Lamar
    Thanks Ken. I m also hacking on it. Lamar ________________________________ From: batchworld@yahoogroups.com [mailto:batchworld@yahoogroups.com] On Behalf Of
    Message 1 of 17 , May 16, 2007
      Thanks Ken. I'm also hacking on it.



      Lamar



      ________________________________

      From: batchworld@yahoogroups.com [mailto:batchworld@yahoogroups.com] On
      Behalf Of Kenneth C. Mazie
      Sent: Wednesday, May 16, 2007 2:24 PM
      To: batchworld@yahoogroups.com
      Subject: RE: [BATCH WORLD] Echo to Log file help



      Probably. Every version of the script I have uses a hard coded password.
      Seems that script you're using was a quick mod on my original script
      that
      also included the password file loop. Mic's mod should be able to do it
      with a bit of alteration as long as you call the entire routine as a
      subroutine so as to do some simple error checking. That way you select
      the
      current password, pass it to the logon subroutine, try it, if it works
      continue, if not loop. I'd be happy to try and look into it later
      tonight,
      right now though I'm in a crunch to get a huge domain management
      vbscript
      done. Perhaps Mic, or someone else might have some variation in their
      bag
      of tricks that would suit the bill.

      Ken Mazie

      From: batchworld@yahoogroups.com <mailto:batchworld%40yahoogroups.com>
      [mailto:batchworld@yahoogroups.com <mailto:batchworld%40yahoogroups.com>
      ] On
      Behalf Of Morris, Lamar
      Sent: Wednesday, May 16, 2007 11:30 AM
      To: batchworld@yahoogroups.com <mailto:batchworld%40yahoogroups.com>
      Subject: RE: [BATCH WORLD] Echo to Log file help

      Is there a way to make the script stop reading the password.txt file
      once it finds a good one.

      Lamar

      ________________________________

      [Non-text portions of this message have been removed]





      [Non-text portions of this message have been removed]
    • foxidrive
      On Wed, 16 May 2007 14:31:41 -0500, Morris, Lamar ... Couldn t sleep so I m up for a few minutes again. Try this untested hack Lamar:
      Message 2 of 17 , May 16, 2007
        On Wed, 16 May 2007 14:31:41 -0500, "Morris, Lamar" <LamarMorris@...>
        wrote:

        >Thanks Ken. I'm also hacking on it.

        Couldn't sleep so I'm up for a few minutes again. Try this untested hack
        Lamar:


        Any lines in column 1 have wrapped. Requires W2K/XP etc


        :: Attempts connection with passwords in password file.
        for /F %%i in (.\passwords.txt) do net use \\%currentmachine%\IPC$
        /USER:%currentmachine%\%admin% %%i&&goto :next
        echo Unable to login to %currentmachine% >>.\log.txt
        goto :loginfail
        :next
      • Morris, Lamar
        Thanks Mic, The file does indeed stop when it hits a good password, it s not echoing unable to log on to %currentmachine% to the log file when it can t find
        Message 3 of 17 , May 17, 2007
          Thanks Mic, The file does indeed stop when it hits a good password, it's
          not echoing unable to log on to %currentmachine% to the log file when it
          can't find the correct password.



          I've included the part of the script where I added your code. I also
          removed the login part of the script because your code does it.



          I don't understand these parts of the script. %%i&&goto :next what does
          this do other that go to the next label.

          This label is not defined, what does it do goto :loginfail





          :process

          :connect

          @echo Current system: %currentmachine% is
          valid......Processing.......>>.\log.txt

          net use %currentmachine%\IPC$ /D

          @echo Attempting logon to %currentmachine% >>.\log.txt

          :: Attempts connection with passwords in password file.

          for /F %%i in (.\passwords.txt) do net use \\%currentmachine%\IPC$
          /USER:%currentmachine%\%admin% %%i&&goto :next

          echo Unable to login to %currentmachine% >>.\log.txt

          goto :loginfail



          :next



          goto :execute



          Lamar



          ________________________________

          From: batchworld@yahoogroups.com [mailto:batchworld@yahoogroups.com] On
          Behalf Of foxidrive
          Sent: Wednesday, May 16, 2007 4:31 PM
          To: batchworld@yahoogroups.com
          Subject: Re: [BATCH WORLD] Echo to Log file help



          On Wed, 16 May 2007 14:31:41 -0500, "Morris, Lamar" <LamarMorris@...
          <mailto:LamarMorris%40ti.com> >
          wrote:

          >Thanks Ken. I'm also hacking on it.

          Couldn't sleep so I'm up for a few minutes again. Try this untested hack
          Lamar:

          Any lines in column 1 have wrapped. Requires W2K/XP etc

          :: Attempts connection with passwords in password file.
          for /F %%i in (.\passwords.txt) do net use \\%currentmachine%\IPC$
          /USER:%currentmachine%\%admin% %%i&&goto :next
          echo Unable to login to %currentmachine% >>.\log.txt
          goto :loginfail
          :next





          [Non-text portions of this message have been removed]
        • foxidrive
          On Thu, 17 May 2007 08:22:43 -0500, Morris, Lamar ... Hmmm. I m not sure why. It works in a simplified test here. Try a few bogus
          Message 4 of 17 , May 17, 2007
            On Thu, 17 May 2007 08:22:43 -0500, "Morris, Lamar" <LamarMorris@...>
            wrote:

            >Thanks Mic, The file does indeed stop when it hits a good password, it's
            >not echoing unable to log on to %currentmachine% to the log file when it
            >can't find the correct password.

            Hmmm. I'm not sure why. It works in a simplified test here.
            Try a few bogus passwords in a new file, just to see.

            >I don't understand these parts of the script. %%i&&goto :next what does
            >this do other that go to the next label.

            It jumps out of the loop that is trying different passwords when a correct
            password is used (well, when the 'net use' command succeeds) and goes
            directly to a spot in the script to continue whatever it is you are doing.
            That can be anyplace.

            && is processed when the errorlevel is zero (no failure) so when a password
            succeeds it branchs to the :next label.

            >This label is not defined, what does it do goto :loginfail

            It should fall through and log the machine that failed (all passwords are
            wrong) and then branch to wherever you want to go. I just called the
            re-entry point :loginfail

            >
            >:process
            >
            >:connect
            >
            > @echo Current system: %currentmachine% is
            >valid......Processing.......>>.\log.txt
            >
            > net use %currentmachine%\IPC$ /D
            >
            > @echo Attempting logon to %currentmachine% >>.\log.txt
            >
            >:: Attempts connection with passwords in password file.
            >
            >for /F %%i in (.\passwords.txt) do net use \\%currentmachine%\IPC$
            >/USER:%currentmachine%\%admin% %%i&&goto :next
            >
            >echo Unable to login to %currentmachine% >>.\log.txt
            >
            >goto :loginfail
            >
            >
            >
            >:next
            >
            >
            >
            >goto :execute
          • Morris, Lamar
            Thanks for the explanation. Here is what the log is showing on failures (no good password). This is ok because I can tell by the file copy failure that the
            Message 5 of 17 , May 17, 2007
              Thanks for the explanation. Here is what the log is showing on failures (no good password). This is ok because I can tell by the file copy failure that the system was either offline or there was no good password.

              -===================================-
              Current system: h6NM7015 is valid......Processing.......
              Attempting logon to h6NM7015
              0 file(s) copied.
              -===================================-

              Lamar

              ________________________________________
              From: batchworld@yahoogroups.com [mailto:batchworld@yahoogroups.com] On Behalf Of foxidrive
              Sent: Thursday, May 17, 2007 8:59 AM
              To: batchworld@yahoogroups.com
              Subject: Re: [BATCH WORLD] Echo to Log file help

              On Thu, 17 May 2007 08:22:43 -0500, "Morris, Lamar" <LamarMorris@...>
              wrote:

              >Thanks Mic, The file does indeed stop when it hits a good password, it's
              >not echoing unable to log on to %currentmachine% to the log file when it
              >can't find the correct password.

              Hmmm. I'm not sure why. It works in a simplified test here.
              Try a few bogus passwords in a new file, just to see.

              >I don't understand these parts of the script. %%i&&goto :next what does
              >this do other that go to the next label.

              It jumps out of the loop that is trying different passwords when a correct
              password is used (well, when the 'net use' command succeeds) and goes
              directly to a spot in the script to continue whatever it is you are doing.
              That can be anyplace.

              && is processed when the errorlevel is zero (no failure) so when a password
              succeeds it branchs to the :next label.

              >This label is not defined, what does it do goto :loginfail

              It should fall through and log the machine that failed (all passwords are
              wrong) and then branch to wherever you want to go. I just called the
              re-entry point :loginfail

              >
              >:process
              >
              >:connect
              >
              > @echo Current system: %currentmachine% is
              >valid......Processing.......>>.\log.txt
              >
              > net use %currentmachine%\IPC$ /D
              >
              > @echo Attempting logon to %currentmachine% >>.\log.txt
              >
              >:: Attempts connection with passwords in password file.
              >
              >for /F %%i in (.\passwords.txt) do net use \\%currentmachine%\IPC$
              >/USER:%currentmachine%\%admin% %%i&&goto :next
              >
              >echo Unable to login to %currentmachine% >>.\log.txt
              >
              >goto :loginfail
              >
              >
              >
              >:next
              >
              >
              >
              >goto :execute
            Your message has been successfully submitted and would be delivered to recipients shortly.