Const ForAppending = 8
strLog = "aaa.txt"
'Retrieves values of environment variables
Set objShell = WScript.CreateObject("WScript.Shell")
strUserName = objShell.ExpandEnvironmentStrings("%username%")
strComputerName = objShell.ExpandEnvironmentStrings("%computername%")
strHomeShare = objShell.ExpandEnvironmentStrings("%homeshare%")
strHomeDrive = objShell.ExpandEnvironmentStrings("%homedrive%")
strOutput = strUserName & ", " & strComputerName & ", " & Time & ", " & _
Date & ", " & strHomeShare & ", " & strHomeDrive
'Appends output to text file
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(strLog, ForAppending, True)
objFile.WriteLine strOutput
objFile.Close
|