Announcement

Collapse
No announcement yet.

Create File Using Computer Name

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Create File Using Computer Name

    Hello,

    I am trying to run a .VBS that will create a file using the computer name as the filename. (computername.txt)

    I'm new to this so any help you can provide would be great! Also any online tutorials for WSH any of you could recommend would also be appreciated!

    Thanks!

  • #2
    Re: Create File Using Computer Name

    sample;
    Code:
    Set WshNetwork = WScript.CreateObject("WScript.Network")
    FileName = WshNetwork.computername & ".txt"
    strFile = "C:\test\" & FileName
    
    Set fso = CreateObject("scripting.filesystemobject")
    Set objNewFile = fso.CreateTextFile(strFile)
    
    objNewFile.writeline "test"
    
    objNewFile.close : Set objNewFile = Nothing
    
    wscript.echo "done"
    wscript.quit
    \Rems

    This posting is provided "AS IS" with no warranties, and confers no rights.

    __________________

    ** Remember to give credit where credit's due **
    and leave Reputation Points for meaningful posts

    Comment


    • #3
      Re: Create File Using Computer Name

      Thank you very much!!

      Comment

      Working...
      X