Code : Tout sélectionner
sc config dhcp start= disabled
sc stop dhcp
sc config dnscache start= disabled
sc stop dnscache
sc config netman start= disabled
sc stop netman
Code : Tout sélectionner
sc config dhcp start= disabled
sc stop dhcp
sc config dnscache start= disabled
sc stop dnscache
sc config netman start= disabled
sc stop netman
Code : Tout sélectionner
;trouvé ici http://purebasic.info/phpBB3ex/viewtopic.php?f=1&t=4449&p=84131&hilit=%23PB_Program_Write#p84131
Procedure.s OemToChar(String.s)
OemToChar_(@String, @String)
ProcedureReturn String
EndProcedure
prog = RunProgram("cmd.exe", "", "", #PB_Program_Open|#PB_Program_Read|#PB_Program_Write|#PB_Program_Hide)
;Delay(200)
If IsProgram(prog)
WriteProgramStringN(prog, "sc config dhcp start= disabled")
WriteProgramStringN(prog, "net stop dhcp /y")
WriteProgramStringN(prog, "sc config dnscache start= disabled")
WriteProgramStringN(prog, "net stop dnscache /y")
WriteProgramStringN(prog, "sc config netman start= disabled")
While ProgramRunning(prog)
If AvailableProgramOutput(prog)
x=0
Answer$=OemToChar(ReadProgramString(prog))
If Answer$
Debug Answer$
EndIf
EndIf
Delay(50) ; commentez cette ligne pour aller plus vite
Wend
EndIf
Code : Tout sélectionner
sc query type= service state= all > query.txt
Code : Tout sélectionner
sc query type= service state= all > query.txt
:: Client DHCP (Automatique)
sc query dhcp
:: Client DNS (Automatique)
sc query dnscache
:: Conneions réseau (Manuel)
sc query netman
pause
Code : Tout sélectionner
; Liste des fonctions PS: http://ss64.com/ps/
; voir https://blogs.technet.microsoft.com/josebda/2012/03/03/using-windows-powershell-to-run-old-command-line-tools-and-their-weirdest-parameters/
; http://ss64.com/ps/syntax.html
Procedure.s GetPath_PowerShell()
Protected path$ = GetEnvironmentVariable("PATH"), ; List of all paths
PowerShell$ = "PowerShell not found!", ; Initialize with failure, success will change it
thispath$ = #Empty$, ; Temporary var to hold path for comparison
i.i ; Loop counter set to number of paths available
For i = 1 To CountString(path$, ";") + 1
thispath$ = StringField(path$, i, ";")
If FindString(thispath$, "powershell", 1, #PB_String_NoCase)
PowerShell$ = thispath$
Break
EndIf
Next
ProcedureReturn PowerShell$
EndProcedure
Debug GetPath_PowerShell() ; chemin de powershell. Attention: même si le chemin indique v1.0, la version de PS peut être 2 ou plus !
Procedure.s SendPS(Command.s)
OutCmd$ = ""
KeepOutCmd$ = ""
CmdPromptRun = RunProgram("powershell.exe", Command, "", #PB_Program_Open|#PB_Program_Read|#PB_Program_Hide);
If CmdPromptRun
While ProgramRunning(CmdPromptRun)
OutCmd$=ReadProgramString(CmdPromptRun)
KeepOutCmd$ = KeepOutCmd$ + RTrim(OutCmd$) + #CR$
Wend
CloseProgram(CmdPromptRun)
EndIf
;ShowMemoryViewer(@KeepOutCmd$,1000)
ProcedureReturn KeepOutCmd$
EndProcedure
;Debug SendPS("Get-Host") ; info sur la console PS
Debug SendPS("get-host | Select version") ; Version de PowerShell, la version 2 ou plus est recquise (XP SP3 minimum)
;Debug SendPS("Get-WmiObject Win32_NetworkAdapterConfiguration -computername . | select DNSServerSearchOrder")
;Debug SendPS("Get-Service LAN* | % { $_.Name; SC.EXE SDSHOW $_.Name }")
;Debug SendPS("Get-Service LANMANSERVER | FL")
;Debug SendPS("get-service | where-object {$_.Status -eq 'Running'}");Display only services that are currently running:
Debug SendPS("get-service");Get all the services on the computer.:
;Attention, certains fonctions ont besoin d'être élevées (administrator), Voir ici http://ss64.com/ps/syntax-elevate.html
; il faut alors ajouter -verb RunAs
; Restart-Service: Stop And then restart a service
; Resume-Service: Resume a suspended service
; Set-Service: Change the start mode/properties of a service
; Start-Service sasv: Start a stopped service
; Stop-Service spsv: Stop a running service
; Suspend-Service: Suspend a running service
Debug SendPS("SC.EXE Query"); voir http://ss64.com/nt/sc.html et surtout https://blogs.technet.microsoft.com/josebda/2012/03/03/using-windows-powershell-to-run-old-command-line-tools-and-their-weirdest-parameters/