1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

VBScript in LNSS Editor, Cannot Figure Out Error

Discussion in 'Web Design, HTML And CSS' started by zdunham6287, Sep 23, 2008.

  1. zdunham6287

    zdunham6287 New Member

    Joined:
    Feb 7, 2007
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Pennsylvania, USA
    Home Page:
    Hi, I'm not sure if this is the right place to post this because its not web development although it is VBScript, but here we go. At work I'm trying to create a script that will let a user input a list of computers on the network and then a program to uninstall from those computers, and then have the program automatically do that. As of now it just accepts one computer as input, I can worry about a list later. I'm getting this error message when I debug: "Error on line: 11 - Method or data member not found: objSoftware". Here is my code:

    Code:
    Dim inputString As String
    Dim inputProgram As String
    inputComputer = InputBox("Computer: ")
    inputProgram = InputBox("Program to be Uninstalled: ")
    
    Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & inputComputer & "\root\cimv2")
    
    Set colSoftware = objWMIService.ExecQuery ("Select * from Win32_Product Where Name = '" & inputProgram & "'")
    
    For Each objSoftware In colSoftware
       objSoftware.Uninstall()
    Next
    
    I'm new to both For Each loops and VBScript so I'm not quite sure why that would be happening. I'm using LNSS Script Debugger Version 1.0 through GFI 8. If anyone knows a better way to do this or something I should change please let me know. Thanks so much for any help.
     
  2. zdunham6287

    zdunham6287 New Member

    Joined:
    Feb 7, 2007
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Pennsylvania, USA
    Home Page:
    I just changed the For Each loop to a For loop:

    Code:
    Set length = UBound(colSoftware)
    For count = 0 To length
    	colSoftware(count).Uninstall()
    Next
    
    And now I get "the parameter is incorrect" as an error. Am I doing something wrong?
     

Share This Page