1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| Option Explicit
Dim Ws,WshEnv,WinPath,ProcessEnv,FSO,HostFile,File,LIGNEENPLUS,sUser,sPass,sCmd,rc
LIGNEENPLUS="adresse IP nom de machine Test"
set Ws = CreateObject("WScript.Shell")
set WshEnv = Ws.Environment("Process")
WinPath = WshEnv("SystemRoot")&"\System32\runas.exe"
HostFile = WshEnv("SystemRoot")&"\System32\drivers\etc\host"
set FSO = CreateObject("Scripting.FileSystemObject")
if Not FSO.FileExists(HostFile) then
MsgBox "Le fichier Host n'existe pas !",16,"Le fichier Host n'existe pas !"
Wscript.Quit
end if
sUser = WshEnv("USERNAME")
sPass="VotrePassword"& VBCRLF 'Modifiez cette ligne par votre mot de passe
sCmd="%comspec% /c echo " & LigneEnPlus & ">>" & HostFile &""
rc=Ws.Run("runas /user:" & qq(sUser) & " " & qq(sCmd),2,FALSE)
Wscript.Sleep 1000
Ws.AppActivate(WinPath)
Ws.SendKeys sPass
Function qq(strIn)
qq = Chr(34) & strIn & Chr(34)
End Function |
Partager