PCFreak Logo (c) Der PCFreak

Check if VBScript runs with correct interpreter cscript.exe/wscript.exe

If you ever want to make sure, that your VBScript gets executed with the correct interpreter, just add the following code to your script header:

  Set args = WScript.Arguments
   ‚check if executed with cscript
   if UCASE(right(wscript.fullname,11)) <> „CSCRIPT.EXE“ then
   ‚Thanks to PCFreak from germany for that!
   Msgbox „Make your life easier and run this script with cscript.exe“
   WScript.Quit
  end if

This will prevent the ugly popups! Change „CSCRIPT.EXE“ to „WSCRIPT.EXE“ if you want to check the other way.

2 Comments so far

  1. zero on Februar 13th, 2012

    there should also be a hint like this in the adplus.vbs from debugging tools for windows. – You might want to have a closer look at the Sub DetectScriptEngine () within that file.

  2. pcfreak on Februar 13th, 2012

    Nice! My solution looks really dumb when I read DetectScriptEngine() function. Thanks for the info!