Solved

Script to write user name and computer name to file

Posted on 2009-04-07
4
414 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Script to copy or move mouse-selected collection of files plus targets referenced by shortcuts (.lnk) The purpose of this article is to help illuminate the real challenges and options available (where they may exist) for utilizing simple scriptin…
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now