1.

Solve : Logging user/computer information with batch file?

Answer»

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 I forgot to mention that I'm running in Windows XP environment.

Thanks!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?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.logHOLY USERNAME LOGGING BATMAN! WORKS like a charm! Thanks so much! Glad it works. You're welcome.



Discussion

No Comment Found