Re: Vbs path , how to run any where
- From: moonhk <moonhkt@xxxxxxxxx>
- Date: Fri, 16 Oct 2009 07:09:41 -0700 (PDT)
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>
.
- Follow-Ups:
- Re: Vbs path , how to run any where
- From: Pegasus [MVP]
- Re: Vbs path , how to run any where
- References:
- Vbs path , how to run any where
- From: moonhk
- Re: Vbs path , how to run any where
- From: Pegasus [MVP]
- Re: Vbs path , how to run any where
- From: Tom Lavedas
- Vbs path , how to run any where
- Prev by Date: Re: Vbs path , how to run any where
- Next by Date: Re: Vbs path , how to run any where
- Previous by thread: Re: Vbs path , how to run any where
- Next by thread: Re: Vbs path , how to run any where
- Index(es):
Relevant Pages
|