VBScript Writing to Server Text File

Posted by Keyfer Mathewson on Stack Overflow See other posts from Stack Overflow or by Keyfer Mathewson
Published on 2012-06-20T15:13:03Z Indexed on 2012/06/20 15:15 UTC
Read the original article Hit count: 179

Filed under:

I have created a VBScript which pulls the service tag, username, and computer name from a computer. What I need to do now is compile this information in a text document.

How it's set up is as follows:

We have an Active Directory Server, with a folder for login scripts. I have created a batch file to run this .vbs script, and the script works well so far. What I now need is for a file on the AD server, called "logging.txt", to be populated with the information that is created with the .vbs script.

This is the script I have so far:

'Get Dell Service Tag Info
set ProSet = GetObject("winmgmts:").InstancesOf("Win32_BIOS")
Set ProSet1 = GetObject("winmgmts:").InstancesOf("Win32_SystemEnclosure")
For each Pro in ProSet
  For each Pro1 in ProSet1
   ServiceTag=Pro.SerialNumber
    wscript.echo ServiceTag
    exit for
  Next
  exit for
Next

'get username and computername, could also be asked in a batch
Set oShell     = WScript.CreateObject("WScript.Shell")
Set oShellEnv  = oShell.Environment("Process")
sComputerName  = oShellEnv("ComputerName")
sUsername      = oShellEnv("username")
wscript.echo sComputerName & " " & sUsername

Thank you very much in advance!

© Stack Overflow or respective owner

Related posts about vbscript