Using WMIC to get a specific Process ID

I'm trying to write a batch file to grab a processid of a specific w3wp.exe process. There are multiple w3wp's running on this server, so I need to add a where clause to get the right one. I can do this part...so, I've got this so far:
for /f %%a in ('Wmic process where "commandline like '%%PROD%%'and name='w3wp.exe'" get ProcessId ') do echo %%a
The problem is that the output contains the literal column heading 'Process ID' along with the numeric value for the process id I'm looking for. All I want is the actual PID, so that I can store that in a variable and use it further down in my batch file.
Any help would be much appreciated.
Thank you.

if you like a PowerShell solution it will be like this:
get-process w3wp |  select Id | ft -AutoSize
Or you can actually just use: stop-service w3wp
But if you want batch file, I guess its kinda hard..
Batch file:
 for /f "tokens=2" %%i in ('tasklist ^| find "w3wp.exe"') do set PID=%%i
Every second counts..make use of it. Disclaimer: This posting is provided AS IS with no warranties or guarantees and confers no rights.
IT Stuff Quick Bytes

Similar Messages

  • How to determine which locale uses the specific process

    Hi,
    I would like to get to know which locale uses the specific process.
    I mean that when the process starts it should use the current system locale.
    Where I can check that information which locale are used by the running process?
    I ask because I would like to make sure that for example when the locale are French or Japanese the process/deamon use the current locale.
    Kind regards,
    Daniel

    VivaLaVida wrote:
    Hi,
    currently we are in the process of consolidating our databases. One of the neccessary steps is to figure out which user connects to the database at all. That's easy, we implemented a logon-trigger and log the collected information into a separate table.It could have been even easier by turning on the built-in audit feature.
    If a user with objects (e.g. tables, views, procedures) exists - but this user never connects to the database - does that automatically mean that these objects are not used at all? No need to say that this is not true. But how can we figure out if a connected user has selected an object of this user?audit would be a good choice.
    Our porblem is that we have alot of schemas in our database - but the developers don't know if this schema is not used by an application or not (sad but true).Not sure what developer will do with used/not used application.
    To enable auditing would be one choice to figure out if an object was ever used or not. What's wrong in auditing ?
    Even though audit may have a footprint on performance, that would probably be less costly than any custom solution.
    Nicolas.

  • Alternative to WMIC csproduct get name?

    Everyone,
    I am currently attempting to find a work around that will allow me to leverage a single WDS/MDT image for all of my PC hardware. At the moment, my biggest hurdle comes from hardware manufacturers that are not properly labeling their hardware. 
    My company has a decent mixture of traditional OEM PCs (Dell, HP, etc.) as well as consumer level PCs with a variety of components (ASUS, Intel, EVGA, etc).  The issue I am faced with is getting the proper identification information from the consumer
    level hardware using the standard 'wmic csproduct get name' command.  
    If I run the 'wmic csproduct get name' command, several of my components return vague identifiers like System Product Name or OEM. Obviously, this is not ideal as it does not uniquely identify the hardware.  In an effort to find a solution, I discovered
    a suggestion to use the WBEMTEST utility in another thread but sadly, the results are the same - System Product Name or OEM appear in those locations.  However, a thread on superuser.com suggested the use of 'wmic baseboard get product' which actually
    returns uniquely identifiable data. 
    As I understand it, WDS/MDT uses the wmic csproduct get name command to identify hardware during the image deployment process. This leads me to question
    Whether WDS/MDT can be modified to also use the 'wmic baseboard get product' command if the results of 'wmic csproduct get name' return data that is unusable, or
    Whether the results of 'wmic baseboard get product' can be used in lieu of the results of 'wmic csproduct get name' 
    Any feedback the community can offer will be greatly appreciated.  I know this is not the first time this issue has come up but thus far, I have not found a single solution or workaround that adequately resolves the problem short of buying hardware
    from manufacturers that know what they are doing.  
    NOTE: I originally included a screenshot and supporting links but the site disallowed their use.  Sorry about that.

    You are looking for a "userexit" script to fix "Lenovo" machines on "MDT"
    http://deploymentbunny.com/2012/05/01/modelalias-user-exit-for-microsoft-deployment-toolkit-20102012/
    Keith Garner - keithga.wordpress.com

  • Tether & Develop Settings in LR3 always get the 'Update Process Version'

    I am using tether with develop settings in LR3. I keep getting the 'Update Process Version' and it won't apply the filter unless I click the (!). It does this with newly created presets. Please help.

    awimaging wrote:
     bit of a waste of £78!
    Erm, 2 words... free trial? 
    Anyway, let's get you sorted out.  Are you the same hania on the POTN forums, or do you just have the same problem?
    First things first, when you mention repairing permissions, I guess you're a Mac user.
    First, hold down Opt while starting LR and see if you can start a clean catalog ok.  That'll determine whether it's catalog specific.
    Then go to Macintosh HD / Users / [your username] / Library / Preferences /  and move or delete any com.adobe.lightroom*.plist files.
    And while you're there, I'd also go to Macintosh HD / Users / [your  username] / Library / Application Support / Adobe / Lightroom / and move  that Lightroom folder somewhere else for the moment.
    Then see if it works.  Could be a few things - most likely are a problem with the catalog, corrupted preferences file, or a preset that it doesn't like.  We can exclude those quite easily using the above.

  • Component is not getting displayed in process scheduler menu

    Hi All,
    I have created a project and created/registered a component in that project. I have also added a page which is having a record definition with a record named L_RUNCNTL having two search fields, to this component and configured L_RUNCNTL as search record for this component.
    I have registered this component with below details:
    Menu Name : PROCESS_SCHEDULER
    Bar Name : PROCESS
    Folder Name as PT_PROCESS_SCHEDULER
    Select “Always Use default local node?” Check box
    Permission List : PTPT1000
    But after registration, when I open process scheduler menu I dont see this component listed. However, previously I created a component in this project and registered it with same details given above and I could see it in process scheduler menu.
    I am surprised why another component registered with same details is not getting displayed in process scheduler menu.

    Thanks Michel,
    I got this problem resolved. Here is what I did:
    Ran portal security sync at the navigation PeopleTools > Portal > Portal Security Sync.
    Cleared browser cache, accessed the page again and saw the link was available.

  • How: can i get a specificated item from a list with more than 100.000 items

    Hi,
    i have a very large list and i got always an exception that the list has more than 5000 items and cant query!! But in the default list view i can see, order and filter all items. So how can i do this by c#?

    Hi,
    According to your description, my understanding is that you want to get a specific list item form a list which with more than 100000 items using C#.
    I suggest you can use CAML Query with some condition and set Row Limit to specify the number of items to return.
    Here is a detailed code demo for your reference:
    Client Object Model Access Large Lists/Overcome ListView Threshold while accessing large list
    Thanks
    Best Regards
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • Using JMX to get status information about NetWeaver cluster

    Hi everybody,
    We are trying to use JMX to get some status information about NetWeaver cluster.
    For example, using the MBean with the name u201Ccom.sap.default:name=EL1,j2eeType=SAP_J2EEClusteru201D we can obtain the list of all instances running in cluster. Here an instance is a u201CJava instanceu201D in the NetWeaver terminology.
    The method u201CgetInstanceNodeIDsu201D provides us with a list of all nodes of an instance.
    Concretely, calling this method for a cluster running on one machine with two java processes, we get the following list of node Ids: u201C0, 1476420, 1476450, 1476451u201D where the last two correspond to the two java processes.
    What are the first two node Ids from the list?
    How can the last two node Ids be identified as java processes?
    How can we obtain status information about each java process (node id) ?
    Thanks for all ideas,
    Radu

    As there seems to be a lot of interest in this subject, and since I found some form of solution, I thought I'd share it with you.
    In the es-cli interface, there is a thing called browse mode. Activate it by typing browse after logging in.
    Now you can easily browse your network and all of the managed objects. Use getattributes at the end of each branch to see the properties of objects. So far, I've indexed all of the kernel reader module, the health monitor module, the common config reader and the config reader for workgroup servers. If my employer allows, I will post results to http://tille.garrels.be/training/sunmc/ - check later this week.
    Machtelt.

  • How to get the specific name of the workset which is currently selected by the user in sap portal 7.0

    Dear Expert,
    I have one requirement like to read the selected workset name in portal by the current user.I have read two documents regarding how to retrieve the PCD contents (iViews, Pages, Worksets and Roles) and its properties like Created by, Changed by, Last changed by and others using PCD API.
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/6112ecb7-0a01-0010-ef90-941c70c9e401?overridelayout=true
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/508baf88-9335-2d10-efa6-c6ad61e5fc4b?quicklink=index&overridelayout=true
    But I am not able to understand how to get the specific name of the workset which is currently selected by the user.Can you please help me.
    I am using portal 7.0.
    Thanks & Regards,
    Patralekha

    Hi Expert,
    I found that we can use Interface INavigationHelperService to read Portal Role selected by user at runtime from http://scn.sap.com/thread/52194
    But this class is available in SAP NetWeaver 7.30 Enterprise Portal .
    But in SAP NetWeaver 7.0 Enterprise Portal that interface is not available.
    INavigationService is available there.
    But didn't get any proper discussion on this interface for the same requirement.
    Can you please help me.
    Thanks & Regards,
    Patralekha

  • How to get the all process orders and outbound deliveries based on material

    Hi Team ,
    I need one help from you regarding the MB 56 transaction.
    My doubt is : How to get the all process orders and outbound deliveries based on material, plant and batch?
    Please help me regarding this.
    Thanks & Regards,
    Srikanth.

    Hi,
    You can use ST05,to trace the program and find out,
    hope it will help you...
    thanks and regards,
    veera.

  • Using Email to initiate a BPEL Process

    Hi All,
    We have a request to process a .csv file which comes as an attachment thru Mail.
    we are able to do the setup to invoke the BPEL Process as the mail is received.
    We want to know how to get attached file in BPEL Process to process it further.
    We are using BPEL 10.1.3.
    Please help.
    Thanks and Regards,
    Vikram Singh

    There is currently no inbound email adapter afaict. If you want a quick solution on a unix system, I would advise you to write a custom shell/python/perl script that can do convert the inbound mail to a xml format and post that xml to a webservice (BPEL process). You can use 'curl' or 'wget' to post it to the BPEL process. This method is discussed in more detail at this Zwiki mail setup page (replace Zope by Oracle BPEL :).
    See also this previous Oracle forum article Re: Using email to invoke a BPEL process, which discusses this same issue.
    Hope this helps,
    Regards,
    PieterB

  • Getting the sub Process instance id through PAPI

    Hi Can anyone suggest me how to get the sub process instance id using PAPI?

    I was only able to figure this out as follows... If you have an InstanceInfo variable (called "instance"), then:
    InstanceEvent[] events = new fuego.papi.InstanceEvent[0];
    events = session.getInstanceEvents(instance.getId());
    for (InstanceEvent event : events) {
    if (event.type == 14) {
    System.out.println("child instance ID is: " + event.eventData);
    I ended up creating a recursive function that would drill down to get sub-sub-...-sub-instance IDs as necessary.
    Todd

  • Getting a specific number of rows

    Hi,
    I would like to know how to get a specific number of rows. For example, I want to page data in my web application, so I'd like to be able to retrieve just 25 rows in my SELECT statement. I searched and I couldn't see anything under the obvious keywords of LIMIT and TOP (as used by other database vendors) so I'm wondering if possible, what do I need to do - a pointer to the relevant documentation would be helpful also.

    You can achieve this with rownum
    http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14200/pseudocolumns009.htm#i1006297
    Best regards
    Maxim

  • When I try to use spellcheck, I get the "Cannot find the User dictionary". It has always worked in the past and when I go to choose the main dictionary, it just goes back to the same line, cannot find user dictionary.

    When I try to use spellcheck, I get the "Cannot find the User dictionary". It has always worked in the past and when I go to choose the main dictionary, it just goes back to the same line, cannot find user dictionary.

    Have you ever created a user dictionary? You have to manually create one, AppleWorks won't do for you. The user dictionary & any other dictionaries belong in the AppleWorks Essentials folder which belongs in the AppleWorks 6 folder in Applications.
    Deleting & reinstalling AppleWorks from the original disk will not delete your files unless you have saved them in the application folder. The Mac OS creates a separate Documents folder for your files & that is where the documents you created should be.
    Unless all of your documents are AppleWorks 6 word processing documents, Pages alone is not sufficient. The iWork applications - Keynote, Pages & Numbers - can only open AppleWorks 6 presentation, word processing & spreadsheet documents, respectively. They will not open any other type of AppleWorks 6 files or any AppleWorks 5 or any version of ClarisWorks files.

  • How to upload using  upload button and want to process it....

    Hi,
    I need a program to upload a file [Excel file] using upload button and
    want to process the excel sheet and store the data in database.
    I know that we can upload using Html - file type.
    but I dont know how to retrieve that uploaded file to process it?
    I mean , Is there any function like requset.getParameter() to get the uploaded file?

    Go to the [Apache Commons FileUpload homepage|http://commons.apache.org/fileupload] and carefully read the 'User Guide' and 'Frequently Asked Questions' sections from top to bottom (do not only focus on the code examples, but also on the article's text!!).

  • Get name of process associated with PID

    The subject is the question -- I have the PID(s). Either I'm overlooking something or this is far more difficult than I expected (would be happy to hear differently). Do shell script routine would be fine.

    Yesterday I assigned some credits to the responses to my post, without comment. For anyone actually interested, I do have some comments.
    In terms of the way I initially presented my question, Camelot's response was most on target. I said I had a PID and wanted to get the related process name, and he pointed me at "lsof PID" (with a length enhancement). Typically, that gave a result like "Default" whereas the full name is actually "Default Folder X" -- a result of calling for the first word (only) in the COMMAND column of the lsof result.
    Niel's responses covered some ground that I had explored and given up on.
    But in fact I had actually gotten PID's from "lsof /", so all this seemed pretty circular; it seemed silly not to figure out how to get a complete process name from lsof / in the first place. To that end, Nils C. Anderson of the UNIX forum pointed me to "lsof -Fc /" as a way of getting the complete COMMAND column of lsof /. The result includes a couple alpha identifiers and some PID info that can be edited out, and what's worked best for me is: set COMlist to do shell script "lsof -Fc / | sed -e 's/^p.*//' -e 's/c//'" -- a fast one liner.
    There remains one issue (see below), but this approach has provided the best process name list yet, at least for open files.
    The remaining issue is this: a small but significant number of open files return the COMMAND in the form (file name)\xxxxxxxx. If I want to compare that to a list of actual file names, somehow I've got to get rid of the "\xxxxxxxxx" portion of the COMMAND, but (maybe I'm blind) the escape seems to defy attempts at doing that. E.g., do shell script "echo " & (COMMAND)&" | sed 's/\xxxxxxxxx//' returns an error, and I haven't found a way to add the second escape AS is looking for. If I should do a new post on this specific issue, tell me that.

Maybe you are looking for

  • Contacts being erased?

    I've had my iPod touch for 4 years, never had a problem with my contacts but in last 2 weeks they have been completely erased twice. The first time I lost everything and had to start again as I allowed my ipod to resync with itunes before I realised

  • Problem in queue operation

    hello friends, in the vi below if I am putting more than one commands ie strings in command control all the commands start executing one by one and after all commands are finished again they start executing as they are in loop.. for example if in the

  • Switching from interleaved broadband to fast

    As above really how to go about it as ive heard this is usually enabled to try and counteract noise on the line but not every line has been checked for noise Solved! Go to Solution.

  • Can SLT replicate data directly to Hadoop

    Hi, Has anyone successfully connected SAP SLT directly to Hadoop or other big data services where the big data is the target? We have a scenario where our SAP OER will produce millions of records of which we wish to report against but see that the sc

  • High Security Apps

    I'm going to start testing an iPad for use in a K-12 school environment. One of the things I'm going to need is some way to lock the unit down so that it can still be used but no modifications can be done to it, and when I say *NO MODIFICATIONS* I re