Solved

Script to write user name and computer name to file

Posted on 2009-04-07
4
452 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

705 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