Log User Input

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
alleypuppy
Posts: 82
Joined: 24 Apr 2011 19:20

Log User Input

#1 Post by alleypuppy » 18 May 2011 17:23

Hello, fellow Batch writers!

I'm working on a messenger batch file and I would like to log up to 10 recent recipients. However, I have never written a Batch file that logs data, so I'm not sure how to do it.

I searched Google for an answer, but I couldn't find what I'm looking for.

Here's the file:


    @echo off
    title Messenger
    sc config messenger start= demand
    sc start messenger
    cls
    echo Welcome to Messenger!
    echo.
    set /p command=Computer Name or Internal IP Address:
    echo.
    set /p message=Message:
    net send %command% %message%
    echo.
    echo Press "Enter" to send another message to the same computer, type "r" to view
    echo recent recipients, or enter the Computer Name or Internal IP Address of another
    echo computer to send a message to a different computer.
    echo.
    set /p command=^>
    if /I "%command%"=="r" goto C
    if /I "%command%"=="" goto A
    goto B

    :A
    Cls
    echo Recipient: %command%
    set /p message=Message:
    net send %command% %message%
    echo.
    echo Press "Enter" to send another message to the same computer, type "r" to view
    echo recent recipients, or enter the Computer Name or Internal IP Address of another
    echo computer to send a message to a different computer.
    echo.
    set /p command=^>
    if /I "%command%"=="r" goto C
    if /I "%command%"=="" goto A
    goto B

    :B
    cls
    echo Recipient: %command%
    echo.
    set /p message=Message:
    net send %command% %message%
    echo.
    echo Press "Enter" to send another message to the same computer, type "r" to view
    echo recent recipients, or enter the Computer Name or Internal IP Address of another
    echo computer to send a message to a different computer.
    echo.
    set /p command=^>
    if /I "%command%"=="r" goto C
    if /I "%command%"=="" goto A
    goto B

    :C
    cls
    type UserLog.log
    echo.
    echo.
    set /p command=Computer Name or Internal IP Address:
    goto B


If you want to test it, type in your internal IP address (the one your router gives you) or your computer name as the recipient.

Thanks for any help! :wink:

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: Log User Input

#2 Post by Ed Dyreen » 18 May 2011 18:52

Code: Select all

@echo off &SetLocal EnableExtensions EnableDelayedExpansion

>out.tmp (
     echo."heloo world !"
)
set /p ?=< "out.tmp"
echo.?=%?%_

set /p "?=input and press enter : " <nul
set /p "?=input and press enter : " >nul
echo.?=%?%_

pause
exit

alleypuppy
Posts: 82
Joined: 24 Apr 2011 19:20

Re: Log User Input

#3 Post by alleypuppy » 18 May 2011 19:59

Ed Dyreen wrote:

Code: Select all

@echo off &SetLocal EnableExtensions EnableDelayedExpansion

>out.tmp (
     echo."heloo world !"
)
set /p ?=< "out.tmp"
echo.?=%?%_

set /p "?=input and press enter : " <nul
set /p "?=input and press enter : " >nul
echo.?=%?%_

pause
exit


This isn't exactly what I'm looking for. I need the text that I type to be sent to the log file.

Also, is there any way to overwrite logs in the same file after 10 have been saved?

Post Reply