Re: Vbs path , how to run any where

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



On Oct 16, 8:23 pm, Tom Lavedas <tglba...@xxxxxxx> wrote:
On Oct 16, 5:25 am, "Pegasus [MVP]" <n...@xxxxxxxxxxxxx> wrote:



"moonhk" <moon...@xxxxxxxxx> wrote in message

news:bb833bca-3487-4ae2-9f76-6bebbbbc299d@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Hi All

How to run vbs on anywhere ? it is seem that found vbs on current
dictory.

All the vbs in X:\HOME\EXAMPLE\SOFTWARE\SHELL

c:\temp>cscript jmail.vbs
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

Input Error: Can not find script file "c:\temp\jmail.vbs".

c:\temp>

X:\HOME\Example\Software\shell>cscript jmail.vbs
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

2009/10/16 17:11:19 Start
2009/10/16 17:11:19 Setup mail Domain :xxxxxxxxxxxxxxxxx
2009/10/16 17:11:19 Sending....
2009/10/16 17:11:20 Sent
2009/10/16 17:11:20 Done

X:\HOME\Example\Software\shell>

setup path as below

X:\HOME\Example\Software\shell>set |grep -i path=c | sed "s/;/\n/g"
LD_LIBRARY_PATH=c:\cygwin\usr\lib
Path=C:\Program Files\PC Connectivity Solution\
C:\Perl\site\bin
C:\Perl\bin
C:\WINDOWS\system32
C:\WINDOWS
C:\WINDOWS\System32\Wbem
X:\HOME\EXAMPLE\SOFTWARE\SHELL                    <== all vbs in this
directory
c:\cygwin
c:\cygwin\bin
c:\cygwin\usr\include
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727
C:\Program Files\Notepad++
X:\HOME\Example\Software\perl
C:\Program Files\Symantec\pcAnywhere\
H:\Software\perl
H:\Software\perl\General

X:\HOME\Example\Software\shell>

You need to do three things:
1. Include X:\HOME\EXAMPLE\SOFTWARE\SHELL in the path.
2. Make cscript.exe your default interpreter
   cscript //H:CScript
3. Invoke your script like so:
    jmail.vbs

Regardless of the script host, if the script can be found on the path,
it can be invoked directly from the command prompt (without a specific
invocation of the host type), However, defining cscript as the default
is very useful, if it is intended that scripts run at the command
prompt are executed synchronous to the current console session.

The one necessary element for this to happen is that the PATHEXT
environment variable include an entry for the .VBS extension.  For
example, my systems has ...

PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.VBC

Note the final extension - VBC.  I have added a VBCFile association to
the registry that makes Cscript.exe the host for such files, so I can
invoke them at the command prompt without regard to which script host
is the default.  That is, if the files name is jmail.vbc, it can be
invoked at the command prompt as ...

C:\>jmail

and it will run in that console session under cscript.

There is one caveat: This approach does not support piping into the
script.  That is it does not properly support the StdIn processing,
though it works fine for StdOut and StdErr.  For that the cscript host
must be explicitly invoked.

C:\>echo testcase | cscript //nologo somescript.vbs
_____________________
Tom Lavedas

Hi All

When change to default to wscript , parameter argument is not
available.

C:\temp>wscript //h:wscript

C:\temp>jmail.vbs
Microsoft (R) Windows Script Host Version 5.7
Copyright (C) Microsoft Corporation. All rights reserved.

2009/10/16 22:05:31 Start
2009/10/16 22:05:31 Setup mail Domain :smtp.netvigator.com
2009/10/16 22:05:31 Sending....
2009/10/16 22:05:32 Sent
2009/10/16 22:05:32 Done

C:\temp>jmail.vbs -h
Microsoft (R) Windows Script Host Version 5.7
Copyright (C) Microsoft Corporation. All rights reserved.

2009/10/16 22:05:34 Start
2009/10/16 22:05:35 Setup mail Domain :smtp.netvigator.com
2009/10/16 22:05:35 Sending....
2009/10/16 22:05:41 Sent
2009/10/16 22:05:41 Done

C:\temp>

C:\temp>wscript //h:cscript

C:\temp>jmail.vbs -h
Microsoft (R) Windows Script Host Version 5.7
Copyright (C) Microsoft Corporation. All rights reserved.

2009/10/16 22:08:08 Start
2009/10/16 22:08:08 Setup mail Domain :smtp.netvigator.com
2009/10/16 22:08:08 Sending....
2009/10/16 22:08:11 Sent
2009/10/16 22:08:11 Done

C:\temp>cscript jmail.vbs -h
Microsoft (R) Windows Script Host Version 5.7
Copyright (C) Microsoft Corporation. All rights reserved.

Input Error: Can not find script file "C:\temp\jmail.vbs".

C:\temp>cscript %shell%\jmail.vbs -h
Microsoft (R) Windows Script Host Version 5.7
Copyright (C) Microsoft Corporation. All rights reserved.

cscript //nologo jmail.vbs -f file_name -h
-f File_name
-h This help message

C:\temp>
.



Relevant Pages

  • Re: Vbs path , how to run any where
    ... Microsoft Windows Script Host Version 5.6 ... Copyright Microsoft Corporation 1996-2001. ... Invoke your script like so: ... it can be invoked directly from the command prompt (without a specific ...
    (microsoft.public.scripting.wsh)
  • Sharing Violation with xcopy -after adsutil.vbs APPUNLOAD & iis st
    ... files to the web server and keep getting sharing violation. ... xcopy filename1.dll destdir ... Microsoft Windows Script Host Version 5.6 ... Copyright Microsoft Corporation 1996-2001. ...
    (microsoft.public.inetserver.iis)
  • Re: adding disclaimer with visual basic SMTP transport event sink
    ... Microsoft Windows Script Host Version 5.6 ... Copyright Microsoft Corporation 1996-2001. ... Binding Display Name Specified: SMTPScriptingHost ...
    (microsoft.public.exchange.admin)
  • Re: cscript sometimes fails to run JScript
    ... I have written a JScript that I execute under cscript from the Windows ... Microsoft Windows Script Host Version 5.6 ... Copyright Microsoft Corporation 1996-2001. ... CScript Error: Initialization of the Windows Script Host failed. ...
    (microsoft.public.scripting.wsh)
  • Re: How to Alert Confirm or Prompt in CScript JSctipt ?
    ... DOS box output is essential. ... I'd much prefer the user to work only in the Command Prompt box. ... Microsoft Windows Script Host versie 5.8 ... Copyright Microsoft Corporation 1996-2001. ...
    (microsoft.public.scripting.jscript)