[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Script to write user name and computer name to file

Posted on 2009-04-07
4
Medium Priority
?
467 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 2000 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
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 will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Integration Management Part 2
Suggested Courses

834 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