0

I am looking for something like..

If RUNNING_THROUGH_WSCRIPT = True Then
    WScript.Echo "This script is running through wscript.exe"
Else
    WScript.Echo "This script is running through cscript.exe"
End If

I have a VBScript that can only run through cscript.exe. wscript.exe gives an error. I can easily go to properties and change default program but if say I was to give the script to a client then I would like him/her to not worry about such things.

It needs to be very easy to use without any complications beyond double-clicking on the file.

I can easily make a VBScript detect it own path and then run itself through a program of my choosing but before I can do that I need to detect the program through which it is already running.

Anyone know how?

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
Asif Ali
  • 271
  • 1
  • 3
  • 16

1 Answers1

1
WScript.Echo CreateObject("Scripting.FileSystemObject").GetFileName( WScript.FullName )

The FullName property of the WScript object contains the full path of the executable host running the current script.

MC ND
  • 69,615
  • 8
  • 84
  • 126
  • Already [answered before](https://stackoverflow.com/a/4572833/692942). – user692942 Jan 06 '19 at 21:14
  • @Lankymart, To be honest I didn't search, it was faster to answer. And probably, seeing the title in the linked question I would not have though it was relevant to this case. Is not there a better matching question? Yes, it is the same answer but (not sure if you agree) unless you know what to search in the answer (not the question) it is not obvious if it is a relevant question. – MC ND Jan 06 '19 at 21:50
  • @MCND thanks I tested it works – Asif Ali Jan 07 '19 at 16:49
  • @AsifAli just as [it did 8 years ago](https://stackoverflow.com/a/4572833/692942). – user692942 Jan 07 '19 at 20:02