HOWTO: Detect if WSH is installed. 
Author Message
 HOWTO: Detect if WSH is installed.

I've worked all morning on this one, thought it might be handy to
others. This batch file will determine whether WSH is installed and if
not, give the user the chance to install it. Of course you could also
automatically install it, without user intervention by modifying this
code slightly. If anyone knows of a better way, of finds this thing
useful, please let me know! Thanks!

By the way, it's designed to be run under NT, but can be modified for
9x. For those not familar with batch files (What are you doing in this
NG anyhow?), just cut and paste the following into notepad and save it
with a .bat extension (or you can use the .cmd extension under NT).

; ------------
; WSH Prompt-Install

; ------------

;*** Determine if Windows Scripting Host is installed
if not exist %WINDIR%\system32\wscript.exe goto no_wsh

:main
if wsherr == 1 exit
;*********************************************************
; put your commands that rely on WSH to be installed here
; ex: CALL my_script.vbs
;*********************************************************
exit

:no_wsh
cls
echo ?
echo Windows Scripting Host does not appear to be installed. Install
now?
echo (If you are unsure, please press "y".)
echo ?
choice /t:y,5
if %errorlevel% == 1 goto accept_wsh
if %errorlevel% == 2 goto decline_wsh
goto no_wsh

:accept_wsh
cls
echo ?
echo Please wait...
if not exist x: net use x: \\my_server\wsh\
start /WAIT x:\ste50en.exe /q
net use x: /delete
if errorlevel 0 goto main
set wsherr=1
echo Installation Failed!
echo ?
pause
goto main

:decline_wsh
set wsherr=1
goto main

; eof

Sent via Deja.com http://www.*-*-*.com/
Share what you know. Learn what you don't.



Sat, 09 Feb 2002 03:00:00 GMT  
 HOWTO: Detect if WSH is installed.
Jamie,

While this will work most of the time it's not the whole story. We've
had quite a few installs where the files have been copied (wscript.exe
etc.), but the controls have not been registered i.e. the install was
incomplete.

To get round this this is what we do (below). Our script is designed to
return an errorlevel of 1 for *successful* operation (higher errorlevels
are used for other things). This means that we can detect whether the
script has run. If no errorlevel is detected then the script didn't run,
and an automatic install of WSH is called. If the script doesn't run a
second time, the user is asked to call for assistance.

Hope this helps someone,

Nick.

Rem **** Run VB Script ****
cscript \\IMSUKLNDC2\Netlogon\NTScript.vbe //NoLogo
If Errorlevel 2 goto WSHError
If Errorlevel 1 goto End

Rem **** Script has failed. Install WSH ****
:WSHError
Cls
Echo You do not appear to have the Windows Scripting Host correctly
installed
Echo Attempting automatic installation. Please wait ...
Call \\IMSUKLNDC2\WSH$\WSH.BAT

Rem **** Now try running the script again ****
Echo.
Echo Attempting to run VBScript again ...
Echo.
cscript \\IMSUKLNDC2\Netlogon\NTScript.vbe //NoLogo
If Errorlevel 2 goto WSHError2
If Errorlevel 1 goto End

:WSHError2
Cls
Echo **** ERROR ****
Echo You do not appear to have the Windows Scripting Host correctly
installed
Echo Attempt to automatically install this software has failed.
Echo Please call the IT+T Helpdesk (x5650) for assistance
Pause

:End

Quote:
> -----Original Message-----

> Posted At: 24 August 1999 17:42
> Posted To: microsoft.public.scripting.wsh
> Conversation: HOWTO: Detect if WSH is installed.
> Subject: HOWTO: Detect if WSH is installed.

> I've worked all morning on this one, thought it might be handy to
> others. This batch file will determine whether WSH is installed and if
> not, give the user the chance to install it. Of course you could also
> automatically install it, without user intervention by modifying this
> code slightly. If anyone knows of a better way, of finds this thing
> useful, please let me know! Thanks!



Sun, 10 Feb 2002 03:00:00 GMT  
 HOWTO: Detect if WSH is installed.
Even though this will detect that the script wasn't run correctly,
won't it also produce errors when the script is intially executed
(assuming the script engine is not installed)? If not... thumbs up!

One of my main goals was to avoid displaying any possible error
messages to users.


global.com>,

Quote:
> Jamie,

> While this will work most of the time it's not the whole story. We've
> had quite a few installs where the files have been copied (wscript.exe
> etc.), but the controls have not been registered i.e. the install was
> incomplete.

> To get round this this is what we do (below). Our script is designed
to
> return an errorlevel of 1 for *successful* operation (higher
errorlevels
> are used for other things). This means that we can detect whether the
> script has run. If no errorlevel is detected then the script didn't
run,
> and an automatic install of WSH is called. If the script doesn't run a
> second time, the user is asked to call for assistance.

> Hope this helps someone,

> Nick.

> Rem **** Run VB Script ****
> cscript \\IMSUKLNDC2\Netlogon\NTScript.vbe //NoLogo
> If Errorlevel 2 goto WSHError
> If Errorlevel 1 goto End

> Rem **** Script has failed. Install WSH ****
> :WSHError
> Cls
> Echo You do not appear to have the Windows Scripting Host correctly
> installed
> Echo Attempting automatic installation. Please wait ...
> Call \\IMSUKLNDC2\WSH$\WSH.BAT

> Rem **** Now try running the script again ****
> Echo.
> Echo Attempting to run VBScript again ...
> Echo.
> cscript \\IMSUKLNDC2\Netlogon\NTScript.vbe //NoLogo
> If Errorlevel 2 goto WSHError2
> If Errorlevel 1 goto End

> :WSHError2
> Cls
> Echo **** ERROR ****
> Echo You do not appear to have the Windows Scripting Host correctly
> installed
> Echo Attempt to automatically install this software has failed.
> Echo Please call the IT+T Helpdesk (x5650) for assistance
> Pause

> :End

> > -----Original Message-----

> > Posted At: 24 August 1999 17:42
> > Posted To: microsoft.public.scripting.wsh
> > Conversation: HOWTO: Detect if WSH is installed.
> > Subject: HOWTO: Detect if WSH is installed.

> > I've worked all morning on this one, thought it might be handy to
> > others. This batch file will determine whether WSH is installed and
if
> > not, give the user the chance to install it. Of course you could
also
> > automatically install it, without user intervention by modifying
this
> > code slightly. If anyone knows of a better way, of finds this thing
> > useful, please let me know! Thanks!

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


Sun, 10 Feb 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Detect if WSH is installed, and if not install it (from command line)

2. Detect if WSH is installed, and if not install it (from command line)

3. Detect version of IE Before Installing WSH..

4. how to detect wsh installed version?

5. INF Install Failure when install WSH on WIN2000

6. Detect and install WSH if not already installed before running CSCRIPT!!!

7. BUG in WSH 5.6 install if Wscript.exe is running while updating WSH

8. after installing WSH on NT4, WSH won`t work

9. BUG in WSH 5.6 install if Wscript.exe is running while updating WSH

10. BUG in WSH 5.6 install if Wscript.exe is running while updating WSH

11. detect if java plugin is installed AND activated for IE

12. detecting installed mimetype or plugin

 

 
Powered by phpBB® Forum Software