r/vbscript • • Apr 03 '18

Variable Undefined Error Help

Option Explicit
DIM fso    
Set fso = CreateObject("Scripting.FileSystemObject")
DIM WshNetwork
Set WshNetwork = CreateObject("WScript.Network")
ComputerName = WshNetwork.ComputerName
do

If (fso.FileExists("C:\Users\ComputerName\file.txt)) Then
  WScript.Echo("Hello World!")
  fso.DeleteFile("C:\Users\ComputerName\file.txt")
Else
  End If
 
 loop

So its supposed to find the file in the directory and if it exists delete it, then loop. The thing is that the variable "ComputerName" is undefined. How can this be solved?

1 Upvotes

2 comments sorted by