I have a .vbs that our entire team uses and it's meant to be run in
cscript mode for WSH (no GUI handling for wscript). Thus, unless the
user has configured WSH to run in cscript mode by default, one must
execute the script like so: cscript <name of my script>.vbs
However, many of the users on my team, by default, usually see this
file and double-click it, which doesn't work out to well for them and
it's not meant to be run in the wscript GUI mode.
Question: is there a way I can catch this error, or detect how the user
executed the script (eg double click the file icon) and throw a single
error via a message box informing them of the
correct way to execute the script?
Thanks for any help,
Sean
If "CSCRIPT.EXE" <> UCase( Right( WScript.Fullname, 11 ) ) Then
WScript.Echo "Das Programm ist fuer CSCRIPT bestimmt!"
WScript.Quit 1
End If
One could even force the script to run in CSCRIPT.EXE
If "CSCRIPT.EXE" <> UCase(Right(WScript.Fullname, 11)) Then
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "CSCRIPT.EXE /nologo " & WScript.ScriptFullName
Wscript.Quit
End If
Wscript.Echo "Script is running in CSCRIPT.EXE now."
Wscript.Sleep 2000 'Pause for demo only.
--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)
Sean
You'll know that and much more with...
Download details: Windows Script 5.6 Documentation
<http://www.microsoft.com/downloads/details.aspx?FamilyId=01592C48-207D-4BE1-8A76-1C4099D7BBB9&displaylang=en>
--
Michael Harris
Microsoft MVP Scripting