' -------------------------------------------- ' Exécution depuis l'explorateur de Windows ' d'une application (.exe et .vbs) dans une console ' avec saisie éventuelle de paramètres ' La console reste ouverte après exécution. ' ' Autoinstallable par exécution sans paramètres ' ' Jean-Claude BELLAMY © 2001-2005 ' -------------------------------------------- Dim shell, args, params, fso, fa,fs Set shell = WScript.CreateObject("WScript.Shell") Set fso = WScript.CreateObject("Scripting.FileSystemObject") Set args = Wscript.Arguments Script=Lcase(Wscript.ScriptFullName) set fs=fso.GetFile(Script) sps=lcase(fs.ShortPath) If args.count=1 Then appli=args(0) set fa=fso.GetFile(appli) spa=lcase(fa.ShortPath) ' test de non-application du script sur lui même If spa<>sps Then params=InputBox("Paramètres éventuels :", Appli) commande="cmd /K title " & appli & " & " & chr(34) & appli & chr(34) & " " & params & " | more" shell.Run commande, 5,true WScript.quit End If End If ' Auto-installation register "exefile" register "comfile" register "vbsfile" register "vbefile" register "wsffile" register "jsfile" register "jsefile" register "batfile" register "cmdfile" wscript.echo "Script "& Script &" installé" WScript.quit ' ----------------------------------------- Sub register(typefic) Key="HKEY_CLASSES_ROOT\" & typefic &"\shell\console\" shell.RegWrite Key,"Exécution dans une fenêtre de commandes" Command="wscript """ & Script & """ ""%1""" shell.RegWrite Key & "command\",Command End Sub ' -----------------------------------------