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

Author Topic: Logging user/computer information with batch file  (Read 2489 times)

0 Members and 1 Guest are viewing this topic.

jsheehan223

  • Guest
Logging user/computer information with batch file
« on: May 10, 2007, 12:25:15 PM »
I've created a script that will perform a certain action, but I need to know who is using the script.  Is there a way to log PC and USER information in a log using a batch file?  Also, is there a way to make this silent?  Please let me know!  I've seen some things that can be used like 'net session' or whoami (available in resource kit - and 'nix flavors), but where ever I look, i can't find a way to log this information.  Any help would be greately appreciate!  Thanks in advance!  Jeremy  ;D

jsheehan223

  • Guest
Re: Logging user/computer information with batch file
« Reply #1 on: May 10, 2007, 12:27:49 PM »
I forgot to mention that I'm running in Windows XP environment.

Thanks!

jsheehan223

  • Guest
Re: Logging user/computer information with batch file
« Reply #2 on: May 10, 2007, 12:49:13 PM »
I did some digging and found some information that I could put into the batch file. 


net session \\127.0.0.1 >> mwarestart.log

ECHO --------------------- >> mwarestart.log

It worked on my PC, but when I tried it from another PC it didn't work.  Reason is that i have a share setup on my system and was connected to it.  Is there some other command other than 'net session' that I can use to get the user ID of who is running my batch file?

GuruGary



    Adviser
    Re: Logging user/computer information with batch file
    « Reply #3 on: May 10, 2007, 07:04:54 PM »
    I assume the other users that may be accessing the file are running Windows XP also?  If so, try adding this as your "log":
    Code: [Select]
    echo %0 is being run by user "%username%" on computer "%computername%" >> \\computer\share\mwarestart.log

    jsheehan223

    • Guest
    Re: Logging user/computer information with batch file
    « Reply #4 on: May 11, 2007, 06:04:46 AM »
    HOLY USERNAME LOGGING BATMAN!  Works like a charm!  Thanks so much! 

    GuruGary



      Adviser
      Re: Logging user/computer information with batch file
      « Reply #5 on: May 11, 2007, 09:07:37 AM »
      Glad it works.  You're welcome.