Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

wscript and cscript in .vbs

49 views
Skip to first unread message

karamel

unread,
Oct 27, 2009, 3:01:58 PM10/27/09
to
Hello

I want indicate in the file .vbs the type of interpreteur for execute the
file (cscript or wscript)
i don't want use WSCRIPT //H:CScript //nologo //S

help me please
thank you very much


mayayana

unread,
Oct 27, 2009, 5:09:17 PM10/27/09
to
If it's local you could define your own file
types. For instance, vb1 and vb2. If you
look in the Registry under HKCR\VBSFile you
should see a DefaultIcon key, an Open key
and an Open2 key. Open is generally wscript
and Open2 is generally cscript. With that info.
you have enough to define your own file-type
keys and icons for each engine.

> Hello
>
> I want indicate in the file .vbs the type of interpreteur for execute the
> file (cscript or wscript)

> i don't want use WSCRIPT file://H:CScript file://nologo file://S

karamel

unread,
Oct 27, 2009, 5:06:35 PM10/27/09
to
I know, thank

I want to define in the execute'file for execute in more machine

is-it possible ?


"mayayana" <mayaX...@rcXXn.com> a �crit dans le message de news:
uWEqhE0V...@TK2MSFTNGP04.phx.gbl...

mayayana

unread,
Oct 27, 2009, 5:11:39 PM10/27/09
to

> I want to define in the execute'file for execute in more machine
>
> is-it possible ?

Once the file is running that decision has already
been made, so I don't see how you'd do it. You'd
have to use the script to write a new script, then
shell to that script and quit.


Richard Mueller [MVP]

unread,
Oct 27, 2009, 6:37:29 PM10/27/09
to

"karamel" <kar...@yahoo.fr> wrote in message
news:4ae743a6$0$934$ba4a...@news.orange.fr...

As indicated, you must recognize which program was used, then re-run the
script. Assuming you want the script to use cscript, it will run in another
copy of the shell, so another console will be launched. I found this code:
===========
Dim strArgs, i, objShell

' Code to make sure program runs with cscript host program.
strArgs=""
If (Right(LCase(Wscript.Fullname), 11)= "wscript.exe") Then
For i = 0 To Wscript.Arguments.Count - 1
strArgs = strArgs & Wscript.Arguments(i) & " "
next
Set objShell=CreateObject("Wscript.Shell")
objShell.Run objShell.ExpandEnvironmentStrings("%comspec%") & _
" /k cscript.exe //nologo " & Wscript.ScriptFullname & " " & strArgs
Wscript.Quit
End If

' The actual VBScript program follows.
Wscript.Echo "Line 1"
Wscript.Echo "Line 2"
Wscript.Echo "Line 3"
Wscript.Echo "Line 4"
==========
In this example I used the /k switch to keep the console open so you can see
anything echoed to the screen. Otherwise, you can use the /c switch and the
new command window will just blink and you won't see anything, including
error messages. With the /k switch you see all messages, but you must enter
"exit" to close the new command window.

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


Todd Vargo

unread,
Oct 27, 2009, 7:40:43 PM10/27/09
to
karamel wrote:
> Hello
>
> I want indicate in the file .vbs the type of interpreteur for execute the
> file (cscript or wscript)
> i don't want use WSCRIPT //H:CScript //nologo //S

The following code will allow you to force a script to always use CSCRIPT no
matter which host is default. Place it at the top of your script.

' Restart with CSCRIPT.vbs
' Written by Todd Vargo in Windows 98 on May 14, 2008
Set WshShell = CreateObject("WScript.Shell")

If InStr(Ucase(WScript.FullName), "WSCRIPT.EXE") Then
'Restart using CSCRIPT.EXE
WshShell.Run "CSCRIPT.EXE //nologo " & _
Chr(34) & Wscript.ScriptFullName & Chr(34)
Wscript.Quit
End If

Wscript.Echo "Host is " & WScript.FullName
WshShell.Popup "Script will close in 5 seconds.",5,"Done"

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)

karamel

unread,
Oct 28, 2009, 1:13:08 PM10/28/09
to
VERY VERY GOOD

Thank you VERY much


"Todd Vargo" <tlv...@sbcglobal.netz> a �crit dans le message de news:
u3h77Z1V...@TK2MSFTNGP05.phx.gbl...

Hz

unread,
Oct 30, 2009, 2:44:50 AM10/30/09
to
karamel wrote:
> Hello
>
> I want indicate in the file .vbs the type of interpreteur for execute the
> file (cscript or wscript)
> i don't want use WSCRIPT //H:CScript //nologo //S


I Use this:

If LCase(Right(WScript.FullName, 11)) <> "cscript.exe" Then
WScript.Echo "Please use CScript to run this script"
WScript.Quit
End If

--
.::[ Hz ]::.

0 new messages