Bonjour à tous![]()
Je recherche une commande DOS qui permette de tester un service pour savoir s’il est activer ou désactiver.
Quelqu’un saurait-il m’aider ?
Bonjour à tous![]()
Je recherche une commande DOS qui permette de tester un service pour savoir s’il est activer ou désactiver.
Quelqu’un saurait-il m’aider ?
salut,
Essaie avec la commande SC.
http://www.microsoft.com/resources/d.../ntcmds_o.mspx
@+
Bonjour SLE et merci pour se lien![]()
Mais se site est en anglai et le traducteur de google n’arrive pas à le traduire.
as tu effectuer une recherche de la commande SC dans l'aide en ligne de windows ...?
que veu-tu faire exactement ?
Bonjour bbil![]()
Oui j’ai taper « sc / ? », il y a bien l’aide mais elle est aussi en anglai.
Ben enfaîte je voudrai tester un service pour voir s’il est activer ou désactiver.
pour l'aide en français ... moi je l'ai dans menu démarrer "Aide et support"...Envoyé par Furius
sinon tu peu faire
pour connaître l'état du service "NomService" ... si tu connais pas le nom exact de ton service utilise
Code : Sélectionner tout - Visualiser dans une fenêtre à part sc query NomService
et fais défiler les pages (touche entrée) jusqu'a afficher ton service ... (tu pourra noter le nom ...)
Code : Sélectionner tout - Visualiser dans une fenêtre à part sc query |pause
![]()
Merci bbil![]()
Fonctionne bien mais encore le résultat est en anglais :
Code : Sélectionner tout - Visualiser dans une fenêtre à part sc query helpsvc
En faite si je veut tester se service s’est pour rediriger vers une étiquette Goto selon si le service est activer ou désactiver.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 SERVICE_NAME: helpsvc TYPE : 20 WIN32_SHARE_PROCESS STATE : 1 STOPPED (NOT_STOPPABLE,NOT_PAUSABLE,IGNORES_SHUTDOWN) WIN32_EXIT_CODE : 1077 (0x435) SERVICE_EXIT_CODE : 0 (0x0) CHECKPOINT : 0x0 WAIT_HINT : 0x0
S’il est activer le script se redirigera vers l’étiquette Goto sous la quel se trouvera le code pour désactiver se service, sinon fin du script.
Sauriez vous m’aider ?
le test ne semble pas faciel à faire dans un '.bat'... mais si de toute façon c'est pour arrêter le service utilise :
sans aucun test préalable ...
Code : Sélectionner tout - Visualiser dans une fenêtre à part sc stop helpsvc
et pour éviter l'affichage de message d'erreur utilise
Code : Sélectionner tout - Visualiser dans une fenêtre à part sc stop helpsvc > Nul![]()
avec un bat :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 sc query helpsvc | findstr "STATE" | findstr "RUNNING" if %ERRORLEVEL%==0 goto desactiveservice
Je ne répondrai à aucune question technique par MP.
Pensez aux Tutoriels et aux FAQs avant de poster ;) (pour le java il y a aussi JavaSearch), n'oubliez pas non plus la fonction Rechercher.
Enfin, quand une solution a été trouvée à votre problème pensez au tag :resolu:
Cours Dvp : http://ydisanto.developpez.com
Blog : http://yann-disanto.blogspot.com/
Page perso : http://yann-disanto.fr
au cas où :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77 echo off rem Get_Srvc_Status.cmd rem affiche le status d'un service rem %1 nom du service à interroger if %1'==' goto SyntaxeError if "%TEMP%"=="" goto Error2 set Service_Status= rem Interroge le service contenu dans la variable %1 "SC.EXE" interrogate %1>"%TEMP%\FileWORK.TMP" rem le mot clé "STATE" est présent si et seulement si le service est démarré et running rem il peut être démarré et pending rem le service est dans un certain état : rem état possible d'un service ( MS-SDK 02/03 ) rem "Stopped" rem "Start Pending" rem "Stop Pending" rem "Running" rem "Continue Pending" rem "Pause Pending" rem "Paused" rem "Unknown" :notExist rem le service n'existe pas. type "%TEMP%\FileWORK.TMP"|find /i "FAILED 1060:">nul rem 1 non la chaine n'existe pas. rem 0 oui la chaine existe. IF ERRORLEVEL 1 goto Running IF ERRORLEVEL 0 set Service_Status=NOTEXIST&Echo NOT Exist : %1&goto FIN :Running type "%TEMP%\FileWORK.TMP"|find /i "STATE : 4 RUNNING">nul IF ERRORLEVEL 1 set Service_Status=NOTRUNNING&goto notRunning IF ERRORLEVEL 0 set Service_Status=RUNNING&Echo Running : %1 &goto fin :notRunning rem le service est à l'état arreté. type "%TEMP%\FileWORK.TMP"|find /i "FAILED 1062:">nul IF ERRORLEVEL 1 set Service_Status=UNKNOW&goto unknow1 IF ERRORLEVEL 0 set Service_Status=NOTRUNNING&Echo NOT Running : %1&goto fin :Unknow1 rem le service ne peut être interrogé type "%TEMP%\FileWORK.TMP"|find /i "FAILED 1061:">nul IF ERRORLEVEL 1 set Service_Status=UNKNOW&goto unknow2 IF ERRORLEVEL 0 set Service_Status=UNKNOW&Echo Unknown : %1 * Reinterroger plus tard &goto fin :Unknow2 Echo Pending : %1 type "%TEMP%\FileWORK.TMP"|find /i "STATE" goto fin :SyntaxeError Echo. Echo Erreur : Echo Il manque un parametre. Echo %0 NOM_SERVICE Echo. Pause Goto fin :Error2 Echo. Echo Erreur : Echo La variable d'environnement TEMP n'existe pas. Echo La déclarer dans la partie environnement SYSTEM ou USER Echo. Pause Goto fin :fin
Tutoriels Delphi Win32/Delphi .NET/Oracle/PowerShell - FAQ Delphi - FAQ Delphi .NET
Beatus, qui prodest, quibus potest.
Salut,
Si tu veux simplement arrêter le service, tu peux faire un simple
Code : Sélectionner tout - Visualiser dans une fenêtre à part net stop NomDuService
Bonjour et merci SLE![]()
Oui je conait cette commande, il me falait carrement désactiver le service,se qui et fait, merci à vous.
Tu peux aussi utiliser "net start" qui liste les services lancés sur ta machine.
Si le service est coupé en deux, il faut que tu le mette entre guillemets, genre:
"Network Associates Task Manager"
salut,
il faut utiliser le nom indiqué dans Service Name (cf. sc query)
SERVICE_NAME: Spooler
DISPLAY_NAME: Print Spoolercf. http://delphi.developpez.com/faq/?pa...enirnomserviceC:\Temp>SC.EXE interrogate "Print Spooler"
[SC] OpenService FAILED 1060:
Le service spécifié n'existe pas en tant que service installé.
C:\Temp>SC.EXE interrogate "Spooler"
SERVICE_NAME: Spooler
TYPE : 110 WIN32_OWN_PROCESS (interactive)
STATE : 4 RUNNING
(STOPPABLE,NOT_PAUSABLE,ACCEPTS_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x0
C:\Temp>
Tutoriels Delphi Win32/Delphi .NET/Oracle/PowerShell - FAQ Delphi - FAQ Delphi .NET
Beatus, qui prodest, quibus potest.
Rebonjour
le y@m's >>>>>
Sauriez vous tester un processus avec « PSKill » ?
c'est pas une commande windows ça.Envoyé par Furius
Si tu parle de l'utilitaire de Sysinternals :Peut-être que l'utilitaire psList te sera plus interessantusage: pskill [-?] [-t] [\\computer [-u username] [-p password]] <process name | process id>
-?
Displays the supported options.
-t
Kill the process and its descendants.
\\computer
Specifies the computer on which the process you want to terminate is executing. The remote computer must be accessible via the NT network neighborhood.
-u username
If you want to kill a process on a remote system and the account you are executing in does not have administrative privileges on the remote system then you must login as an administrator using this command-line option. If you do not include the password with the -p option then PsKill will prompt you for the password without echoing your input to the display.
-p password
This option lets you specify the login password on the command line so that you can use PsList from batch files. If you specify an account name and omit the -p option PsList prompts you interactively for a password.
process id
Specifies the process ID of the process you want to kill.
process name
Specifies the process name of the process or processes you want to kill.Je ne l'ai pas testé.usage: pslist [-?] [-d] [-m] [-x][-t][-s [n] [-r n]][\\computer [-u username] [-p password]] [name | pid]
-?
Displays the supported options and the units of measurement used for output values.
-d
This switch has PsList show statistics for all active threads on the system, grouping threads with their owning process.
-m
This switch has PsList show memory-oriented information for each process, rather than the default of CPU-oriented information.
-x
With this switch PsList shows CPU, memory and thread information for each of the processes specified.
-t
Shows the tree of processes.
-s [n]
Has PsList run in task-manager-like updating mode. You can optionally specify the number of seconds it runs and abort it by pressing the escape key.
-r n
Task-manager mode refresh rate in seconds (default is 1).
name
Instead of listing all the running processes in the system, this parameter narrows PsList's scan to those processes that begin with the name process. Thus:
pslist exp
would statistics for all the processes that start with "exp", which would include Explorer.
-u
username If you want to kill a process on a remote system and the account you are executing in does not have administrative privileges on the remote system then you must login as an administrator using this command-line option. If you do not include the password with the -p option then PsList will prompt you for the password without echoing your input to the display.
-p
password This option lets you specify the login password on the command line so that you can use PsList from batch files. If you specify an account name and omit the -p option PsList prompts you interactively for a password.
\\computer
Instead of showing process information for the local system, PsList will show information for the NT/Win2K system specified. Include the -u switch with a username and password to login to the remote system if your security credentials do not permit you to obtain performance counter information from the remote system.
pid
Instead of listing all the running processes in the system, this parameter narrows PsList's scan to tthe process that has the specified PID. Thus:
pslist 53
would dump statistics for the process with the PID 53.
Je ne répondrai à aucune question technique par MP.
Pensez aux Tutoriels et aux FAQs avant de poster ;) (pour le java il y a aussi JavaSearch), n'oubliez pas non plus la fonction Rechercher.
Enfin, quand une solution a été trouvée à votre problème pensez au tag :resolu:
Cours Dvp : http://ydisanto.developpez.com
Blog : http://yann-disanto.blogspot.com/
Page perso : http://yann-disanto.fr
Bonjour le y@m's et merci beaucoup
« PSKill » je crois que je l’ai télécharger quelque par mais je ne sais plus ou.
Je viens donc de télécharger « pslist », ici :
http://www.sysinternals.com/utilities/pslist.html
Partager