Problem Ping - any batch file writing gurus

Discussion in 'Software' started by Arroryn, Oct 8, 2009.

  1. Arroryn

    Arroryn we're all dooooooomed Moderator

    4,015
    193
    209
    I have a tricksy little beast I would appreciate some assistance with.

    In short, I need to stop a process - the process namely being svchost.exe - specifically, the one that's hosting the Windows Management Instrumentation service. Simply stopping the service alone isn't enough.

    Then I need to uninstall an MSI, transfer some files and run an exe.

    I want this as a batch file, so I can invoke it from our kixtart script, so that any processes spawned from it (eg the uninstall) run with elevated permissions, instead of having to elevate users locally.

    Help?
     
    Certifications: A+, N+, MCDST, 70-410, 70-411
    WIP: Modern Languages BA
  2. ThomasMc

    ThomasMc Gigabyte Poster

    1,507
    49
    111
    Would "winmgmt /kill" be enough?

    [Added]
    The reason why I'm asking the above is that it seems that its not just the wmi that attached to the svchost(see pic, PID 1008 )
     

    Attached Files:

    Last edited: Oct 8, 2009
    Certifications: MCDST|FtOCC
    WIP: MCSA(70-270|70-290|70-291)
  3. Bluerinse
    Honorary Member

    Bluerinse Exabyte Poster

    8,878
    181
    256
    Quite right, svchost is like the Clapham Junction of processes, and it will have different dependencies on different computers. Tread very carefully with this Arro.
     
    Certifications: C&G Electronics - MCSA (W2K) MCSE (W2K)
  4. Arroryn

    Arroryn we're all dooooooomed Moderator

    4,015
    193
    209
    Oh I know svchost spawns so many processes it's untrue.

    But I think I've just found a strange workaround.

    I've been trying to batter down the service - stopping it didn't help. But I have just found that if I pause the service, it allows me to do what I need without a problem (!). So I can just use net pause and net resume, and the rest is easy street!

    Thanks for your prompt replies chaps, seems this may not be the horror story I once thought it could be... :oops:
     
    Certifications: A+, N+, MCDST, 70-410, 70-411
    WIP: Modern Languages BA
  5. ThomasMc

    ThomasMc Gigabyte Poster

    1,507
    49
    111
    You could bark
    winmgmt /standalonehost
    NET STOP "Windows Management Instrumentation"

    that will atleast get it on its own svchost.exe


    [added]
    Glad you got it going :)
     
    Last edited: Oct 8, 2009
    Certifications: MCDST|FtOCC
    WIP: MCSA(70-270|70-290|70-291)
  6. Arroryn

    Arroryn we're all dooooooomed Moderator

    4,015
    193
    209
    Hokay, I got it done - in the morning actually, which surprised me. I have to tackle a few activex errors that come up in Word after the transfer is done, but I don't think that'll be too tough to sort.

    Ended up figuring out how to elevate the priviledges on the batch file itself too, so I don't even need to elevate the login script (which normally runs with standard privileges).

    I created a batch file that runs a reg file creating a 'runas' key against the class 'batfile' which runs the batch files as administrator. I then call my batch file which does the biz as far as stopping the process, doing the uninstall etc etc is concerned. Then I run another reg file restoring the registry back to its former secure glory.

    Most of you guys are probably thinking 'simples, yeah, so?' but I haven't worked with batch files very much and I was quite chuffed lol :oops:
     
    Certifications: A+, N+, MCDST, 70-410, 70-411
    WIP: Modern Languages BA
  7. Bluerinse
    Honorary Member

    Bluerinse Exabyte Poster

    8,878
    181
    256
    Not at all, that sounds a pretty cool solution to me 8)
     
    Certifications: C&G Electronics - MCSA (W2K) MCSE (W2K)

Share This Page

Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.