Mark,
You always need a 'Sub Main / End Sub' around the main body of the script. The error you're getting (which should, admittedly be less cryptic) indicates a missing "Main". I've made the following modifications in the code:
1. Put Sub Main around the main body of the application
2. Move declarations outside of main. Some of these are shared with the Ipconfig function and need to be global.
3. Add objOutputfile to the declaration list. It is created in Main and used in Ipconfig
4. Included a path '' in the assignment to strFileName. Otherwise, there's no telling where the file might actuall be.
Hope this helps.
Nice script, BTW.
Regards,
Brian
Code: |
VBSCRIPT
Dim objShell, strPath, strRegReg, strRegKey, custcode, strSRVHost, StrHostName, strFileName, strClientCode, objOutputfile
Sub Main
set objFSO = CreateObject("Scripting.FileSystemObject")
strFileName = "c:Network-log.txt"
set objOutputfile = objFSO.CreateTextFile( (strFileName) , True)
set objShell = CreateObject("WScript.Shell")
MsgBox "About to Run Network Tests"
objOutputfile.WriteLine(VbCrLf & " Tests Started on: " & Now & vbCrLf)
objOutputfile.writeline (vbCrLf & "**** Run Tests ****" & vbCrLf)
objOutputfile.writeline ("**** Computers IP Settings ****")
Ipconfig()
objOutputfile.WriteLine(VbCrLf & "Test ended on: " & Now)
objOutputfile.close
MsgBox "Tests Completed, Please contact Support with a screenshot of your issue"
objShell.Exec("notepad " & (strFileName) )
End Sub
Function Ipconfig()
set objExec = objShell.Exec("ipconfig /all" )
strResults = LCase(objExec.StdOut.ReadAll)
objOutputfile.writeline (strResults)
End Function
|