Script to find the service and manage its state

We have a service that runs with different names on different machines like
Bomgar-scadsadccd, Bomgarsdscchfn, Bomgarscnkfkdk
So, here we need to write a VB script that will find this service with partial name "Bomgar" and check it's status like
1) Not present, then should install from a shared folder like "start \10.216.16.245\Bomgar.exe"
2) Installed but not running, then start the service.
3) Installed and running then quit.
How can we achieve this? This is what i have tried..
"strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colRunningServices = objWMIService.ExecQuery("Select * from Win32_Service
where Name='bomgar*'")
nItems = colRunningServices.Count
    If nItems > 0  Then
For Each objItem in colRunningServices
    If objItem.State = "Stopped" Then objItem.startservice            
            ElseIf objItem.State = "Running" Then exit
End If
    Next
Else
        start \\10.18.23.245\Shared\Bomgar.exe
End If

We have a service that runs with different names on different machines like
Bomgar-scadsadccd, Bomgarsdscchfn, Bomgarscnkfkdk
So, here we need to write a VB script that will find this service with partial name "Bomgar" and check it's status.
Instead of re-inventing the wheel with a script you could these existing console commands:
net  start  |  find  /i  "Bomgar"
(to find out which Bomgar services exist)
sc  query "Bomgar-scadsadccd"
(to check the status of this service)
net start "Bomgar-scadsadccd"
(to start the service)

