Question : The WScript equivalent?

Hi Experts :)

What is the WScript equivalent of the following batch command?

echo %username%, %computername%, %time%, %date%, %homashare%, %homedrive% >> aaa.txt

Best regards,
The Terrible

Answer : The WScript equivalent?

Paste the script below into a text file with a .vbs extension.  Running it should produce the desired output.


1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
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
Open in New Window Select All
Random Solutions  
 
programming4us programming4us