VKontakte.DJ
forum traveling
 

Celestial Software

...better by design

Home Support SSH Client Forums
Welcome, Guest
Please Login or Register.    Lost Password?
Scripting Error (1 viewing) (1) Guest
Go to bottom Favoured: 0
TOPIC: Scripting Error
#2274
Scripting Error 15 Years ago  
Hi,

I have the following script bound via key mapping to alt+shit+a. However everytime i run it i get the following error after it completes:
Keymapping script Error
*(null)" (0) on line 0 column 0: (null)

Any ideas how i can stop that?

Regards

Mark
Code:


VBSCRIPT
 Dim objShell, strPath, strRegReg, strRegKey, custcode, strSRVHost, StrHostName, strFileName, strClientCode
 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) )

Function Ipconfig()
 set objExec = objShell.Exec("ipconfig /all" )
 strResults = LCase(objExec.StdOut.ReadAll)
 objOutputfile.writeline (strResults)
End Function

molliver (User)
Fresh Boarder
Posts: 2
graphgraph
User Offline Click here to see the profile of this user
Logged Logged  
 
Last Edit: 2009/04/17 10:38 By bpence. Reason: added code tags to prevent code elements from being converted to smilies
 
The administrator has disabled public write access.  
#2275
Re:Scripting Error 15 Years ago  
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

bpence (Admin)
Admin
Posts: 1406
graph
User Offline Click here to see the profile of this user
Logged Logged  
 
Brian Pence
Celestial Software
SSH , SFTP, and Telnet in a tabbed interface for Windows XP, Vista, Mobile, and others
 
The administrator has disabled public write access.  
#2276
Re:Scripting Error 15 Years ago  
Thanks, that solved the problem and works fine now even with the rest of the debug output i made with the script put back in place.

Regards

Mark
molliver (User)
Fresh Boarder
Posts: 2
graphgraph
User Offline Click here to see the profile of this user
Logged Logged  
 
The administrator has disabled public write access.  
Go to top