Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


800a330e input past enf of file error

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,29390
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> 800a330e input past enf of file error
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 800a330e input past enf of file error - 12/29/2005 3:36:13 AM   
  faulkkev

 

Posts: 151
Score: 0
Joined: 11/1/2005
Status: offline
I only get this if I specify an incorrect server name or leave it blank.  I can't figure out how to make it check that the name is correct first and then write to my output then echo server name incorrect.  Otherwise it works fine i have tried so many things to get this to work.  The program checks local group membership of a specified user.

found = False
errorlog = "c:\error.txt"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile(errorlog, True)
' On Error Resume Next
computer = inputbox ("computer name")
user = lcase(inputbox ("enter user name"))
strComputer = computer
Set colGroups = GetObject("WinNT://" & strComputer)
colGroups.Filter = Array("Group")

For Each objGroup In colGroups

For Each objUser In objGroup.Members
                     
                       If lcase(objUser.name) = user Then
                                   found=True
          
                   End If
           Next
           If found=true Then
                       objfile.writeline Now & " user " & user & " is a member of " & objGroup.Name & " on " & strcomputer
           Else
                       objfile.writeline Now & " user " & user & " is NOT a member of " & objgroup.name
           end If

          found=False
Next

objFile.Close
result = objfso.OpenTextFile(errorlog, 1).ReadAll
wscript.echo result
 
 
Post #: 1
 
 RE: 800a330e input past enf of file error - 12/29/2005 3:57:50 AM   
  ehvbs

 

Posts: 2204
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi faulkkev,

I hope this code


      

will qualify as diagnosis and therapy.

(in reply to faulkkev)
 
 
Post #: 2
 
 RE: 800a330e input past enf of file error - 12/29/2005 4:09:33 AM   
  Sebekz

 

Posts: 9
Score: 0
Joined: 12/27/2005
Status: offline
There's a couple ways to approach this.

The one I'd try would be to add an If statement that checks the value of Err.Number.  If that value has changed from 0, an error has occured.  This would be a good check to put in after the line "Set colGroups = GetObject("WinNT://" & strComputer)", where an error is likely the result of the computer not existing.

You can also add a loop that checks the values entered for the computer and user names to make sure that they are not blank.

Here's how it might look all together...


found = False
errorlog = "c:\error.txt"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile(errorlog, True) 

'Unremarked the On Error statement so the script will get to the If statement to check for an error.
On Error Resume Next 

'Loop until a non-blank value is entered for both ehe user and computer names
Do Until computer <> "" And user <> ""
          computer = inputbox ("computer name") 
          user = lcase(inputbox ("enter user name"))
Loop

strComputer = computer
'Clear any previous error codes
Err.Clear
Set colGroups = GetObject("WinNT://" & strComputer)
'Check to see if the script was able to contact a computer with the name provided
If Err.Number <>0 then
          Wscript.Echo "Invalid computer name or remote system unavailable!"
          Wscript.quit
End If

colGroups.Filter = Array("Group")

For Each objGroup In colGroups

For Each objUser In objGroup.Members
                    
                      If lcase(objUser.name) = user Then
                                  found=True
         
                  End If
          Next 
          If found=true Then
                      objfile.writeline Now & " user " & user & " is a member of " & objGroup.Name & " on " & strcomputer
          Else
                      objfile.writeline Now & " user " & user & " is NOT a member of " & objgroup.name
          end If

         found=False
Next

objFile.Close
result = objfso.OpenTextFile(errorlog, 1).ReadAll
wscript.echo result

(in reply to faulkkev)
 
 
Post #: 3
 
 RE: 800a330e input past enf of file error - 12/29/2005 6:31:32 AM   
  faulkkev

 

Posts: 151
Score: 0
Joined: 11/1/2005
Status: offline
thanks the loop appears to help but I can' t get the output to work correctly if err.number <> 0 it doesn't echo or write a line if I change the code to write.  It just comes up witn a little window that has an ok and is blank.  Here is my revised code which is from example two.

found = False
errorlog = "c:\error.txt"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile(errorlog, True) 
'Unremarked the On Error statement so the script will get to the If statement to check for an error.
On Error Resume Next 
'Loop until a non-blank value is entered for both ehe user and computer names
Do Until computer <> "" And user <> ""
         computer = inputbox ("computer name") 
         user = lcase(inputbox ("enter user name"))
Loop
strComputer = computer
'Clear any previous error codes
Err.Clear
Set colGroups = GetObject("WinNT://" & strComputer)
'Check to see if the script was able to contact a computer with the name provided
If Err.Number <> 0 then
         objfile.writeline Now & " computer " & strcomputer & " is invalid or available! "
         Wscript.quit
End If
colGroups.Filter = Array("Group")
For Each objGroup In colGroups
For Each objUser In objGroup.Members
                   
                     If lcase(objUser.name) = user Then
                                 found=True
        
                 End If
         Next 
         If found=true Then
                     objfile.writeline Now & " user " & user & " is a member of " & objGroup.Name & " on " & strcomputer
         Else
                     objfile.writeline Now & " user " & user & " is NOT a member of " & objgroup.name
         end If
        found=False
Next
objFile.Close
result = objfso.OpenTextFile(errorlog, 1).ReadAll
wscript.echo result

(in reply to faulkkev)
 
 
Post #: 4
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> 800a330e input past enf of file error Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts