Jump to content

Piping mit "find"


Der letzte Beitrag zu diesem Thema ist mehr als 180 Tage alt. Bitte erstelle einen neuen Beitrag zu Deiner Anfrage!

Empfohlene Beiträge

Salut,

 

ich möchte gern den Status von Diensten abfragen. Dazu habe ich mir die Kombination net start und find auserwählt:

 

net start | find "Dienstname" > NUL

 

Leider erhalte ich immer die Fehlermeldung

 

"find: Dienstname: No such file or directory"

 

net start und find "alleine" funktionieren aber ... Wo ist mein Fehler?

 

Grüße, e2e4

 

Ps., off-topic: Wieso kann "find" nicht mit der Forumssuche gesucht werden?

Link zu diesem Kommentar

Hi e2e4,

 

wieso nimmst du nicht das Prog dafür was genau diesen Funktion anbieten soll:

sc.exe (Bei xp u. 2k3 dabei für 2k zum Download verfügbar)

C:\>sc /?
*** Unrecognized Command ***
DESCRIPTION:
       SC is a command line program used for communicating with the
       NT Service Controller and services.
USAGE:
       sc <server> [command] [service name] <option1> <option2>...

       The option <server> has the form "\\ServerName"
       Further help on commands can be obtained by typing: "sc [command]"
       Commands:
         query-----------Queries the status for a service, or
                         enumerates the status for types of services.
         queryex---------Queries the extended status for a service, or
                         enumerates the status for types of services.
         start-----------Starts a service.
         pause-----------Sends a PAUSE control request to a service.
         interrogate-----Sends an INTERROGATE control request to a service.
         continue--------Sends a CONTINUE control request to a service.
         stop------------Sends a STOP request to a service.
         config----------Changes the configuration of a service (persistant).
         description-----Changes the description of a service.
         failure---------Changes the actions taken by a service upon failure.
         qc--------------Queries the configuration information for a service.
         qdescription----Queries the description for a service.
         qfailure--------Queries the actions taken by a service upon failure.
         delete----------Deletes a service (from the registry).
         create----------Creates a service. (adds it to the registry).
         control---------Sends a control to a service.
         sdshow----------Displays a service's security descriptor.
         sdset-----------Sets a service's security descriptor.
         GetDisplayName--Gets the DisplayName for a service.
         GetKeyName------Gets the ServiceKeyName for a service.
         EnumDepend------Enumerates Service Dependencies.

       The following commands don't require a service name:
       sc <server> <command> <option>
         boot------------(ok | bad) Indicates whether the last boot should
                         be saved as the last-known-good boot configuration
         Lock------------Locks the Service Database
         QueryLock-------Queries the LockStatus for the SCManager Database
EXAMPLE:
       sc start MyService

Would you like to see help for the QUERY and QUERYEX commands? [ y | n ]: y
QUERY and QUERYEX OPTIONS :
       If the query command is followed by a service name, the status
       for that service is returned.  Further options do not apply in
       this case.  If the query command is followed by nothing or one of
       the options listed below, the services are enumerated.
   type=    Type of services to enumerate (driver, service, all)
            (default = service)
   state=   State of services to enumerate (inactive, all)
            (default = active)
   bufsize= The size (in bytes) of the enumeration buffer
            (default = 4096)
   ri=      The resume index number at which to begin the enumeration
            (default = 0)
   group=   Service group to enumerate
            (default = all groups)

 

Z.b. eine Abfrage des Spooler-Dienstes:

C:\>sc queryex 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
       PID                : 584
       FLAGS              :

 

LG Gadget

Link zu diesem Kommentar

Salut,

 

wieso nimmst du nicht das Prog dafür was genau diesen Funktion anbieten soll

 

Unter XP/2k3 habe ich in der Tat bereits mit sc getestet und meine Abfragen á la

 

sc query "Dienstname" | find "state"

 

durchgeführt und ein positives Ergebnis erhalten. Unter 2k habe ich hiermit keinen Erfolg zielen können, sprich keine Ausgabe.

 

Mit meinem Ansatz von oben bin ich jetzt aber schon einen Schritt weiter und der schaut gut aus ;)

 

net start | findstr "Dienstname" > NUL

 

Überraschenderweise liefert

 

sc query "Dienstname" | findstr "state"

 

bei mir unter Win2k kein Ergebnis ...

 

Grüße, e2e4

Link zu diesem Kommentar
Der letzte Beitrag zu diesem Thema ist mehr als 180 Tage alt. Bitte erstelle einen neuen Beitrag zu Deiner Anfrage!

Schreibe einen Kommentar

Du kannst jetzt antworten und Dich später registrieren. Falls Du bereits ein Mitglied bist, logge Dich jetzt ein.

Gast
Auf dieses Thema antworten...

×   Du hast formatierten Text eingefügt.   Formatierung jetzt entfernen

  Only 75 emoji are allowed.

×   Dein Link wurde automatisch eingebettet.   Einbetten rückgängig machen und als Link darstellen

×   Dein vorheriger Inhalt wurde wiederhergestellt.   Editor-Fenster leeren

×   Du kannst Bilder nicht direkt einfügen. Lade Bilder hoch oder lade sie von einer URL.

×
×
  • Neu erstellen...