Results 1 to 12 of 12

Thread: Variable is undefined on Set oShell ...

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2004
    Posts
    11

    Variable is undefined on Set oShell ...

    I'm tring to run a vb script on the command line and I get this error :

    Srcipt: xyz.vbs
    Line: 98
    Char: 1
    Error: Variable is undefined: 'oShell'
    Code: 800A01F4
    Source: Microsoft VBScript runtime error

    and this is the code on line 98:

    Set oShell = CreateObject("WScript.Shell")

    Do I have to define a variable for oShell ?
    What I'm doing wrong ?

    Any help is realy apreciate.

  2. #2
    Junior Member
    Join Date
    Apr 2004
    Location
    Birmingham, UK
    Posts
    23
    I use this:

    VB Code:
    1. Dim wShell
    2. Set wShell = WScript.CreateObject("WScript.Shell")

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2004
    Posts
    11

    The system cannot find the file specified

    Thanks that worked, but I'm getting into another problem:

    Line100: The system cannot find the file specified!

    as the code looks like this:

    ...
    34: cPath = "c:\\Program Files\\Ensim\\Webppliance\\util\\"
    ...
    45: cCmd = "adddomain -s " & cXML
    ...
    98: Dim oShell
    99: Set oShell = CreateObject("WScript.Shell")
    100: Set oExec = oShell.Exec(cPath & cCmd)
    ...

    The path is ok I have checked many times.

  4. #4
    Junior Member
    Join Date
    Apr 2004
    Location
    Birmingham, UK
    Posts
    23
    Are you sure all those double '\' are correct?

  5. #5

    Thread Starter
    New Member
    Join Date
    Apr 2004
    Posts
    11
    I have tried as well with single "/" but same message.
    I've note that when I go to the command prompt I cannot run the program simply typing c:\\Program Files\\Ensim\\Webppliance\\util\\adddomain it works only using short file names C:\\PROGRA~1\\Ensim\\WEBPPL~1\\util\\adddom~1.bat or using double quotes "c:\\Program Files\\Ensim\\Webppliance\\util\\adddomain".

    Unfortunatelly I cannot change the code to use short file names and I don't know how to specify in the code to send the command with double quotes.

  6. #6
    Junior Member
    Join Date
    Apr 2004
    Location
    Birmingham, UK
    Posts
    23
    did you try with single '/' or '\' ?


    you could just try

    Code:
    ...
    98: Dim oShell
    99: Set oShell = CreateObject("WScript.Shell")
    100: Set oExec = oShell.Exec("c:\\Program Files\\Ensim\\Webppliance\\util\\adddomain  -s")
    Last edited by Amleto; Apr 7th, 2004 at 12:15 PM.

  7. #7

    Thread Starter
    New Member
    Join Date
    Apr 2004
    Posts
    11
    That I cannot do because the cCmd variable gets changed.

  8. #8
    Junior Member
    Join Date
    Apr 2004
    Location
    Birmingham, UK
    Posts
    23
    what about:

    Code:
    cPath = "'" & "c:\\Program Files\\Ensim\\Webppliance\\util\\" & "'"
    etc.

  9. #9

    Thread Starter
    New Member
    Join Date
    Apr 2004
    Posts
    11
    same error

  10. #10
    Junior Member
    Join Date
    Apr 2004
    Location
    Birmingham, UK
    Posts
    23
    well make a new folder in a path that doesnt contain any spaces, and try and run an .exe file in there to test exactly what the problem is

  11. #11

    Thread Starter
    New Member
    Join Date
    Apr 2004
    Posts
    11
    sorry Amleto,

    I cannot do this because some other applications are running in the same folder.

  12. #12
    Junior Member
    Join Date
    Apr 2004
    Location
    Birmingham, UK
    Posts
    23
    that wont matter.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width