473,761 Members | 7,290 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Exec method won't work

I have a script used to find and run Java on a Windows system.**It*wor ked
fine on original tests (on a Windows XP system).**It's* now*running*on* a
Windows 2000 (sp3) system, and it won't work -- the problem is this line:

set oCommand = WshShl.Exec(sCo mmand)

(it's about halfway down)**Is*there *a*problem*with *the*Exec*metho d*in*some
versions of VBS?**Is*the*pr oblem*Windows*v ersion*I'm*on,* or*is*it*someth ing
more obvious that I'm just not seeing?

The error is that the object doesn't support the Exec method.**(I've* also
substituted the string sCommand with "C:\WINNT\Syste m32\sol.exe" just to
make a quick check, and it makes no difference (not that it should with
that error message, I just wanted to try a .exe I knew was there and
working).

Thanks for any help!

Hal

'
'Set up initial variables
'
qm = chr(34)
sqm = chr(39)
set WshShl = WScript.CreateO bject("WScript. shell")

sOut = "No Java Installed"
On Error Resume Next
sVersion = WshShl.RegRead( "HKLM\SOFTWARE\ JavaSoft\Java Runtime
Environment\Cur rentVersion")
sJava = WshShl.RegRead( "HKLM\SOFTWARE\ JavaSoft\Java Runtime Environment\" &
sVersion & "\JavaHome" )
On Error Goto 0

sJava = sJava + "\bin\java. exe"
sCommand = sJava + " -version"
set oCommand = WshShl.Exec(sCo mmand)

iCount = 10

Do While oCommand.Status = 0
*WScript.Sleep* 100
Loop
'WScript.Sleep 1000
25
sOut = oCommand.StdErr .ReadAll

WScript.StdOut. WriteLine("Comm and: ")
'WScript.StdOut .WriteLine("Com mand: " & sJava)
'WScript.StdOut .WriteLine(sOut )
WScript.StdOut. WriteLine(sVers ion
Jul 17 '05 #1
6 8384
Okay -- did I not provide enough information on this? It would be helpful
if someone could at least let me know if this sounds like a bad install or
something. I want the system I'm working on to be multiplatform, and I
need to be able to count on VBScript to do that. If VBScript is so
inherently unstable it is not uncommon to have problems like this, or if
there is no answer to problems like this, then it is not usable for my
purposes.

Could someone at least give me a few suggestions -- or comments, like is
this kind of problem common, does it indicate a bad install? Did I do
something wrong, or is the code okay, but there is no way to tell why it's
not working?

I'd really like to get some ideas on this, but if I don't, I'll just have to
tell my clients they need a separate computer to run my system (so far all
clients have had no issue with this -- the system I use raises their profit
margin enough to make it a worthwhile investment) and that it is not
possible to make it work on Windows. It's not that I'm trying to threaten,
but when I started this, I found quick support from the Perl and Linux
communities and my experience with VBScript and other questions is like
this -- I can ask questions and not even get an answer like, "Your code
looks okay, and I can't see anything wrong with it." I've never posed a
question on ANY Java, Perl, or Linux forum and had no answers at all. It's
very frustrating, and if there is a reason I'm not getting ANY answers on
this, I'd like to know.

Hal

Hal Vaughan wrote:
I have a script used to find and run Java on a Windows system.**It*wor ked
fine on original tests (on a Windows XP system).**It's* now*running*on* a
Windows 2000 (sp3) system, and it won't work -- the problem is this line:

set oCommand = WshShl.Exec(sCo mmand)

(it's about halfway down)**Is*there *a*problem*with *the*Exec*metho d*in*some
versions of VBS?**Is*the*pr oblem*Windows*v ersion*I'm*on,* or*is*it
something more obvious that I'm just not seeing?

The error is that the object doesn't support the Exec method.**(I've* also
substituted the string sCommand with "C:\WINNT\Syste m32\sol.exe" just to
make a quick check, and it makes no difference (not that it should with
that error message, I just wanted to try a .exe I knew was there and
working).

Thanks for any help!

Hal

'
'Set up initial variables
'
qm = chr(34)
sqm = chr(39)
set WshShl = WScript.CreateO bject("WScript. shell")

sOut = "No Java Installed"
On Error Resume Next
sVersion = WshShl.RegRead( "HKLM\SOFTWARE\ JavaSoft\Java Runtime
Environment\Cur rentVersion")
sJava = WshShl.RegRead( "HKLM\SOFTWARE\ JavaSoft\Java Runtime Environment\"
& sVersion & "\JavaHome" )
On Error Goto 0

sJava = sJava + "\bin\java. exe"
sCommand = sJava + " -version"
set oCommand = WshShl.Exec(sCo mmand)

iCount = 10

Do While oCommand.Status = 0
WScript.Sleep*1 00
Loop
'WScript.Sleep 1000
25
sOut = oCommand.StdErr .ReadAll

WScript.StdOut. WriteLine("Comm and: ")
'WScript.StdOut .WriteLine("Com mand: " & sJava)
'WScript.StdOut .WriteLine(sOut )
WScript.StdOut. WriteLine(sVers ion


Jul 17 '05 #2
This is a VB group, not VBScript. They're not
the same thing. That's probably why you
didn't get an answer.

It sounds like you've got v. 5.1 of the Windows
Script Host on the machine. I'm fairly certain
that Exec is only in v. 5.6. You can fix it by updating
the WSH to v. 5.6.

For WSH questions:
microsoft.publi c.scripting.wsh
--
_______________ ______________

ma**********@mi ndYYspring.com
For return email remove XX and YY.
_______________ ______________
Hal Vaughan <ha*@thresholdd igital.com> wrote in message
news:k5******** ************@co mcast.com...
I have a script used to find and run Java on a Windows system. It worked
fine on original tests (on a Windows XP system). It's now running on a
Windows 2000 (sp3) system, and it won't work -- the problem is this line:

set oCommand = WshShl.Exec(sCo mmand)

(it's about halfway down) Is there a problem with the Exec method in some
versions of VBS? Is the problem Windows version I'm on, or is it something
more obvious that I'm just not seeing?

The error is that the object doesn't support the Exec method. (I've also
substituted the string sCommand with "C:\WINNT\Syste m32\sol.exe" just to
make a quick check, and it makes no difference (not that it should with
that error message, I just wanted to try a .exe I knew was there and
working).

Thanks for any help!

Hal

'
'Set up initial variables
'
qm = chr(34)
sqm = chr(39)
set WshShl = WScript.CreateO bject("WScript. shell")

sOut = "No Java Installed"
On Error Resume Next
sVersion = WshShl.RegRead( "HKLM\SOFTWARE\ JavaSoft\Java Runtime
Environment\Cur rentVersion")
sJava = WshShl.RegRead( "HKLM\SOFTWARE\ JavaSoft\Java Runtime Environment\" & sVersion & "\JavaHome" )
On Error Goto 0

sJava = sJava + "\bin\java. exe"
sCommand = sJava + " -version"
set oCommand = WshShl.Exec(sCo mmand)

iCount = 10

Do While oCommand.Status = 0
WScript.Sleep 100
Loop
'WScript.Sleep 1000
25
sOut = oCommand.StdErr .ReadAll

WScript.StdOut. WriteLine("Comm and: ")
'WScript.StdOut .WriteLine("Com mand: " & sJava)
'WScript.StdOut .WriteLine(sOut )
WScript.StdOut. WriteLine(sVers ion

Jul 17 '05 #3
mayayana wrote:
This is a VB group, not VBScript. They're not
the same thing. That's probably why you
didn't get an answer.
Thank you.

To someone who does no work with these languages regularly, it is an easy
mistake to make. If someone had passed that on to me and answered my
question with that when I posted it a week ago, it would have saved me a
week.
It sounds like you've got v. 5.1 of the Windows
Script Host on the machine. I'm fairly certain
that Exec is only in v. 5.6. You can fix it by updating
the WSH to v. 5.6.

For WSH questions:
microsoft.publi c.scripting.wsh
Thanks. I'll check which version I have (that's important -- I have to be
able to count on what is installed on the client's system, which means if a
copy of Win2k as recent as SP3 doesn't have it, I can't count on it being
on my clients' systems -- which means I'll either have to add something to
install 5.6 before installing my program, or not support Win2k.

Thank you!

Hal
--
_______________ ______________

ma**********@mi ndYYspring.com
For return email remove XX and YY.
_______________ ______________
Hal Vaughan <ha*@thresholdd igital.com> wrote in message
news:k5******** ************@co mcast.com...
I have a script used to find and run Java on a Windows system. It worked
fine on original tests (on a Windows XP system). It's now running on a
Windows 2000 (sp3) system, and it won't work -- the problem is this line:

set oCommand = WshShl.Exec(sCo mmand)

(it's about halfway down) Is there a problem with the Exec method in some
versions of VBS? Is the problem Windows version I'm on, or is it
something more obvious that I'm just not seeing?

The error is that the object doesn't support the Exec method. (I've also
substituted the string sCommand with "C:\WINNT\Syste m32\sol.exe" just to
make a quick check, and it makes no difference (not that it should with
that error message, I just wanted to try a .exe I knew was there and
working).

Thanks for any help!

Hal

'
'Set up initial variables
'
qm = chr(34)
sqm = chr(39)
set WshShl = WScript.CreateO bject("WScript. shell")

sOut = "No Java Installed"
On Error Resume Next
sVersion = WshShl.RegRead( "HKLM\SOFTWARE\ JavaSoft\Java Runtime
Environment\Cur rentVersion")
sJava = WshShl.RegRead( "HKLM\SOFTWARE\ JavaSoft\Java Runtime Environment\"

&
sVersion & "\JavaHome" )
On Error Goto 0

sJava = sJava + "\bin\java. exe"
sCommand = sJava + " -version"
set oCommand = WshShl.Exec(sCo mmand)

iCount = 10

Do While oCommand.Status = 0
WScript.Sleep 100
Loop
'WScript.Sleep 1000
25
sOut = oCommand.StdErr .ReadAll

WScript.StdOut. WriteLine("Comm and: ")
'WScript.StdOut .WriteLine("Com mand: " & sJava)
'WScript.StdOut .WriteLine(sOut )
WScript.StdOut. WriteLine(sVers ion


Jul 17 '05 #4
I'm not familiar with using Exec and StdOut (I don't have
WSH 5.6 installed), so I'm not sure how necessary
that is to your script, but you might take a look at the
Run method of WScript.Shell. It runs a program in
the same way that Exec does but Exec does it in a
"command shell" (which I gather is a DOS window)
and provides the StdIn and StdOut methods.

Run (strCommand, [intWindowStyle], [bWaitOnReturn])

You might be able to use Run with bWaitOnReturn set
to True, in which case you get an error code return if
it's used as a function. The Textstream object, then,
would be the equivalent of StdOut, the difference being that
Textstream writes to a file rather than a command window.
If you wanted current visual feedback you'd need to use
a MsgBox.
_______________ ______________

ma**********@mi ndYYspring.com
For return email remove XX and YY.
_______________ ______________
Hal Vaughan <ha*@thresholdd igital.com> wrote in message
news:bK******** ************@co mcast.com...
mayayana wrote:
This is a VB group, not VBScript. They're not
the same thing. That's probably why you
didn't get an answer.
Thank you.

To someone who does no work with these languages regularly, it is an easy
mistake to make. If someone had passed that on to me and answered my
question with that when I posted it a week ago, it would have saved me a
week.
It sounds like you've got v. 5.1 of the Windows
Script Host on the machine. I'm fairly certain
that Exec is only in v. 5.6. You can fix it by updating
the WSH to v. 5.6.

For WSH questions:
microsoft.publi c.scripting.wsh


Thanks. I'll check which version I have (that's important -- I have to be
able to count on what is installed on the client's system, which means if

a copy of Win2k as recent as SP3 doesn't have it, I can't count on it being
on my clients' systems -- which means I'll either have to add something to
install 5.6 before installing my program, or not support Win2k.

Thank you!

Hal
--
_______________ ______________

ma**********@mi ndYYspring.com
For return email remove XX and YY.
_______________ ______________
Hal Vaughan <ha*@thresholdd igital.com> wrote in message
news:k5******** ************@co mcast.com...
I have a script used to find and run Java on a Windows system. It worked fine on original tests (on a Windows XP system). It's now running on a
Windows 2000 (sp3) system, and it won't work -- the problem is this line:
set oCommand = WshShl.Exec(sCo mmand)

(it's about halfway down) Is there a problem with the Exec method in some versions of VBS? Is the problem Windows version I'm on, or is it
something more obvious that I'm just not seeing?

The error is that the object doesn't support the Exec method. (I've also substituted the string sCommand with "C:\WINNT\Syste m32\sol.exe" just to make a quick check, and it makes no difference (not that it should with
that error message, I just wanted to try a .exe I knew was there and
working).

Thanks for any help!

Hal

'
'Set up initial variables
'
qm = chr(34)
sqm = chr(39)
set WshShl = WScript.CreateO bject("WScript. shell")

sOut = "No Java Installed"
On Error Resume Next
sVersion = WshShl.RegRead( "HKLM\SOFTWARE\ JavaSoft\Java Runtime
Environment\Cur rentVersion")
sJava = WshShl.RegRead( "HKLM\SOFTWARE\ JavaSoft\Java Runtime
Environment\" &
sVersion & "\JavaHome" )
On Error Goto 0

sJava = sJava + "\bin\java. exe"
sCommand = sJava + " -version"
set oCommand = WshShl.Exec(sCo mmand)

iCount = 10

Do While oCommand.Status = 0
WScript.Sleep 100
Loop
'WScript.Sleep 1000
25
sOut = oCommand.StdErr .ReadAll

WScript.StdOut. WriteLine("Comm and: ")
'WScript.StdOut .WriteLine("Com mand: " & sJava)
'WScript.StdOut .WriteLine(sOut )
WScript.StdOut. WriteLine(sVers ion

Jul 17 '05 #5
mayayana wrote:
I'm not familiar with using Exec and StdOut (I don't have
WSH 5.6 installed), so I'm not sure how necessary
that is to your script, but you might take a look at the
Run method of WScript.Shell. It runs a program in
the same way that Exec does but Exec does it in a
"command shell" (which I gather is a DOS window)
and provides the StdIn and StdOut methods.

Run (strCommand, [intWindowStyle], [bWaitOnReturn])

You might be able to use Run with bWaitOnReturn set
to True, in which case you get an error code return if
it's used as a function. The Textstream object, then,
would be the equivalent of StdOut, the difference being that
Textstream writes to a file rather than a command window.
If you wanted current visual feedback you'd need to use
a MsgBox.
I knew and have used the Run() method.**I*was* using*Exec()*be cause*I*needed
to read STDOUT.**I*did* not*know*I*coul d*use*a*Textstr eam*object*to*r ead*the
output from a Run() method.**That*c ould*be*a*BIG*h elp,*since*it'l l*let*me
use an earlier version, which would be "stock" on more systems.

Thank you!

Hal
_______________ ______________

ma**********@mi ndYYspring.com
For return email remove XX and YY.
_______________ ______________
Hal Vaughan <ha*@thresholdd igital.com> wrote in message
news:bK******** ************@co mcast.com...
mayayana wrote:
> This is a VB group, not VBScript. They're not
> the same thing. That's probably why you
> didn't get an answer.


Thank you.

To someone who does no work with these languages regularly, it is an easy
mistake to make. If someone had passed that on to me and answered my
question with that when I posted it a week ago, it would have saved me a
week.
> It sounds like you've got v. 5.1 of the Windows
> Script Host on the machine. I'm fairly certain
> that Exec is only in v. 5.6. You can fix it by updating
> the WSH to v. 5.6.
>
> For WSH questions:
> microsoft.publi c.scripting.wsh


Thanks. I'll check which version I have (that's important -- I have to
be able to count on what is installed on the client's system, which means
if

a
copy of Win2k as recent as SP3 doesn't have it, I can't count on it being
on my clients' systems -- which means I'll either have to add something
to install 5.6 before installing my program, or not support Win2k.

Thank you!

Hal
> --
> _______________ ______________
>
> ma**********@mi ndYYspring.com
> For return email remove XX and YY.
> _______________ ______________
> Hal Vaughan <ha*@thresholdd igital.com> wrote in message
> news:k5******** ************@co mcast.com...
>> I have a script used to find and run Java on a Windows system. It worked >> fine on original tests (on a Windows XP system). It's now running on a
>> Windows 2000 (sp3) system, and it won't work -- the problem is this line: >>
>> set oCommand = WshShl.Exec(sCo mmand)
>>
>> (it's about halfway down) Is there a problem with the Exec method in some >> versions of VBS? Is the problem Windows version I'm on, or is it
>> something more obvious that I'm just not seeing?
>>
>> The error is that the object doesn't support the Exec method. (I've also >> substituted the string sCommand with "C:\WINNT\Syste m32\sol.exe" just to >> make a quick check, and it makes no difference (not that it should
>> with that error message, I just wanted to try a .exe I knew was there
>> and working).
>>
>> Thanks for any help!
>>
>> Hal
>>
>> '
>> 'Set up initial variables
>> '
>> qm = chr(34)
>> sqm = chr(39)
>> set WshShl = WScript.CreateO bject("WScript. shell")
>>
>> sOut = "No Java Installed"
>> On Error Resume Next
>> sVersion = WshShl.RegRead( "HKLM\SOFTWARE\ JavaSoft\Java Runtime
>> Environment\Cur rentVersion")
>> sJava = WshShl.RegRead( "HKLM\SOFTWARE\ JavaSoft\Java Runtime Environment\" > &
>> sVersion & "\JavaHome" )
>> On Error Goto 0
>>
>> sJava = sJava + "\bin\java. exe"
>> sCommand = sJava + " -version"
>> set oCommand = WshShl.Exec(sCo mmand)
>>
>> iCount = 10
>>
>> Do While oCommand.Status = 0
>> WScript.Sleep 100
>> Loop
>> 'WScript.Sleep 1000
>> 25
>> sOut = oCommand.StdErr .ReadAll
>>
>> WScript.StdOut. WriteLine("Comm and: ")
>> 'WScript.StdOut .WriteLine("Com mand: " & sJava)
>> 'WScript.StdOut .WriteLine(sOut )
>> WScript.StdOut. WriteLine(sVers ion


Jul 17 '05 #6
I didn't mean that you can use Textstream to
read the output. I meant that the Textstream methods
are analogous to the StdOut methods and that
TextStream could be used to write the data to file
if necessary.

There are two things you need:
1) The return info. from StdErr and
2) The write ability of StdOut.

I'm not able to give you a clear answer because I don't
know where StdOut.WriteLin e is actually writing a line
(log file? DOS window?), and I don't know what info. you
get from StdErr.
Run() can return an error code but I don't know whether
that's the same thing.
I knew and have used the Run() method. I was using Exec() because I needed
to read STDOUT. I did not know I could use a Textstream object to read the
output from a Run() method. That could be a BIG help, since it'll let me
use an earlier version, which would be "stock" on more systems.


Jul 17 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3089
by: Andrew Crowe | last post by:
Hi guys, I'm having trouble executing commands using exec() or system() that need to write files. I've set the permissions on CMD.EXE but I can't use exec() to write any files, even if the folder I'm writing to has write access to IUSER account and PHP can write to the folder directly. eg. Calling exec('echo hello >C:\writablefolder\text.txt') does nothing,
3
5108
by: starlightjen | last post by:
Hello, I'm trying to use php to update my htpasswd file. I have my permissions on .htpasswd set to 777, so it should be wide open. From the command line (when logged into the server as "nobody", my server's web user) I can get the htpasswd.exe to run without a problem, but when passed through my php exec() function the .htpasswd file does not change. I'm not getting any errors, but I'm not getting any action either.
5
1866
by: Nick Jacobson | last post by:
This works fine: x = 1 def execfunc(): print x execfunc() So why doesn't this? s = \
4
8656
by: Shailesh Humbad | last post by:
I was trying to exec a background process on XP using PHP CLI, but could not get it to work. Suppose the command I want to spawn off is "cmd". On *nix, it is as easy as putting ampersand "&" at the end of the command. I tried the following on XP without working. exec("cmd"); exec("cmd >NUL"); exec("cmd /c cmd"); exec("start /b cmd");
11
3124
by: news | last post by:
I've a PHP script that does some stuff, zips up some files, and starts an FTP process. I need it to do the Zip and FTP in the background and let the page finish, otherwise the user could have that page sitting there loading for 20 minutes while the FTP completes. Here's what I have: $zipfile = $order_po.".zip";
4
2368
by: Michael | last post by:
Hi, I'm having difficulty finding any previous discussion on this -- I keep finding people either having problems calling os.exec(lepev), or with using python's exec statement. Neither of which I mean here. Just for a moment, let's just take one definition for one of the
3
1899
by: Mike | last post by:
Hi all, In my recent project (using ASP.NET 2.0 and MSSQL), I need to scheduled a certain operation to be executed, for example, on beginning of a month. Is there anyway to do this on server-side, either on ASP.NET side or SQL Server side? Many thanks in advance, Mike
4
3597
by: Andreas.Burman | last post by:
Hi I call a program through exec that can take a long time to execute. This is fine but I would like to show some kind of animation or something while the program is running and when it is finished letting the user download the file. Right now I'm using code similar to this simplified example: ----- index.php -----
26
3660
by: warth33 | last post by:
Hello I have a php site. Some page needs to call an external program. The programs are home made c# applications. It uses to work without problem. For a while. Maybe it work for some hour. Or for a day. Or even for a week. At a certain point, when a php script calls the exe file, the application freezes. The following happens:
0
9345
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10115
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9957
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9775
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8780
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6609
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5373
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3881
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3456
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.