Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: batch file logging windows 7 home how to question  (Read 15546 times)

0 Members and 1 Guest are viewing this topic.

snowcatman

    Topic Starter


    Beginner

    • Experience: Beginner
    • OS: Windows 8
    batch file logging windows 7 home how to question
    « on: March 08, 2014, 02:46:21 PM »
    I have windows 7 home. As admin I did a ver. in the cmd.exe, results were "Microsoft Windows [version 6.1.7601]"

    I am making a patch file that changes your logon wallpaper. What can I say. I want to learn how.

    The question is! How do I log whats going on it the patch file?

    Whats happening is a cmd window opens up and just sit's there doing nothing. The files output.txt and error.txt are made put there is nothing in them. Eventually I just x out of the window.

    Here is the code I am using so far. Or what mess I have made so far. Its a work in progress.  :)

    I am using "resource hacker [version 3.6.0.92] by angus johnson"
    i have a picture file that meets microsoft's requirments
    ==============================================================

    @ECHO OFF

    logonwallpaper.bat 1> output.txt 2> error.txt

    CLS

    ECHO You need to exit and start this
    ECHO file with administrator privileges.
    ECHO If you already have just countinue.
    ECHO Thank You
    echo.
    echo press anykey
    PAUSE > NUL

    :MENU
    CLS

    ECHO ============= MENU NAME =============
    ECHO -------------------------------------
    ECHO A. Read Me First
    ECHO -------------------------------------
    ECHO B  2.enable uac not yet emplemented
    ECHO -------------------------------------
    ECHO C  3.background wallper changer at logon
    ECHO -------------------------------------
    ECHO D  Selection 4
    ECHO -------------------------------------
    ECHO E  Selection 5
    ECHO -------------------------------------
    ECHO F  Selection 6
    ECHO -------------------------------------
    ECHO G  Selection 7
    ECHO -------------------------------------
    ECHO H  Selection 8
    ECHO -------------------------------------
    ECHO I  Selection 9
    ECHO -------------------------------------
    ECHO ==========PRESS 'z' TO QUIT==========
    ECHO.

    SET INPUT=
    SET /P INPUT=Please select a number:

    IF /I '%INPUT%'=='a' GOTO Selection1
    IF /I '%INPUT%'=='b' GOTO Selection2
    IF /I '%INPUT%'=='c' GOTO Selection3
    IF /I '%INPUT%'=='d' GOTO Selection4
    IF /I '%INPUT%'=='e' GOTO Selection5
    IF /I '%INPUT%'=='f' GOTO Selection6
    IF /I '%INPUT%'=='g' GOTO Selection7
    IF /I '%INPUT%'=='h' GOTO Selection8
    IF /I '%INPUT%'=='i' GOTO Selection9
    IF /I '%INPUT%'=='j' GOTO Selection9

    IF /I '%INPUT%'=='z' GOTO Quit

    CLS

    ECHO ============INVALID INPUT============
    ECHO -------------------------------------
    ECHO Please select a number from the Main
    echo Menu [1-9] or select 'z' to quit.
    ECHO -------------------------------------
    ECHO ======PRESS ANY KEY TO CONTINUE======

    PAUSE > NUL
    GOTO MENU

    :Selection1

    echo Ok this is to change your wallpaper on your login screen as if you were to do it manually.
    echo Even though we are doing it in a patch file.
    echo I am in the beginning stages of making this work. the reason i made the script the way i
    echo did is to see and know what i am doing with it. i need to see the errors and know if there needs to be a change.
    echo.
    echo the script is full of pauses and you need to tap on the enter key once or twice to see the script move on
    echo.
    echo if you see a drive letter the just type exit and the script will continue.
    echo.
    echo it may ask if you are making a folder or a file i choose file
    echo.
    echo it needs some touch up so don't nock it for what it is. think if you had
    echo to do it mannually in a batch file how would you do it.
    echo.
    echo also if you make any changes to these files please zip the folder back up and send it my way. thank you
    echo [email protected]
    echo.
    echo thank you.
    echo Press Any Key when done Reading!
    echo.
    PAUSE > NUL
    Goto Menu

    :Selection2

    cls


    echo press anykey
    PAUSE > NUL
    Goto Menu

    :Selection3

    cls

    echo before you begine this you need to
    echo be on the administrator account you unhide
    echo if you are not please use ctrl c and exit this batch script
    echo if you are on the administrator account then just press anykey
    PAUSE > NUL

    cls


    echo processing

    C:\Windows\System32\cmd.exe /k %windir%\System32\reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA /t REG_DWORD /d 0 /f

    echo killing task's<----------
    taskkill /f /IM explorer.exe
    taskkill /f /IM rundll32.exe
    taskkill /f /IM procexp64.exe
    PAUSE > NUL
    cls

    SET __COMPAT_LAYER=WINXPSP3

    echo step 1 take ownership
    TAKEOWN /F %windir%\system32\imageres.dll
    ICACLS %windir%\system32\imageres.dll /GRANT Administrator:F

    echo step 2 make directory
    mkdir %~dp0\temp

    echo press anykey
    PAUSE > NUL
    cls

    echo step 3 copy file make old
    xcopy %windir%\system32\imageres.dll "%windir%\system32\imageres.dll.old" /c /y /h

    echo step 4 copy file to temp
    xcopy %windir%\system32\imageres.dll %~dp0\temp /c /y /h

    Echo step 5 delete file in system
    attrib -r -s -h "%windir%\system32\imageres.dll" | echo attrib used
    del /q /f "%windir%\system32\imageres.dll" | echo imageres.ddl deleted in the system folder

    PAUSE > NUL

    echo step 6 overwrite image to file
    %~dp0\ResHacker.exe -addoverwrite %~dp0\temp\imageres.dll, %~dp0\temp\imageres1.dll, %~dp0\cat.jpg, image, 5031,
    xcopy %~dp0\temp\imageres1.dll %~dp0\temp\imageres.dll /c /y /h
    echo .
    %~dp0\ResHacker.exe -addoverwrite %~dp0\temp\imageres.dll, %~dp0\temp\imageres1.dll, %~dp0\cat.jpg, image, 5032,
    xcopy %~dp0\temp\imageres1.dll %~dp0\temp\imageres.dll /c /y /h
    echo ..
    %~dp0\ResHacker.exe -addoverwrite %~dp0\temp\imageres.dll, %~dp0\temp\imageres1.dll, %~dp0\cat.jpg, image, 5033,
    xcopy %~dp0\temp\imageres1.dll %~dp0\temp\imageres.dll /c /y /h
    echo ...
    %~dp0\ResHacker.exe -addoverwrite %~dp0\temp\imageres.dll, %~dp0\temp\imageres1.dll, %~dp0\cat.jpg, image, 5034,
    xcopy %~dp0\temp\imageres1.dll %~dp0\temp\imageres.dll /c /y /h
    echo ....
    %~dp0\ResHacker.exe -addoverwrite %~dp0\temp\imageres.dll, %~dp0\temp\imageres1.dll, %~dp0\cat.jpg, image, 5035,
    xcopy %~dp0\temp\imageres1.dll %~dp0\temp\imageres.dll /c /y /h
    echo .....
    %~dp0\ResHacker.exe -addoverwrite %~dp0\temp\imageres.dll, %~dp0\temp\imageres1.dll, %~dp0\cat.jpg, image, 5036,
    xcopy %~dp0\temp\imageres1.dll %~dp0\temp\imageres.dll /c /y /h
    echo ......
    %~dp0\ResHacker.exe -addoverwrite %~dp0\temp\imageres.dll, %~dp0\temp\imageres1.dll, %~dp0\cat.jpg, image, 5037,
    xcopy %~dp0\temp\imageres1.dll %~dp0\temp\imageres.dll /c /y /h
    echo .......
    %~dp0\ResHacker.exe -addoverwrite %~dp0\temp\imageres.dll, %~dp0\temp\imageres1.dll, %~dp0\cat.jpg, image, 5038,
    xcopy %~dp0\temp\imageres1.dll %~dp0\temp\imageres.dll /c /y /h
    echo ........
    %~dp0\ResHacker.exe -addoverwrite %~dp0\temp\imageres.dll, %~dp0\temp\imageres1.dll, %~dp0\cat.jpg, image, 5039,
    xcopy %~dp0\temp\imageres1.dll %~dp0\temp\imageres.dll /c /y /h
    echo ........."25%"
    %~dp0\ResHacker.exe -addoverwrite %~dp0\temp\imageres.dll, %~dp0\temp\imageres1.dll, %~dp0\cat.jpg, image, 5040,
    xcopy %~dp0\temp\imageres1.dll %~dp0\temp\imageres.dll /c /y /h
    echo ..........
    %~dp0\ResHacker.exe -addoverwrite %~dp0\temp\imageres.dll, %~dp0\temp\imageres1.dll, %~dp0\cat.jpg, image, 5041,
    xcopy %~dp0\temp\imageres1.dll %~dp0\temp\imageres.dll /c /y /h
    echo ...........
    %~dp0\ResHacker.exe -addoverwrite %~dp0\temp\imageres.dll, %~dp0\temp\imageres1.dll, %~dp0\cat.jpg, image, 5042,
    xcopy %~dp0\temp\imageres1.dll %~dp0\temp\imageres.dll /c /y /h
    echo ............
    %~dp0\ResHacker.exe -addoverwrite %~dp0\temp\imageres.dll, %~dp0\temp\imageres1.dll, %~dp0\cat.jpg, image, 5043,
    xcopy %~dp0\temp\imageres1.dll %~dp0\temp\imageres.dll /c /y /h
    echo .............
    %~dp0\ResHacker.exe -addoverwrite %~dp0\temp\imageres.dll, %~dp0\temp\imageres1.dll, %~dp0\cat.jpg, image, 5044,
    xcopy %~dp0\temp\imageres1.dll %~dp0\temp\imageres.dll /c /y /h
    echo ..............
    %~dp0\ResHacker.exe -addoverwrite %~dp0\temp\imageres.dll, %~dp0\temp\imageres1.dll, %~dp0\cat.jpg, image, 5045,
    xcopy %~dp0\temp\imageres1.dll %~dp0\temp\imageres.dll /c /y /h
    echo ..............."50%"
    %~dp0\ResHacker.exe -addoverwrite %~dp0\temp\imageres.dll, %~dp0\temp\imageres1.dll, %~dp0\cat.jpg, image, 5046,
    xcopy %~dp0\temp\imageres1.dll %~dp0\temp\imageres.dll /c /y /h
    echo ................
    %~dp0\ResHacker.exe -addoverwrite %~dp0\temp\imageres.dll, %~dp0\temp\imageres1.dll, %~dp0\cat.jpg, image, 5047,
    xcopy %~dp0\temp\imageres1.dll %~dp0\temp\imageres.dll /c /y /h
    echo .................
    %~dp0\ResHacker.exe -addoverwrite %~dp0\temp\imageres.dll, %~dp0\temp\imageres1.dll, %~dp0\cat.jpg, image, 5048,
    xcopy %~dp0\temp\imageres1.dll %~dp0\temp\imageres.dll /c /y /h
    echo ..................
    %~dp0\ResHacker.exe -addoverwrite %~dp0\temp\imageres.dll, %~dp0\temp\imageres1.dll, %~dp0\cat.jpg, image, 5049,
    xcopy %~dp0\temp\imageres1.dll %~dp0\temp\imageres.dll /c /y /h
    echo ...................
    %~dp0\ResHacker.exe -addoverwrite %~dp0\temp\imageres.dll, %~dp0\temp\imageres1.dll, %~dp0\cat.jpg, image, 5050,
    xcopy %~dp0\temp\imageres1.dll %~dp0\temp\imageres.dll /c /y /h
    echo ...................."75%"
    %~dp0\ResHacker.exe -addoverwrite %~dp0\temp\imageres.dll, %~dp0\temp\imageres1.dll, %~dp0\cat.jpg, image, 5051,
    xcopy %~dp0\temp\imageres1.dll %~dp0\temp\imageres.dll /c /y /h
    echo .....................
    %~dp0\ResHacker.exe -addoverwrite %~dp0\temp\imageres.dll, %~dp0\temp\imageres1.dll, %~dp0\cat.jpg, image, 5052,
    xcopy %~dp0\temp\imageres1.dll %~dp0\temp\imageres.dll /c /y /h
    echo ......................
    %~dp0\ResHacker.exe -addoverwrite %~dp0\temp\imageres.dll, %~dp0\temp\imageres1.dll, %~dp0\cat.jpg, image, 5053,
    xcopy %~dp0\temp\imageres1.dll %~dp0\temp\imageres.dll /c /y /h
    echo .......................
    %~dp0\ResHacker.exe -addoverwrite %~dp0\temp\imageres.dll, %~dp0\temp\imageres1.dll, %~dp0\cat.jpg, image, 5054,
    xcopy %~dp0\temp\imageres1.dll %~dp0\temp\imageres.dll /c /y /h
    echo ........................
    %~dp0\ResHacker.exe -addoverwrite %~dp0\temp\imageres.dll, %~dp0\temp\imageres1.dll, %~dp0\cat.jpg, image, 5055,
    xcopy %~dp0\temp\imageres1.dll %~dp0\temp\imageres.dll /c /y /h
    echo ........................
    %~dp0\ResHacker.exe -addoverwrite %~dp0\temp\imageres.dll, %~dp0\temp\imageres1.dll, %~dp0\cat.jpg, image, 5056,
    echo ........................."100%"




    echo step 7 copy modified file back to origanel location

    xcopy %~dp0\temp\imageres.dll %windir%\system32\imageres.dll /c /y

    PAUSE > NUL

    echo cleanup delete temp folder
    del /q %~dp0\temp | echo attemped delete of temp folder

    PAUSE > NUL

    @rem IF EXIST "%~dp0\temp\" ( del /q "%~dp0\temp\" | delete command used ) ELSE ( echo file or folder still exists )

    PAUSE > NUL

    start /b explorer.exe
    start /b rundll32.exe
    start /b procexp64.exe

    echo proccess finnished
    echo.
    echo press anykey
    PAUSE > NUL


    :Selection4

    and so on

    :Selection5

    and so on

    :Selection6

    and so on

    :Selection7

    and so on

    :Selection8

    and so on

    :Selection9

    and so on

    echo back to menu
    PUASE>NUL
    goto menu
    CLS

    :Quit
    cls

    ECHO ==============THANKYOU===============
    ECHO -------------------------------------
    ECHO ======PRESS ANY KEY TO CONTINUE======

    PAUSE>NUL
    EXIT

    ==============================================================

    thank you for checking it out.

    snowcatman

      Topic Starter


      Beginner

      • Experience: Beginner
      • OS: Windows 8
      Re: batch file logging windows 7 home how to question
      « Reply #1 on: March 08, 2014, 04:07:09 PM »
      I know i am replying to my own post put was thinking i have a template script and it seem to not work out either. put it doesn't freeze up. i get the log.log but nothing is in it. i was thinking i should see something. right?


      ==============================================================

      @ECHO OFF

      defualt batch script.bat>>log.log

      CLS
      ECHO For windows 7 home
      ECHO Warning: Can not just be administrator.
      ECHO You need to exit and start this
      ECHO file with owner administrator privileges.
      ecHO The one you unhide and secured right?
      ECHO You also need to start the patch file with
      ECHO administrator privilages.
      ECHO If you already have just countinue.
      ECHO Thank You
      echo.
      ECHO Press ctrl and c to quit or
      echo Press Anykey to continue
      PAUSE > NUL

      :MENU
      CLS

      ECHO ============= MENU NAME =============
      ECHO -------------------------------------
      ECHO 1.  READ ME FIRST
      ECHO -------------------------------------
      ECHO 2.  Selection 2
      ECHO -------------------------------------
      ECHO 3.  Selection 3
      ECHO -------------------------------------
      ECHO 4.  Selection 4
      ECHO -------------------------------------
      ECHO 5.  Selection 5
      ECHO -------------------------------------
      ECHO 6.  Selection 6
      ECHO -------------------------------------
      ECHO 7.  Selection 7
      ECHO -------------------------------------
      ECHO 8.  Selection 8
      ECHO -------------------------------------
      ECHO 9.  Selection 9
      ECHO -------------------------------------
      ECHO ==========PRESS 'Q' TO QUIT==========
      ECHO.

      SET INPUT=
      SET /P INPUT=Please select a number:

      IF /I '%INPUT%'=='1' GOTO Selection1
      IF /I '%INPUT%'=='2' GOTO Selection2
      IF /I '%INPUT%'=='3' GOTO Selection3
      IF /I '%INPUT%'=='4' GOTO Selection4
      IF /I '%INPUT%'=='5' GOTO Selection5
      IF /I '%INPUT%'=='6' GOTO Selection6
      IF /I '%INPUT%'=='7' GOTO Selection7
      IF /I '%INPUT%'=='8' GOTO Selection8
      IF /I '%INPUT%'=='9' GOTO Selection9
      IF /I '%INPUT%'=='0' GOTO Selection9

      IF /I '%INPUT%'=='q' GOTO Quit

      CLS

      ECHO ============INVALID INPUT============
      ECHO -------------------------------------
      ECHO Please select a number from the Main
      echo Menu [1-9] or select 'q' to quit.
      ECHO -------------------------------------
      ECHO ======PRESS ANY KEY TO CONTINUE======

      PAUSE > NUL
      GOTO MENU

      :Selection1

      cls
      echo Ok this is to change your wallpaper on your login screen as if you were to do it manually.
      echo Even though we are doing it in a patch file.
      echo I am in the beginning stages of making this work. The reason I made the script the way I
      echo did is to see and know what I am doing with it. I need to see the errors and know if there needs to be a change.
      echo.
      echo the script is full of pauses and you need to tap on the enter key once or twice to see the script move on
      echo.
      echo if you see a drive letter the just type "exit" and the script will continue.
      echo.
      echo it may ask if you are making a folder or a file i choose "file"
      echo.
      echo it needs some touch up so don't nock it for what it is. think if you had
      echo to do it mannually in a batch file how would you do it.
      echo.
      echo also if you make any changes to these files please zip the folder back up and send it my way. thank you
      echo [email protected]
      echo.
      echo thank you.
      echo Press Any Key when done Reading!
      echo.
      PAUSE > NUL
      Goto Menu

      :Selection2

      echo processing

      C:\Windows\System32\cmd.exe /k %windir%\System32\reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA /t REG_DWORD /d 0 /f

      ok at some point i want to reverse what i just done.

      echo 2
      echo press anykey
      PAUSE > NUL
      GOTO MENU

      :Selection3

      cls
      echo 3
      echo press anykey
      PAUSE > NUL
      GOTO MENU

      :Selection4

      cls
      echo 4
      echo press anykey
      PAUSE > NUL
      GOTO MENU

      :Selection5

      cls
      echo 5
      echo press anykey
      PAUSE > NUL
      GOTO MENU

      :Selection6

      cls
      echo 6
      echo press anykey
      PAUSE > NUL
      GOTO MENU

      :Selection7

      cls
      echo 7
      echo press anykey
      PAUSE > NUL
      GOTO MENU

      :Selection8

      cls
      echo 8
      echo press anykey
      PAUSE > NUL
      GOTO MENU

      :Selection9

      cls
      echo 9
      echo press anykey
      PAUSE > NUL
      GOTO MENU

      :Quit
      CLS

      ECHO ==============THANKYOU===============
      ECHO -------------------------------------
      ECHO ======PRESS ANY KEY TO CONTINUE======

      PAUSE>NUL
      EXIT

      ==============================================================

      once i see i have my thoughts about me i was going to make a cleaned up version of the batch. but i see that i am just learning and doing it over again better. i hope. thank  you.
      « Last Edit: March 08, 2014, 04:32:21 PM by snowcatman »

      Salmon Trout

      • Guest
      Re: batch file logging windows 7 home how to question
      « Reply #2 on: March 08, 2014, 05:40:03 PM »
      patch NEQ batch.

      Salmon Trout

      • Guest
      Re: batch file logging windows 7 home how to question
      « Reply #3 on: March 08, 2014, 05:43:30 PM »
      defualt batch script.bat>>log.log

      What is that line supposed to do?

      snowcatman

        Topic Starter


        Beginner

        • Experience: Beginner
        • OS: Windows 8
        Re: batch file logging windows 7 home how to question
        « Reply #4 on: March 08, 2014, 07:49:27 PM »
        logonwallpaper.bat 1> output.txt 2> error.txt
        or
        defualt batch script.bat>>log.log
        is me flirting with the commands to log to file of the batch files
        like in this link
        http://www.msfn.org/board/topic/22253-how-to-log-the-results-of-a-dos-batch-file/
        i am learning here and if i get this right  ">"  clears and logs to a file and  ">>"  appends to a file.

        but my first post is not doing anything and i was wondering what i was doing wrong.
        and my second post is not leaving anything to my log files. so i am in hopes that someone can tell me what simple step i am missing.
        thank you

        defualt.batch.script.bat>>log.log
        i did do this to see if the spaces were the problem but no changes happened. still no info in the log

        foxidrive



          Specialist
        • Thanked: 268
        • Experience: Experienced
        • OS: Windows 8
        Re: batch file logging windows 7 home how to question
        « Reply #5 on: March 09, 2014, 12:21:39 AM »
        Code: [Select]
        @ECHO OFF
        logonwallpaper.bat 1> output.txt 2> error.txt

        Is this batch file above called logonwallpaper.bat

        If so then the 2nd line in the code will launch the same batch file again and again, and never stop.  Nothing will happen.

        If logonwallpaper.bat is a different batch file, then it will launch and none of the code below that line will run, because CALL is needed to launch
        a batch file, so it then returns control to the original code.


        snowcatman

          Topic Starter


          Beginner

          • Experience: Beginner
          • OS: Windows 8
          Re: batch file logging windows 7 home how to question
          « Reply #6 on: March 09, 2014, 07:20:30 AM »
          Thank you fox drive.

          so if i dont want to use another file to log this one what do i do?
          1> output.txt 2> error.txt
          do i just forget the name of the file and run this?
          How do i log the file i am using i wonder? without creating another...

          foxidrive



            Specialist
          • Thanked: 268
          • Experience: Experienced
          • OS: Windows 8
          Re: batch file logging windows 7 home how to question
          « Reply #7 on: March 09, 2014, 08:34:50 AM »
          To log an entire batch file you use this at the command line or in a separate batch file:

          Code: [Select]
          logonwallpaper.bat 1>output.txt 2> error.txt
          The 1 is optional.

          But this will also remove any text that you want to see, and if you have an input command in the batch file then it is not the right way to log it.
          You use the technique above when the batch file is not interactive.

          To get around that you can use a tee filter
          Here is one in a separate batch file and you can use it like this: 
          Code: [Select]
          logonwallpaper.bat | batchtee logfile.txt

          Read the limitations in the batch code below, and there are other tee filters for modern Windows like Swiss File Knife on Sourceforge.


          Code: [Select]
          ::batchTee.bat  OutputFile  [+]
          ::
          ::  Write each line of stdin to both stdout and outputFile.
          ::  The default behavior is to overwrite any existing outputFile.
          ::  If the 2nd argument is + then the content is appended to any existing
          ::  outputFile.
          ::
          ::  Limitations:
          ::
          ::  1) Lines are limited to ~1000 bytes. The exact maximum line length varies
          ::     depending on the line number. The SET /P command is limited to reading
          ::     1021 bytes per line, and each line is prefixed with the line number when
          ::     it is read.
          ::
          ::  2) Trailing control characters are stripped from each line.
          ::
          ::  3) Lines will not appear on the console until a newline is issued, or
          ::     when the input is exhaused. This can be a problem if the left side of
          ::     the pipe issues a prompt and then waits for user input on the same line.
          ::     The prompt will not appear until after the input is provided.
          ::

          @echo off
          setlocal enableDelayedExpansion
          if "%~1" equ ":tee" goto :tee

          :lock
          set "teeTemp=%temp%\tee%time::=_%"
          2>nul (
            9>"%teeTemp%.lock" (
              for %%F in ("%teeTemp%.test") do (
                set "yes="
                pushd "%temp%"
                copy /y nul "%%~nxF" >nul
                for /f "tokens=2 delims=(/" %%A in (
                  '^<nul copy /-y nul "%%~nxF"'
                ) do if not defined yes set "yes=%%A"
                popd
              )
              for /f %%A in ("!yes!") do (
                  find /n /v ""
                   echo :END
                   echo %%A
                ) >"%teeTemp%.tmp" | <"%teeTemp%.tmp" "%~f0" :tee %* 7>&1 >nul
              (call )
            ) || goto :lock
          )
          del "%teeTemp%.lock" "%teeTemp%.tmp" "%teeTemp%.test"
          exit /b

          :tee
          set "redirect=>"
          if "%~3" equ "+" set "redirect=>>"
          8%redirect% %2 (call :tee2)
          set "redirect="
          (echo ERROR: %~nx0 unable to open %2)>&7

          :tee2
          for /l %%. in () do (
            set "ln="
            set /p "ln="
            if defined ln (
              if "!ln:~0,4!" equ ":END" exit
              set "ln=!ln:*]=!"
              (echo(!ln!)>&7
              if defined redirect (echo(!ln!)>&8
            )
          )


          snowcatman

            Topic Starter


            Beginner

            • Experience: Beginner
            • OS: Windows 8
            Re: batch file logging windows 7 home how to question
            « Reply #8 on: March 09, 2014, 09:26:47 AM »
            ok i uncled a little and made a test.batch with: defualt.batch.script.bat 1> output.txt 2> error.txt

            but it did not bring up the second cmd window. and the log file did show my echo's so now i must have a cmd window in the background just sitting waiting for input or not.

            As you can tell this is an interactive script. so i was hoping that i could just log it. but so far it seems i have yet to learn what i need at this time, logging. i have pieced this together this. test.bat
                   cmd /k %~dp0\defualt.batch.script.bat 1>> output.txt 2>> error.txt   ~~~ just sat there too. did append to log files first echos in my script.

            so do i append  of a command every time? do i have to do this with multiple files or is there a way to do it from the first batch file i am using interactively?

            log after command
            echo test>>log.log 2>&1
            mycmd 2>&1 | othercmd
            or
            log one batch with another batch file "a" runs batch file "b"
            cmd /k %~dp0\defualt.batch.script.bat 1>> output.txt 2>> error.txt
            or
            is there a way to do it from batch file "a" altogether interactively?
            ???

            ==================================================
            thank you "foxidrive" i think you set me in the right direction if not answered my question.
            i ran a test of what you posted and just to see what i could see.
            the error log seem to put what was echoed, but very little on the errors. again my learning curve gets in the way. i have been piecing this together. not going to claim it as my own put will say i was learning and this is what i came up with along the way. i guess i want to understand what i am seeing. is there a way to see the errors to. i understand you mentioned there are limitations..
            looking and reading what you posted still. forgive my rudeness please.

            foxidrive



              Specialist
            • Thanked: 268
            • Experience: Experienced
            • OS: Windows 8
            Re: batch file logging windows 7 home how to question
            « Reply #9 on: March 09, 2014, 09:55:25 AM »
            One of the most useful things you can learn is that long filenames with spaces etc can be wrapped in double quotes, and that is how they are used.

            As an example in your code you use this, and your batch file will fail if you launch in in a folder with spaces, or where there are any folders below it with spaces.  Or & characters.

            Code: [Select]
            %~dp0\reshacker
            but if you use double quotes around the path\filenames then it will always work correctly.

            Code: [Select]
            "%~dp0\ResHacker.exe"
            As for logging individual lines, you can use this, assuming your commands are correct: note all the double quotes.

            Code: [Select]
            2>>"error.log" "%~dp0\ResHacker.exe" -addoverwrite "%~dp0\temp\imageres.dll", "%~dp0\temp\imageres1.dll", "%~dp0\cat.jpg", image, 5031,
            2>>"error.log' xcopy "%~dp0\temp\imageres1.dll" "%~dp0\temp\imageres.dll" /c /y /h

            In that way you allow regular text to appear on the console and error messages will appear in the error.log file. 
            Note that double quotes can be used on short filenames as well, so you never have to think about where they should be used, you can always use them.

            Another thing that Salmon Trout brought up - these are not called a patch file, they are called a Batch file.  It is essentially a batch of commands.

            snowcatman

              Topic Starter


              Beginner

              • Experience: Beginner
              • OS: Windows 8
              Re: batch file logging windows 7 home how to question
              « Reply #10 on: March 09, 2014, 10:11:56 AM »
              your one step ahead of me. thank you. "foxidrive"
              ok you posted before me. np. i will make those changes will take some time. I catch myself in a lot of spelling mistakes. yes i use patch and batch wrong. thank you for pointing that out. "Salmon Trout"
              i will repost this when i am done and after a test drive thank you.

              Think if i talk about the rest of my code i might need to start another post.
              I have been cleaning it up.
              but just for the record. i get to a certain point all seems to stop no error code just what was last echoed. the log shows no error.

              :: THIS IS RATHER LONG...
              :: In a external usb hard drive I have a folder
              :: I have windows 7 home. As owner admin I did a ver. in the cmd.exe, results were "Microsoft Windows [version 6.1.7601]"
              ::A picture that meets windows requirements in said folder
              :: I am using "resource hacker [version 3.6.0.92] by angus johnson" in said folder
              :: using the script provided "batchTee.bat" in said folder.  thank you "foxidrive" i omitted reposting that file for you already posted it. there were no changes to name or content. a shorter post this way. feel like i am righting a book. smiles
              ================================================================
              :: start me first.bat
              logonwallpaper.bat | batchtee logfile.txt
              ================================================================
              :: this worked well in my book like a breath of fresh air
              :: just dont see the errors yet
              ================================================================
              :: logonwallpaper.bat
              @ECHO OFF

              CLS
              ECHO For windows 7 home
              ECHO Warning: Can not just be administrator.
              ECHO You need to exit and start this
              ECHO file with owner administrator privileges.
              ecHO The one you unhide and secured right?
              ECHO You also need to start the patch file with
              ECHO administrator privilages.
              ECHO If you already have just countinue.
              ECHO Thank You
              echo.
              ECHO Press ctrl and c to quit or
              echo Press Anykey to continue
              PAUSE > NUL

              :MENU
              CLS

              ECHO ============= MENU NAME =============
              ECHO -------------------------------------
              ECHO 1.  READ ME FIRST
              ECHO -------------------------------------
              ECHO 2.  Set Logon Wallpaper
              ECHO -------------------------------------
              ECHO 3.  test
              ECHO -------------------------------------
              ECHO 4.  Selection 4
              ECHO -------------------------------------
              ECHO 5.  Selection 5
              ECHO -------------------------------------
              ECHO 6.  Selection 6
              ECHO -------------------------------------
              ECHO 7.  Selection 7
              ECHO -------------------------------------
              ECHO 8.  Selection 8
              ECHO -------------------------------------
              ECHO 9.  Selection 9
              ECHO -------------------------------------
              ECHO ==========PRESS 'Q' TO QUIT==========
              ECHO.

              SET INPUT=
              SET /P INPUT=Please select a number:

              IF /I '%INPUT%'=='1' GOTO Selection1
              IF /I '%INPUT%'=='2' GOTO Selection2
              IF /I '%INPUT%'=='3' GOTO Selection3
              IF /I '%INPUT%'=='4' GOTO Selection4
              IF /I '%INPUT%'=='5' GOTO Selection5
              IF /I '%INPUT%'=='6' GOTO Selection6
              IF /I '%INPUT%'=='7' GOTO Selection7
              IF /I '%INPUT%'=='8' GOTO Selection8
              IF /I '%INPUT%'=='9' GOTO Selection9
              IF /I '%INPUT%'=='0' GOTO Selection9

              IF /I '%INPUT%'=='q' GOTO Quit

              CLS

              ECHO ============INVALID INPUT============
              ECHO -------------------------------------
              ECHO Please select a number from the Main
              echo Menu [1-9] or select 'q' to quit.
              ECHO -------------------------------------
              ECHO ======PRESS ANY KEY TO CONTINUE======

              PAUSE > NUL
              GOTO MENU

              :Selection1

              cls
              echo Ok this is to change your wallpaper on your login screen as if you were to do it manually.
              echo Even though we are doing it in a patch file.
              echo I am in the beginning stages of making this work. The reason I made the script the way I
              echo did is to see and know what I am doing with it. I need to see the errors and know if there needs to be a change.
              echo.
              echo the script is full of pauses and you need to tap on the enter key once or twice to see the script move on
              echo.
              echo if you see a drive letter the just type "exit" and the script will continue.
              echo.
              echo it may ask if you are making a folder or a file i choose "file"
              echo.
              echo it needs some touch up so don't nock it for what it is. think if you had
              echo to do it mannually in a batch file how would you do it.
              echo.
              echo also if you make any changes to these files please zip the folder back up and send it my way. thank you
              echo [email protected]
              echo.
              echo thank you.
              echo Press Any Key when done Reading!
              echo.
              PAUSE > NUL
              Goto Menu

              :Selection2

              cls
              echo processing
              echo.
              echo set UAC to disable
              %windir%\System32\reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA /t REG_DWORD /d 0 /f
              ECHO.
              echo press anykey
              PAUSE > NUL

              cls
              ECHO KILLING PROCESSES NEEDED FOR Modifying imageres.dll
              @REM need to make this an if statement if process is running kill it other wise next
              taskkill /f /IM explorer.exe
              taskkill /f /IM rundll32.exe
              taskkill /f /IM procexp64.exe
              ECHO.
              echo press anykey
              PAUSE > NUL

              cls
              echo Take Ownership of imageres.dll
              TAKEOWN /F %windir%\system32\imageres.dll
              ICACLS %windir%\system32\imageres.dll /GRANT Administrator:F
              SET __COMPAT_LAYER=WINXPSP3
              ECHO.
              echo press anykey
              PAUSE > NUL

              cls
              echo Make back up of imageres.dll
              xcopy %windir%\system32\imageres.dll "%windir%\system32\imageres.dll.old" /c /y /h | echo make backup copy attempted
              ECHO.
              echo press anykey
              PAUSE > NUL

              cls
              echo Copy imagerers file to folder
              copy %windir%\system32\imageres.dll %~dp0\ | echo attempted copy imageres file to this folder
              ECHO.
              echo press anykey
              PAUSE > NUL

              cls
              Echo Delete imagers file in system folder
              attrib -r -s -h "%windir%\system32\imageres.dll" | echo attrib changed attempted
              del /q /f "%windir%\system32\imageres.dll" | echo imageres.ddl delete attempted in the system folder
              ECHO.
              echo press anykey
              PAUSE > NUL

              cls
              echo step 6 overwrite image to file
              echo [[[ this may take some time pending on you computor processing power]]]
              %~dp0\ResHacker.exe -addoverwrite %~dp0\imageres.dll, %~dp0\imageres1.dll, %~dp0\cat.jpg, image, 5031,
              xcopy %~dp0\imageres1.dll %~dp0\imageres.dll /c /y /h
              echo .
              %~dp0\ResHacker.exe -addoverwrite %~dp0\imageres.dll, %~dp0\imageres1.dll, %~dp0\cat.jpg, image, 5032,
              xcopy %~dp0\imageres1.dll %~dp0\imageres.dll /c /y /h
              echo ..
              %~dp0\ResHacker.exe -addoverwrite %~dp0\imageres.dll, %~dp0\imageres1.dll, %~dp0\cat.jpg, image, 5033,
              xcopy %~dp0\imageres1.dll %~dp0\imageres.dll /c /y /h
              echo ...
              %~dp0\ResHacker.exe -addoverwrite %~dp0\imageres.dll, %~dp0\imageres1.dll, %~dp0\cat.jpg, image, 5034,
              xcopy %~dp0\imageres1.dll %~dp0\imageres.dll /c /y /h
              echo ....
              %~dp0\ResHacker.exe -addoverwrite %~dp0\imageres.dll, %~dp0\imageres1.dll, %~dp0\cat.jpg, image, 5035,
              xcopy %~dp0\imageres1.dll %~dp0\imageres.dll /c /y /h
              echo .....
              %~dp0\ResHacker.exe -addoverwrite %~dp0\imageres.dll, %~dp0\imageres1.dll, %~dp0\cat.jpg, image, 5036,
              xcopy %~dp0\imageres1.dll %~dp0\imageres.dll /c /y /h
              echo ......
              %~dp0\ResHacker.exe -addoverwrite %~dp0\imageres.dll, %~dp0\imageres1.dll, %~dp0\cat.jpg, image, 5037,
              xcopy %~dp0\imageres1.dll %~dp0\imageres.dll /c /y /h
              echo .......
              %~dp0\ResHacker.exe -addoverwrite %~dp0\imageres.dll, %~dp0\imageres1.dll, %~dp0\cat.jpg, image, 5038,
              xcopy %~dp0\imageres1.dll %~dp0\imageres.dll /c /y /h
              echo ........
              %~dp0\ResHacker.exe -addoverwrite %~dp0\imageres.dll, %~dp0\imageres1.dll, %~dp0\cat.jpg, image, 5039,
              xcopy %~dp0\imageres1.dll %~dp0\imageres.dll /c /y /h
              echo ........."25%"
              %~dp0\ResHacker.exe -addoverwrite %~dp0\imageres.dll, %~dp0\imageres1.dll, %~dp0\cat.jpg, image, 5040,
              xcopy %~dp0\imageres1.dll %~dp0\imageres.dll /c /y /h
              echo ..........
              %~dp0\ResHacker.exe -addoverwrite %~dp0\imageres.dll, %~dp0\imageres1.dll, %~dp0\cat.jpg, image, 5041,
              xcopy %~dp0\imageres1.dll %~dp0\imageres.dll /c /y /h
              echo ...........
              %~dp0\ResHacker.exe -addoverwrite %~dp0\imageres.dll, %~dp0\imageres1.dll, %~dp0\cat.jpg, image, 5042,
              xcopy %~dp0\imageres1.dll %~dp0\imageres.dll /c /y /h
              echo ............
              %~dp0\ResHacker.exe -addoverwrite %~dp0\imageres.dll, %~dp0\imageres1.dll, %~dp0\cat.jpg, image, 5043,
              xcopy %~dp0\imageres1.dll %~dp0\imageres.dll /c /y /h
              echo .............
              %~dp0\ResHacker.exe -addoverwrite %~dp0\imageres.dll, %~dp0\imageres1.dll, %~dp0\cat.jpg, image, 5044,
              xcopy %~dp0\imageres1.dll %~dp0\imageres.dll /c /y /h
              echo ..............
              %~dp0\ResHacker.exe -addoverwrite %~dp0\imageres.dll, %~dp0\imageres1.dll, %~dp0\cat.jpg, image, 5045,
              xcopy %~dp0\imageres1.dll %~dp0\imageres.dll /c /y /h
              echo ..............."50%"
              %~dp0\ResHacker.exe -addoverwrite %~dp0\imageres.dll, %~dp0\imageres1.dll, %~dp0\cat.jpg, image, 5046,
              xcopy %~dp0\imageres1.dll %~dp0\imageres.dll /c /y /h
              echo ................
              %~dp0\ResHacker.exe -addoverwrite %~dp0\imageres.dll, %~dp0\imageres1.dll, %~dp0\cat.jpg, image, 5047,
              xcopy %~dp0\imageres1.dll %~dp0\imageres.dll /c /y /h
              echo .................
              %~dp0\ResHacker.exe -addoverwrite %~dp0\imageres.dll, %~dp0\imageres1.dll, %~dp0\cat.jpg, image, 5048,
              xcopy %~dp0\imageres1.dll %~dp0\imageres.dll /c /y /h
              echo ..................
              %~dp0\ResHacker.exe -addoverwrite %~dp0\imageres.dll, %~dp0\imageres1.dll, %~dp0\cat.jpg, image, 5049,
              xcopy %~dp0\imageres1.dll %~dp0\imageres.dll /c /y /h
              echo ...................
              %~dp0\ResHacker.exe -addoverwrite %~dp0\imageres.dll, %~dp0\imageres1.dll, %~dp0\cat.jpg, image, 5050,
              xcopy %~dp0\imageres1.dll %~dp0\imageres.dll /c /y /h
              echo ...................."75%"
              %~dp0\ResHacker.exe -addoverwrite %~dp0\imageres.dll, %~dp0\imageres1.dll, %~dp0\cat.jpg, image, 5051,
              xcopy %~dp0\imageres1.dll %~dp0\imageres.dll /c /y /h
              echo .....................
              %~dp0\ResHacker.exe -addoverwrite %~dp0\imageres.dll, %~dp0\imageres1.dll, %~dp0\cat.jpg, image, 5052,
              xcopy %~dp0\imageres1.dll %~dp0\imageres.dll /c /y /h
              echo ......................
              %~dp0\ResHacker.exe -addoverwrite %~dp0\imageres.dll, %~dp0\imageres1.dll, %~dp0\cat.jpg, image, 5053,
              xcopy %~dp0\imageres1.dll %~dp0\imageres.dll /c /y /h
              echo .......................
              %~dp0\ResHacker.exe -addoverwrite %~dp0\imageres.dll, %~dp0\imageres1.dll, %~dp0\cat.jpg, image, 5054,
              xcopy %~dp0\imageres1.dll %~dp0\imageres.dll /c /y /h
              echo ........................
              %~dp0\ResHacker.exe -addoverwrite %~dp0\imageres.dll, %~dp0\imageres1.dll, %~dp0\cat.jpg, image, 5055,
              xcopy %~dp0\imageres1.dll %~dp0\imageres.dll /c /y /h
              echo ........................
              %~dp0\ResHacker.exe -addoverwrite %~dp0\imageres.dll, %~dp0\imageres1.dll, %~dp0\cat.jpg, image, 5056,
              echo ........................."100%"
              ECHO.
              echo press anykey
              PAUSE > NUL

              cls
              echo Copy modified imageres file back to systems folder
              xcopy %~dp0\imageres.dll %windir%\system32\imageres.dll /c /y | echo copy attempt of imageres file back to system folder
              ECHO.
              echo press anykey
              PAUSE > NUL

              cls
              echo Set Back Ownership of imageres.dll
              @rem got to learn some day soon.
              ECHO.
              echo press anykey
              PAUSE > NUL

              cls
              ECHO STARTING PROCESSES NEEDED FOR Modifying imageres.dll
              @REM need to make this an if statement if process is not running start it other wise next. note it shouls start if was stopped really.
              start /b explorer.exe
              start /b rundll32.exe
              start /b procexp64.exe
              ECHO.
              echo press anykey
              PAUSE > NUL

              cls
              echo.
              echo set UAC to enable
              %windir%\System32\reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA /t REG_DWORD /d 1 /f

              cls
              ECHO.
              echo Processing Ended
              ECHO.
              echo press anykey
              PAUSE > NUL
              GOTO MENU

              :Selection3

              cls

              echo test 2>&1 | echo tested
              xcopy  %~dp0\no.jpg %~dp0\ non.jpg 2<&1 test.log | echo tested

              echo 3
              echo press anykey
              PAUSE > NUL
              GOTO MENU

              :Selection4

              cls
              echo 4
              echo press anykey
              PAUSE > NUL
              GOTO MENU

              :Selection5

              cls
              echo 5
              echo press anykey
              PAUSE > NUL
              GOTO MENU

              :Selection6

              cls
              echo 6
              echo press anykey
              PAUSE > NUL
              GOTO MENU

              :Selection7

              cls
              echo 7
              echo press anykey
              PAUSE > NUL
              GOTO MENU

              :Selection8

              cls
              echo 8
              echo press anykey
              PAUSE > NUL
              GOTO MENU

              :Selection9

              cls
              echo 9
              echo press anykey
              PAUSE > NUL
              GOTO MENU

              :Quit
              CLS

              ECHO ==============THANKYOU===============
              ECHO -------------------------------------
              ECHO ======PRESS ANY KEY TO CONTINUE======

              PAUSE>NUL
              EXIT
              ===========================================================
              :: logfile.txt
              ===========================================================
              For windows 7 home
              Warning: Can not just be administrator.
              You need to exit and start this
              file with owner administrator privileges.
              The one you unhide and secured right?
              You also need to start the patch file with
              administrator privilages.
              If you already have just countinue.
              Thank You

              Press ctrl and c to quit or
              Press Anykey to continue
              ============= MENU NAME =============
              -------------------------------------
              1.  READ ME FIRST
              -------------------------------------
              2.  Set Logon Wallpaper
              -------------------------------------
              3.  test
              -------------------------------------
              4.  Selection 4
              -------------------------------------
              5.  Selection 5
              -------------------------------------
              6.  Selection 6
              -------------------------------------
              7.  Selection 7
              -------------------------------------
              8.  Selection 8
              -------------------------------------
              9.  Selection 9
              -------------------------------------
              ==========PRESS 'Q' TO QUIT==========

              Please select a number: processing

              set UAC to disable
              The operation completed successfully.

              press anykey
              KILLING PROCESSES NEEDED FOR Modifying imageres.dll
              SUCCESS: The process "explorer.exe" with PID 1584 has been terminated.

              press anykey
              Take Ownership of imageres.dll

              SUCCESS: The file (or folder): "C:\Windows\system32\imageres.dll" now owned by user "snowballs01\a".
              processed file: C:\Windows\system32\imageres.dll
              Successfully processed 1 files; Failed processing 0 files

              press anykey
              Make back up of imageres.dll
              make backup copy attempted

              ===========================================================
              so far that what i got
              in folder listed
              folder --> imageres contants
              folder --> old files
              batchTea.bat
              cat.jpg
              logfile.txt
              logonwallpaper.bat
              ResHacker.exe
              ResHacker.ini
              ResHacker.log
              start me first.bat
              ----------------------------------------------
              hope i provided enough information. again thank you.

              Salmon Trout

              • Guest
              Re: batch file logging windows 7 home how to question
              « Reply #11 on: March 09, 2014, 10:34:21 AM »
              IF /I '%INPUT%'=='1'

              How many cases can a number have?

              snowcatman

                Topic Starter


                Beginner

                • Experience: Beginner
                • OS: Windows 8
                Re: batch file logging windows 7 home how to question
                « Reply #12 on: March 09, 2014, 11:50:31 AM »
                i expect or assume that if a file already exist's it get's overwritten imageres.dll.old

                cls
                echo Make back up of imageres.dll
                2>>"error.log" "xcopy" "%windir%\system32\imageres.dll" "%windir%\system32\imageres.dll.old" /c /y /h | echo make backup copy attempted
                ECHO.
                echo press anykey
                PAUSE > NUL

                when in xcopy it freezes and in copy it closes the cmd window.
                when look at the log i get this:
                nothing for xcopy, but the with copy i get this---
                ['"copy"' is not recognized as an internal or external command,
                operable program or batch file.]
                my fault i should have know better.
                thank you i see the error batch logging starting to work.

                snowcatman

                  Topic Starter


                  Beginner

                  • Experience: Beginner
                  • OS: Windows 8
                  Re: batch file logging windows 7 home how to question
                  « Reply #13 on: March 09, 2014, 12:56:08 PM »
                  ok fixed my own stuff  :)

                  cls
                  echo Make back up of imageres.dll
                  2>>"error.log" copy "%windir%\system32\imageres.dll" "%windir%\system32\imageres.dll.old" /c /y /h | echo make backup copy attempted
                  ECHO.
                  echo press anykey
                  PAUSE > NUL

                  do you see what i did. xcopy will ask if it is a file or folder. copy already thinks it a file

                  foxidrive



                    Specialist
                  • Thanked: 268
                  • Experience: Experienced
                  • OS: Windows 8
                  Re: batch file logging windows 7 home how to question
                  « Reply #14 on: March 09, 2014, 06:44:28 PM »
                  Salmon Trout pointed this style of line out:

                  Code: [Select]
                  IF /I '%INPUT%'=='1'
                  and it is wiser to use double quotes as below so that a blank enter, or a space, will not break the input checking.  The /I is not needed for numerals, but it won't hurt either.

                  Code: [Select]
                  IF /I "%INPUT%"=="1"
                  You have many instances of %~dp0\filename  which also need double quotes to make the batch file robust.  Even the lone %~dp0\ needs double quotes, see examples below:

                  Code: [Select]
                  "%~dp0\filename"
                  "%~dp0\"

                  In a number of places you are piping through an echo command, and that isn't usual practice.

                  copy %windir%\system32\imageres.dll %~dp0\ | echo attempted copy imageres file to this folder

                  The line above is usually written in this style: where the >nul eliminates the normal text to the screen and you can add
                  the 2>>"error.log" if you want to log any error messages.  Note the double quotes.

                  Code: [Select]
                  copy "%windir%\system32\imageres.dll" "%~dp0\" >nul
                  echo attempted copy imageres file to this folder