none
Error : Object required in vbscript

    Question

  • Hi,

    I am new to Vbscript. I have got an error :Object required when i tried to unintall the product using the Command line : setup.exe -silent -deinstall -nowait -responseFile"Oracle11g.rsp"

    Below is my code:

    Option Explicit
    Dim SRCDIR, FSO, strRespFile, strCmd, WshShell
    Set SRCDIR = CreateObject("Scripting.FileSystemObject").GetFile(WScript.ScriptFullName).ParentFolder
    Set strRespFile = TEMPDIR & "\Oracle11g.rsp"
    strCmd = """" & SRCDIR & "\Installer\setup.exe"" -silent -deinstall -nowait " & _
             "-responseFile """ & strRespFile & """"
    WshShell.Run strCmd, 1, True
    If CheckError(SEVERE) Then
     LogMsg "Uninstallation will now abort.", SEVERE
     ExitScript(Err.Number)
    End If

    'Wait for the Uninstallation process to complete
    LogEvent "Waiting for process to complete"
    Do While FindProcess("java.exe")
     WScript.Sleep(500)
    Loop
    LogMsg "Uninstallation process complete.", INFO

    Please help me.

     

    Thursday, July 21, 2011 3:55 PM

Answers

  • We must not be seeing all of the VBScript code. And, the error message should have indicated a line number, which you can use to determine the line in the program that raised the error.

    The error might be raised because you are invoking the Run method of the wshShell object, but that object has not been Set. You appear to missing:

    Set wshShell = CreateObject("Wscript.Shell")

    However, we also seem to be missing the code for the methods CheckError, LogMsg, ExitScript, LogEvent, and FindProcess. Are these defined elsewhere?

     


    Richard Mueller - MVP Directory Services
    Thursday, July 21, 2011 4:06 PM
    Moderator

All replies

  • We must not be seeing all of the VBScript code. And, the error message should have indicated a line number, which you can use to determine the line in the program that raised the error.

    The error might be raised because you are invoking the Run method of the wshShell object, but that object has not been Set. You appear to missing:

    Set wshShell = CreateObject("Wscript.Shell")

    However, we also seem to be missing the code for the methods CheckError, LogMsg, ExitScript, LogEvent, and FindProcess. Are these defined elsewhere?

     


    Richard Mueller - MVP Directory Services
    Thursday, July 21, 2011 4:06 PM
    Moderator
  • You declared the object WshShell but you never created it with a Set command! Try this:

    Option Explicit
    Dim SRCDIR, FSO, strRespFile, strCmd, WshShell
    Set WshShell = CreateObject("WScript.Shell")
    Set SRCDIR = CreateObject("Scripting.FileSystemObject").GetFile(WScript.ScriptFullName).ParentFolder
    Set strRespFile = TEMPDIR & "\Oracle11g.rsp"
    strCmd = """" & SRCDIR & "\Installer\setup.exe"" -silent -deinstall -nowait " & _
             "-responseFile """ & strRespFile & """"
    WshShell.Run strCmd, 1, True

    Thursday, July 21, 2011 4:11 PM
  • I tried by declaring the object WshShell but got an another error

    Error: Variable is undefined:"TEMPDIR"

    code:800A01f4

    Source:Microsoft VBScript runtime error


    Banu AS
    Thursday, July 21, 2011 4:28 PM
  • I tried by declaring the object WshShell but got an another error

    Error: Variable is undefined:"TEMPDIR"

    code:800A01f4

    Source:Microsoft VBScript runtime error

    Removed those methods for logmsg,checkerror etc. Got the above error

    Banu AS
    Thursday, July 21, 2011 4:30 PM
  • Get rid of the reserved word SET from the lines where you create the STRING variables SRCDIR and strRespFile and define the variable TEMPDIR.  The word SET is only used to instatiate an object and TEMPDIR is not a predefined variable.  If you mean the system's standard temp directory, you can determine that, like this (among other ways) ...

    TEMPDIR = WshShell.Environment("TEMP")


    Tom Lavedas
    Thursday, July 21, 2011 4:46 PM
    Moderator
  • Look up what Option Explicit does and you'll see why Tom said you need to define the variable TEMPDIR.

    http://msdn.microsoft.com/en-us/library/bw9t3484(v=vs.85).aspx


    Paul Frankovich
    Thursday, July 21, 2011 5:11 PM
  • This is the Command line which works fine when running through run command. Files present under the soure directory

    Command : SourceFolder\Installer\setup.exe -silent -deinstall -nowait -responseFile "C:\Windows\Temp\Oracle11g.rsp"

    Below is the code which i created for the above command .

    Option Explicit
    Dim SRCDIR, strCmd, WshShell , TEMPDIR
    WshShell = CreateObject("WScript.Shell")
    SRCDIR = CreateObject("Scripting.FileSystemObject").GetFile(WScript.ScriptFullName).ParentFolder
    TEMPDIR = WshShell.Environment("TEMP")
    strCmd = " & SRCDIR & "\Installer\setup.exe"" -silent -deinstall -nowait " & _
             "-responseFile """ & TEMPDIR& "\Oracle11g.rsp""
    WshShell.Run strCmd, 1, True

    Please help me in correcting the script and modify the script where it went wrong.

     

    Thanks.

     

     

     

     


    Banu AS
    Friday, July 22, 2011 8:44 AM
  • Sorry but much of the advice her has been misleading.

    Try it this way:

    Set shell = CreateObject("WScript.Shell")
    TEMPDIR = shell.ExpandEnvironmentStrings("%TEMP%")
    SRCDIR =shell.CurrentDirectory 
    strCmd = SRCDIR & "\Installer\setup.exe -silent -deinstall -nowait -responseFile " & TEMPDIR & "\Oracle11g.rsp"
    msgbox strCmd
    WshShell.Run strCmd, 1, True
    

    When you are building string use a msgboc to display the string so you can check it.  This also demonsrates one of teh ways to get the current folder and environment values that will actually work under all circumstances.

    I think you are building the command line incorrectly.  The response file is the file of commands you send to teh installer.  The installer is NOT necessarily where the script is but is in the Oracle folder.  There is an environment that should point to the installer home.  Ot is under ORACLE_HOME.  You chould notplace fles in teh ORACLE folders as they can conflict

    You need to study up on string handling.  Get the WSH help file and look up the commands.  There are numerous examples and information on all aspects of WSH and VBSCript.

    http://www.microsoft.com/download/en/details.aspx?id=2764

     

     

     

     


    jv
    Friday, July 22, 2011 10:08 AM
  • I just noticed one other odd thing. Why are you using teh environment to get teh Windows temp folder.  In your copy of teh environment the TEMP variable points to the temp folder in your profile.

    Why would the Orqacle installer response file be in teh WIndows Temp folder?  You should use the one from ORACLE_HOME.  This one may have been updated by the installer and should have the correct commands in it.

    Look at the installer documentation closely or you will likely be going in circles for quite some time.

    Here is how we get teh Windows TEMP folder.

    WINTEMP = shell.Environment("SYSTEM")("TEMP")
    TEMPDIR = shell.ExpandEnvironmentStrings(WINTEMP)

    Again - you could find this in teh previously mentioned help file along with numerous helpful examples.

    You can also finf it here: http://msdn.microsoft.com/en-us/library/fd7hxfdd(VS.85).aspx

    Note that all of the documentaion about Environment is missing a reference to USER.  There are three Environments SYSTEM, USER, and PROCESS.  FOr most things USER and PROCESS are equal however a process can alter its environment but the USER environment will not be altered.

     


    jv
    Friday, July 22, 2011 10:25 AM
  • Sorry but much of the advice her has been misleading.


     

    What was misleading about Richard's or Tom's advice? That's a powerful accusation without points to back it up.


    Paul Frankovich
    Friday, July 22, 2011 12:39 PM
  • The OP wanted to know why teh errors.  Ther ewere many.  You all kept thrashing back  and forth do I posted a fix for everything.

    You might say I couldn't stand the high drama.

    It was really meant to be a bit funny as I don't really think you all are being misleading nut I do think that understanding the issue was somehow lost early on.

    I suspect that the OP was not really all that helpful either.  I sw the real problem was not using any construct correctly and the OP not having a clue as to how VBScript works. 

    I suspect that it would haev gotten fixed one line at a time.  Sorry if I mislead anybody by my wild use of 'misleading'.

    Anyway - its fixed now.

     

     


    jv
    Friday, July 22, 2011 1:31 PM