[VBS][DOS]

TheRealGRiz Messages postés 8 Statut Membre -  
cs_Le Pivert Messages postés 8437 Statut Contributeur -
Bonjour,
je débute en VBScript et je souhaiterais, au sein du programme, lancer des instructions dans la console Window en mode admin. Quelles instructions sont nécessaires pour cela en VBScript ?

1 réponse

  1. cs_Le Pivert Messages postés 8437 Statut Contributeur 730
     
    Bonjour,

    Voir ceci:

    https://stackoverflow.com/questions/4388879/vbscript-output-to-console

    Set oWSH = CreateObject("WScript.Shell")
     vbsInterpreter = "cscript.exe"
    
     Call ForceConsole()
    
     Function printf(txt)
        WScript.StdOut.WriteLine txt
     End Function
    
     Function printl(txt)
        WScript.StdOut.Write txt
     End Function
    
     Function scanf()
        scanf = LCase(WScript.StdIn.ReadLine)
     End Function
    
     Function wait(n)
        WScript.Sleep Int(n * 1000)
     End Function
    
     Function ForceConsole()
        If InStr(LCase(WScript.FullName), vbsInterpreter) = 0 Then
            oWSH.Run vbsInterpreter & " //NoLogo " & Chr(34) & WScript.ScriptFullName & Chr(34)
            WScript.Quit
        End If
     End Function
    
     Function cls()
        For i = 1 To 50
            printf ""
        Next
     End Function
    
     printf " _____ _ _           _____         _    _____         _     _   "
     printf "|  _  |_| |_ ___ ___|     |_ _ _ _| |  |   __|___ ___|_|___| |_ "
     printf "|     | | '_| . |   |   --| | | | . |  |__   |  _|  _| | . |  _|"
     printf "|__|__|_|_,_|___|_|_|_____|_____|___|  |_____|___|_| |_|  _|_|  "
     printf "                                                       |_|     v1.0"
     printl " Entrez votre nom:"
     MyVar = scanf
     cls
     printf "Votre nom est: " & MyVar
     wait(5)
    

    0
    1. TheRealGRiz Messages postés 8 Statut Membre
       
      Merci de ta réponse.
      Cependant je voudrais n'afficher que des boites de dialogue dans wscript (c'est pour ça que j'utilise un vbscript et non un batch) et que csript reste invisible. Il me semble qu'on peut le faire avec
      /K
      ou avec
      /C
      0