Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Handle is invalid

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

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Handle is invalid
  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 >>
 Handle is invalid - 7/9/2007 12:59:31 AM   
  j.junt

 

Posts: 4
Score: 0
Joined: 7/8/2007
Status: offline
I have a VBScript that I am running from a shortcut off of the start menu.  This VBScript create's the object WScript.Shell.  The code then executes another script using

oWShell = createobject("wscript.shell")
oWShell.run "anothervbs.vbs",3,1

On Windows 2003 server I am consistently getting the error : The Handle is invalid.  Yet if I go and double click the script in the explorer then it all works.  These same scripts run fine on all other operating systems except Windows 2003 server.  I am at a loss here.

Any input is greatly appreciated.  Internet Explorer Enhanced Security Configuration is disabled, have tried with and without the anti-virus running also with the firewall turned on and off.  There is no 3rd party software running at all on the machine.

Jeff
 
 
Post #: 1
 
 RE: Handle is invalid - 7/9/2007 2:07:13 AM   
  LANlazy

 

Posts: 82
Score: 0
Joined: 4/11/2007
Status: offline
You may have to give it the full path to anothervbs.vbs unless it is located in the same folder.

(in reply to j.junt)
 
 
Post #: 2
 
 RE: Handle is invalid - 7/9/2007 5:56:35 AM   
  mcds99


Posts: 441
Score: 4
Joined: 2/28/2006
Status: offline
Check the other script to be sure it isn't pointing to something that needs a full path.

Use the full path to the other script.

_____________________________

Sam

Keep it Simple Make it Fun KiSMiF

(in reply to j.junt)
 
 
Post #: 3
 
 RE: Handle is invalid - 7/9/2007 6:52:13 AM   
  Rischip


Posts: 510
Score: 2
Joined: 3/26/2007
Status: offline
Or you can adjust the startup folder in the shortcut to the directory where the scripts are running. When you double click something in explorer which is executable it automatically does this for you, hence why it works one way and not the other.



< Message edited by Rischip -- 7/9/2007 6:53:31 AM >


_____________________________

Rischip
Author of - The Grim Linker

(in reply to mcds99)
 
 
Post #: 4
 
 RE: Handle is invalid - 7/10/2007 11:43:14 PM   
  j.junt

 

Posts: 4
Score: 0
Joined: 7/8/2007
Status: offline
By no means is this a path related problem.  As I stated this works on every operating system except Windows 2003 server.

(in reply to j.junt)
 
 
Post #: 5
 
 RE: Handle is invalid - 7/11/2007 4:22:27 AM   
  Country73


Posts: 735
Score: 10
Status: offline
Which script is the one giving you the error?

The initial script that launches the "anothervbs.vbs" or the 'anothervbs.vbs' script?

(in reply to j.junt)
 
 
Post #: 6
 
 RE: Handle is invalid - 7/11/2007 5:16:31 AM   
  j.junt

 

Posts: 4
Score: 0
Joined: 7/8/2007
Status: offline
The error fires directly on the line:

oWShell.Run "anothervbs.vbs",3,1

This is in script number 1.  The code before this command is simple.  It uses
The scripting.filesystemobject and copies a few files and delete's a few files.

An interesting point to note.  If I put

wscript.sleep 3000

before the run and then another wscript.sleep 3000 in anothervbs.vbs on
the first line then about 1/2 the time it works.  But oddly another error will
sometimes occur even if this does work and that is:

not enough storage is available to process this command.

The server has 2GB of RAM and no major processes running .. ie .. sql
server or exchange server.  It is a barebones config for Win 2003, really
only acts as a AD and file server.

I am lost to find information about this one.



(in reply to Country73)
 
 
Post #: 7
 
 RE: Handle is invalid - 7/11/2007 6:41:12 AM   
  mcds99


Posts: 441
Score: 4
Joined: 2/28/2006
Status: offline
Are you running out of File Handles i.e. have to many files open on the server?

This is possible because the server will track every open file/path  from every user.

_____________________________

Sam

Keep it Simple Make it Fun KiSMiF

(in reply to j.junt)
 
 
Post #: 8
 
 RE: Handle is invalid - 7/11/2007 8:16:38 AM   
  Rischip


Posts: 510
Score: 2
Joined: 3/26/2007
Status: offline
Just so we are not overlooking anything.




oWShell = createobject("wscript.shell")
oWShell.run "anothervbs.vbs",3,1


Should be




Set oWShell = createobject("wscript.shell")
oWShell.run "anothervbs.vbs",3,1



My anothervbs.vbs is :

wscript.sleep 5000
MsgBox "Done"


And it works on 2003 server just fine.





< Message edited by Rischip -- 7/11/2007 8:18:13 AM >


_____________________________

Rischip
Author of - The Grim Linker

(in reply to mcds99)
 
 
Post #: 9
 
 RE: Handle is invalid - 7/12/2007 4:44:37 AM   
  j.junt

 

Posts: 4
Score: 0
Joined: 7/8/2007
Status: offline
I have solved the problem.   VBS #2 (anothervbs.vbs) is created in code from another program.  This program didn't trim the trailing spaces of each line of code in anothervbs.vbs.  Trimming off all trailing spaces in (anothervbs.vbs) solved the problem.  This for some unknown reason only showed itself on Windows 2003 server, not sure why but am releived this problem is solved.  Try it out on a Windows 2003 server with a whole bunch of trailing spaces after each line of code and call it with a Wshell.run and it'll reproduce 90% of the time.

Thanks to all who responded 

(in reply to j.junt)
 
 
Post #: 10
 
 
 
  

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 >> Handle is invalid 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