Similar Messages

  • Script to find a user and restart two services

    I am looking to make a script to first find a user that is connected to a server (list) the to stop Spooler, then stop cpsvc. Once the services are stopped, the script would then clear out the folder on "C:\Windows\System32\spool\PRINTERS"
    Directory. Once that was done, the script would then start Spooler and cpsvc. At the end it would echo the services were restarted and to try to print now.
    Lee Mossolle

    A user cannot stop and start services and cannot delete files in the system folders.
    There is no need to look for the services in that way  You will have to do this remotely.  Just find the services if they exisit and stop them then remotely delete the contents of the spooler folder.
    PowerShell remoting would be the easies way to do this.
    strComputer = WScript.Arguments(0)
    WScript.Echo "Running Against Remote Computer Named: " & strComputer
    set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
    Set colListOfServices = objWMIService.ExecQuery("Select * from Win32_Service Where Name = 'cpsvc' OR Name = 'spooler'")
    for Each objService in colListOfServices
    objService.StopService()
    objService.StartService()
    Next
    Until you understand how yor code will work avoid over coding.  It just adds confusion and errors.   The above is functionally equivalent to what you posted. 
    I suspect there may be a dependency between cpsvc and spooler.  In that casr yo can only kill them in the correct order.  This will require to loops of a more sophisticated scripting approach.
    We can also use the 'Forse' argument and retriev the master service (spooler) and force it to stop all dependent services.  We would then retrive all services and start them. We can also just retrieve the dependency list and use that.
    The code is simple and will allow the dependencies to be added if needed.
    You can also use PowerShell which is much easier.
    Get-Service spooler -computer remotepc | Stop-Service -force
    Get-Service spooler -computer remotepc | Start-Service
    We can wrap this in a function for convenience.
    ¯\_(ツ)_/¯

  • I need help writing a script that finds the first instance of a paragraph style and then changes it

    I need help writing a script that finds the first instance of a paragraph style and then changes it to another paragraph style.  I don't necessarily need someone to write the whole thing, by biggest problem is figuring how to find just the first instance of the paragraph style.  Any help would be greatly appreciated, thanks!

    Hi,
    Do you mean first instance of the paragraph style
    - in a chosen story;
    - on some chosen page in every text frames, looking from its top to the bottom;
    - in a entire document, looking from its beginning to the end, including hidden layers, master pages, footnotes etc...?
    If story...
    You could set app.findTextPreferences.appliedParagraphStyle to your "Style".
    Story.findText() gives an array of matches. 1st array's element is a 1st occurence.
    so:
    Story.findText()[0].appliedParagraphStyle = Style_1;
    //==> this will change a paraStyle of 1st occurence of story to "Style_1".
    If other cases...
    You would need to be more accurate.
    rgds

  • Script to find the Concurrent Request ID from its associated SID

    Hi,
    In one of my production system, my server load is going very high. From the top used process ID of server, I found the SID and found out that the program running is "ora_rw20_run@acgerp (which is a concurrent program)
    How do I find out the Request ID using the SID/PID? Can someone please provide me the script to find the Concurrent Request ID from its associated SID?
    Thanks!

    There has been no new changes in the report server or in the database. Suddenly of late, we have been observing this program running and it never ends, consuming major part of the cpu load. Not sure what this program is -> ora_rw20_run. There is no mention about it in metalink or in google.
    I followed MOS Doc 1058210.6 and tried to debug more. But the formatted output doesnt give any info either.
    TKPROF: Release 10.2.0.2.0 - Production on Tue Oct 20 09:44:21 2009
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    Trace file: prod_ora_15721.trc
    Sort options: default
    count = number of times OCI procedure was executed
    cpu = cpu time in seconds executing
    elapsed = elapsed time in seconds executing
    disk = number of physical reads of buffers from disk
    query = number of buffers gotten for consistent read
    current = number of buffers gotten in current mode (usually for update)
    rows = number of rows processed by the fetch or execute call
    0 statements EXPLAINed in this session.
    Trace file: prod_ora_15721.trc
    Trace file compatibility: 10.01.00
    Sort options: default
    1 session in tracefile.
    0 user SQL statements in trace file.
    0 internal SQL statements in trace file.
    0 SQL statements in trace file.
    0 unique SQL statements in trace file.
    96507 lines in trace file.
    0 elapsed seconds in trace file.
    When I use the below query, I can find that the session is running a module named "PAXMGSLS" and the action is Concurrent Request.
    But I am not sure how to find out the Concurrent Request ID using this info to dig more (look into the concurrent request log files etc)
    select s.sid,s.serial#,p.spid os_pid,s.status,
    s.osuser,s.username,s.COMMAND,s.MACHINE,s.MODULE, s.SCHEMANAME,
    s.LOCKWAIT,s.action
    from v$session s, v$process p
    WHERE s.paddr = p.addr
    and s.sid = 823
    SID     SERIAL#     OS_PID     STATUS     OSUSER     USERNAME     COMMAND     MACHINE     MODULE     SCHEMANAME     LOCKWAIT     ACTION
    823     47     4559     ACTIVE     applprod     APPS     3     acgerp     PAXMGSLS     APPS          Concurrent Request

  • Find the service which controls agent on job server and find out the login it's using ?

    How do I find the service that's controlling my SQL server agent on the job server and find out the login it's using ? Is there a query for this ?

    Go to SQL Server Configuration Manager and you will see the SQL Server Agent service there with all the information you need.
    Programmatic way:
    http://stackoverflow.com/questions/7324407/get-service-account-details-of-the-sql-agent-service
    Kalman Toth Database & OLAP Architect
    IPAD SELECT Query Video Tutorial 3.5 Hours
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

  • VB Script to find the last modified file and time in a directory

    Hi,
    I am new to VB script i need a script to find the latest modifed file and last modifed time in a directory(Contains  folders and sub folders inside it). it has to go through all the folders and get the latest file and last modifed time.

    Thanks it worked for me Get-ChildItem C:\Users\sujith.reddy.komma\Desktop\Suj1\* -recurse |?{-not $_.PsIsContainer} |Sort LastWriteTime -desc | select -first 1 now in my script i have hard coded the directory i need to run this script in different
    servers from one location i will put all the different paths in one text file and ineed to pass them to this script can you help me with this?
    Essentially you are incrementally asking us to write each line for you.  I recommend freeing yourself of this misery and leraning PowerShell.  THe answers to all of your questions are learned in the first few hours of study.
    Start here:
    http://technet.microsoft.com/en-us/scriptcenter/dd793612.aspx
    ¯\_(ツ)_/¯

  • I paid for a rented film on my iPad, got the receipt but now i can't find the film and its not in my purchase history. Help!

    I paid for a rented film on my iPad, got the receipt but now i can't find the film and its not in my purchase history. Help!

    If you rented and downloaded it on your iPad then it should be in the Videos app - if it doesn't show in there then have you got a film age rating set in Settings > General > Restrictions that is hiding it ?

  • I have redeemed my code and downloaded the Mountain Lion overnight. Now I am unable to find the download and unable to install it. And the code says that its already redeemed. What can I do? Please help.

    I have redeemed my code to download the Mountain Lion. I left it for download overnight. Now I am unable to find the download and its not installed. And the code says that its already redeemed so I cannot download the Mountain Lion again. Please help.

    Look in your Applications folder.

  • Find an iphone 5 in the club and i want you to help me find the owner and return it to the user.  its been erased and no sim card in it .when i try to configure , it says i should enter an apple  and a password.

    find an iphone 5 in the club and i want you to help me find the owner and return it to the user.
    its been erased and no sim card in it .when i try to configure , it says i should enter an apple
    and a password.

    Since it was erased and no sim card the owner probably got rid of it of some reason.

  • Is there a way to dial a contact by just typing its name in the keypad....as one can do in all the blackberry and android dialers...it is quite a job first to find the contact and then dial..

    Is there a way to dial a contact by just typing its name in the keypad....as one can do in all the blackberry and android dialers...it is quite a job first to find the contact and then dial..

    People - you critisize something you've no idea about! Smart dialing (also called T9) is NOT about text input for God's sake...it's about dialing a contact in a really quick and simple way just by clicking on one of 10 dial buttons (much bigger and easier to be tapped btw especially on the move) and the phone finds all the contacts matching typed combination
    For example I want to dial contact MLADD - I then tap on 6,5,2,3,3 and the phone searches for contacts matching all the combinations hidden on these numbers.
    Another example: see Apple's website containing contact line number specified in 2 ways: (800) MY-IPHONE (800-694-7466)
    Do you get my point now?
    I've used at least 6 different phones in my life so far and went through most of well known platforms including Symbian, Blackberry, Android, Windows Phone and now iOS. I'm very sure there is no better and faster way to quickly and easily dial somebody but by using a smart dial. Dialing somebody this way takes 2 seconds while dialing using tapping on contacts field, then typing a word using keyboard (assuming you click on a right button when on the move) takes a while longer and is frustrating.
    It's just a matter of a wider perspective when looking at this problem. If you would use it at least once - you would demand it as well.
    For people liking tapping everywhere to perform basic actions - let it be as it is, but why not to improve something by adding an additional option in setting and enable SmartDial?

  • Script to find out table and index candidates to keep in the buffer pool

    I am looking for a script to find out tables and indexes to keep in the buffer pool.
    Could you help me on this ?
    thanks...
    Markus

    this is more of a open question. As you know ur data well. We do not know whats ur data. cachin tables in buffer pool is okay, but it might age out after not being used...instead you can use the KEEP POOL...to cache small tables/popular tables into the keep pool...as keep pool guarantees full caching .....
    here are some links on keep pool cacheing
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14211/memory.htm#sthref410
    http://www.dba-oracle.com/oracle_tips_cache_small_fts.htm
    http://www.dba-oracle.com/t_script_automate_keep_pool_tables_indexes.htm
    http://www.dba-oracle.com/oracle_news/news_caching_keep_pool_large_objects_clob_blob.htm
    Edited by: user630084 on Apr 8, 2009 5:48 AM

  • Tell me about the Service Delivery Management  in the sap

    hi
    Sap gurus
    plz tel me the
    Service Delivery Management in Sap

    Hello,
    Service delivery management is also called Service Level Management, is the process of negotiating, defining, measuring, managing and imprving the quality of IT services at an acceptable cost. All of this must take place in an environment of rapidly changing business needs and rapid changes in technlogy. Service level management aims to find the right balance between qualitysupply and demand, customer friendliness and cost of IT services. It is important that both the provider and the customer realize that a service is being provided and being received. Service Level Management includes designing, agreeing and maintaining the following:
    Service Level Agreements (SLAs)
    Operational Level Agreements (OLAs)
    Underpinning Contracts (UCs)
    Service Quality Plans.
    Regards,
    Ravi

  • HT3986 I've had MS Office:mac 2011 on my imac for around 18 months now.  Outlook has just disappeared and when I find the file and open it it tells me that there is a problem and I may need to re-install it.  I've just done this using the installation dis

    I've had MS Office:mac 2011 on my imac for around 18 months now.  Outlook has just disappeared and when I find the file and open it it tells me that there is a problem and I may need to re-install it.  I've just done this using the installation disc which, then said the installation had been successful.
    Outlook is still not working.  Can anyone please advise me on what to do next.

    Remove MS Office 2011 completely (here are instructions) and reinstall it.
    It's not a simple or fast process but it is important to follow all of the steps in order to get all the files that Office scatters around. This will not affect your data files, only MS Office and its preferences.

  • FM/Class to find the class and characterstics for a given material

    Hi All,
    Is there any Class/FM to find the class and characterstics for a given material.I tried some BAPI_OBJCL* BAPI's but lot of the BAPI's need classnum as input parameter. But i need a BAPI or tables or class which can give the class and its characterstic values for a given material.

    Hi Ben
             Try ..
    BAPI_OBJCL_GETCLASSES
    BAPI_OBJCL_CREATE

  • My acer Aspire V7-481P touchscreen stopped working. I can no longer find the pen and touch settings on my computer, please help.

    My acer Aspire V7-481P touchscreen stopped working. I can no longer find the pen and touch settings on my computer, please help, I have tried to download all the drivers on the acer website and it is still not working. The touchscreen previously worked before
    but unexpectedly stopped.

    touchscreen don't need driver
    go to device manager, find Human Interface Device, find HID-compliant touchscreen (maybe under USB input device), try to enable it, click yes and restart PC
    If not solved, try to perfrom system restore (back to condition when this PC working fine)
    http://acer.custhelp.com/app/answers/detail/a_id/11564/related/1
    for more details TS, i suggest contact Acer

Maybe you are looking for