|
-
May 5th, 2009, 08:02 AM
#3
Re: Log Windows username from HTML file into txt file
Done, just in case any1 need this:
Code:
<Script Language="VBScript">
Option Explicit
Dim objFSO, objFolder, objShell, objTextFile, objFile
Dim strDirectory, strFile, strText
Dim objNet
strDirectory = "C:\test"
strFile = "\log.txt"
On Error Resume Next
Set objNet = CreateObject("WScript.NetWork")
strText = Now & ";" & objNet.UserName & ";" &objNet.ComputerName & ";;;"
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FolderExists(strDirectory) Then
Set objFolder = objFSO.GetFolder(strDirectory)
Else
Set objFolder = objFSO.CreateFolder(strDirectory)
WScript.Echo "Just created " & strDirectory
End If
If objFSO.FileExists(strDirectory & strFile) Then
Set objFolder = objFSO.GetFolder(strDirectory)
Else
Set objFile = objFSO.CreateTextFile(strDirectory & strFile)
Wscript.Echo "Just created " & strDirectory & strFile
End If
set objFile = nothing
set objFolder = nothing
Const ForAppending = 8
Set objTextFile = objFSO.OpenTextFile _
(strDirectory & strFile, ForAppending, True)
objTextFile.WriteLine(strText)
objTextFile.Close
Set objNet = Nothing
WScript.Quit
</Script>
<HTML>
<HEAD> <title>UserInfo</title>
</HEAD>
<body scroll="no" leftmargin="0" topmargin="0"
This Should Log your username on a txt file called log.txt located in c:\test
</body>
</HTML>
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|