Solved

Script to write user name and computer name to file

Posted on 2009-04-07
4
434 Views
Last Modified: 2012-06-27
Hi All,

Can a scripting person assist by creating a Vb script that will

1. Create a file to a network share using \\server\share
2. Create the text file with the user name and Date as the file name
3. Save the User Name, Computer Name, Logon Time and Date on separate lines

User Name: Marvin
Computer Name: Themartian
Logon Time: 14:32
Date:  08/04/2009

Hope i am not asking to much.

Thanks

Aalborg

0
Comment
Question by:AI-SYD
  • 2
4 Comments
 
LVL 14

Accepted Solution

by:
yehudaha earned 500 total points
ID: 24094250
change this line the line of the share you want to save the file

strPath = "\\server\share"
strPath = "\\server\share"
Set objnet = CreateObject("wscript.network")
Set objfso = CreateObject("scripting.filesystemobject")
strDate = Day(Date) & "." & Month(Date) & "." & Year(Date)
Set objlog = objfso.CreateTextFile(strPath & "\" & objnet.UserName & "_" & strDate & ".txt",True)
objlog.WriteLine "User Name: " & objnet.UserName
objlog.WriteLine "Computer Name: " & objnet.ComputerName
objlog.WriteLine "Logon Time: " & Time
objlog.WriteLine "Date: " & Date

Open in new window

0
 
LVL 5

Expert Comment

by:mfhorizon
ID: 24094252
Hi Aalborg,

I think you need to create a cookie using vbscript, that can save different events like name, time etc. You can do it by using following script:

VBScript
=======
Creating a cookie in VBScript uses the document.cookie object:

<SCRIPT LANGUAGE="VBScript">
document.cookie = "User_Name=Marvin; &_
                                path=/; &_
                                expires Sat, 01-Jan-2010 00:00:00 GMT"
document.cookie = "Computer_Name=Themartian; &_
                                path=/; &_
                                expires Sat, 01-Jan-2010 00:00:00 GMT"

document.cookie = "Logon_Date=Date; &_
                                path=/; &_
                                expires Sat, 01-Jan-2010 00:00:00 GMT"
document.cookie = "Logon_Time=Time; &_
                                path=/; &_
                                expires Sat, 01-Jan-2010 00:00:00 GMT"
</SCRIPT>


To retreive these values next time on your website you can use
NameVariable = getCookie("User_Name")
ComputerNameVariable = getCookie("Computer_Name")
TimeVariable = getCookie("Logon_Time")
DateVariable = getCookie("Logon_Date")


0
 

Author Closing Comment

by:AI-SYD
ID: 31567888
Thanks it worked perfectly.
0
 
LVL 14

Expert Comment

by:yehudaha
ID: 24094443
glad to help
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is an addendum to the following article: Acitve Directory based Outlook Signature (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_24950055.html) The script is fine, and works in normal client-server domains…
This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question