Results 1 to 12 of 12

Thread: WMI -> start services in network computers? [Resolved]

  1. #1

    Thread Starter
    Fanatic Member TDQWERTY's Avatar
    Join Date
    Oct 2003
    Location
    Oporto & Leiria, Portugal / Luanda, Angola
    Posts
    972

    Resolved WMI -> start services in network computers? [Resolved]

    Hello, i have a issue, i'm trying to run a program that is in a network path \\backups\bin\dobackup.exe

    I want to order all computers to open that program at least once a day..the program i have, doesn't work, i think it's because of not allowing to put login/password, it's WMI based.
    I would apreceate is someone could help me in this

    Thanks
    Last edited by TDQWERTY; Jun 29th, 2005 at 06:18 AM.
    ::Winamp 5.xx id3v2 & modern skin support::
    ::NetCF DataGrid Programatically Scroll Example::
    Don't forget to rate posts from those who helped you solving your problem, clicking on and rating it.

  2. #2
    Frenzied Member moinkhan's Avatar
    Join Date
    Jun 2000
    Location
    Karachi, Pakistan
    Posts
    2,011

    Re: WMI -> start services in network computers?

    Quote Originally Posted by TDQWERTY
    Hello, i have a issue, i'm trying to run a program that is in a network path \\backups\bin\dobackup.exe

    I want to order all computers to open that program at least once a day..the program i have, doesn't work, i think it's because of not allowing to put login/password, it's WMI based.
    I would apreceate is someone could help me in this

    Thanks
    dobackup.exe is a service?
    also tell me what operating system your network computers have?

  3. #3

    Thread Starter
    Fanatic Member TDQWERTY's Avatar
    Join Date
    Oct 2003
    Location
    Oporto & Leiria, Portugal / Luanda, Angola
    Posts
    972

    Re: WMI -> start services in network computers?

    Yes, that program is a system service called daily_backup it can be started using "net start daily_backup" there are 4 Windows XP SP2 and one Windows 2003.
    In the Windows 2003 machine the system service sometimes doesn't start using "net start" i have to start it calling the program directly. That's why i would prefer to execute directly the program and not start that service.

    I also tryed that project to list all the processes that i have attached here (doesn't work for me)
    Last edited by TDQWERTY; May 21st, 2005 at 03:03 AM.
    ::Winamp 5.xx id3v2 & modern skin support::
    ::NetCF DataGrid Programatically Scroll Example::
    Don't forget to rate posts from those who helped you solving your problem, clicking on and rating it.

  4. #4

    Thread Starter
    Fanatic Member TDQWERTY's Avatar
    Join Date
    Oct 2003
    Location
    Oporto & Leiria, Portugal / Luanda, Angola
    Posts
    972

    Re: WMI -> start services in network computers?

    Doesn't anyone have an ideia?

    frmMain.frm (5.8 KB, 5 views) and no answers??
    ::Winamp 5.xx id3v2 & modern skin support::
    ::NetCF DataGrid Programatically Scroll Example::
    Don't forget to rate posts from those who helped you solving your problem, clicking on and rating it.

  5. #5
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: WMI -> start services in network computers?

    Can you map that folder? That way you can log on when you map it, or map it once, and have it remain mapped when you logout.

  6. #6
    Hyperactive Member
    Join Date
    Sep 2000
    Location
    NJ, USA
    Posts
    326

    Re: WMI -> start services in network computers?

    The code below will start a service . However, these are windows services. Your example appears to be just a regular program? That is also possible using WMI, however, you would need to escalate your permissions by providing Admin credentials if your program does not have them. I forget how to do it off the top of my head.

    VB Code:
    1. Private Sub StartService(ServiceName As String, strComputer as String)
    2.  
    3. Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    4. Set colListOfServices = objWMIService.ExecQuery("Select * from Win32_Service Where Name ='" & ServiceName & "'")
    5. For Each objService In colListOfServices
    6.     objService.StartService
    7. Next
    8.  
    9. End Sub
    VB.NET 2005 Express with .Net 2.0
    C# 2010 .Net 4.0

  7. #7

    Thread Starter
    Fanatic Member TDQWERTY's Avatar
    Join Date
    Oct 2003
    Location
    Oporto & Leiria, Portugal / Luanda, Angola
    Posts
    972

    Re: WMI -> start services in network computers?

    Thanks Chris H but seems not to be working and yes, i'm used the Admin account of the network and i0v tryed too with local admin account but it seems not to do nothing.

    btw, i'v tryed to start the Themes service..didn't worked too

    \\backups\bin\
    Is mapped as W: but i want to run the service by myself, i don't want that service to start always the computers start.

    Any more ideias?

    thanks
    ::Winamp 5.xx id3v2 & modern skin support::
    ::NetCF DataGrid Programatically Scroll Example::
    Don't forget to rate posts from those who helped you solving your problem, clicking on and rating it.

  8. #8
    Hyperactive Member
    Join Date
    Sep 2000
    Location
    NJ, USA
    Posts
    326

    Re: WMI -> start services in network computers?

    Quote Originally Posted by TDQWERTY
    Thanks Chris H but seems not to be working and yes, i'm used the Admin account of the network and i0v tryed too with local admin account but it seems not to do nothing.

    btw, i'v tryed to start the Themes service..didn't worked too

    \\backups\bin\
    Is mapped as W: but i want to run the service by myself, i don't want that service to start always the computers start.

    Any more ideias?

    thanks
    Try starting Messenger and see if that works. Set ServiceName to Messenger. The code won't work for your application as it looks like you are trying to run a program and not a Windows Service.

    There is code out there to use WMI to run a program on a remote PC, HOWEVER, you will not be able to interact with the user or anything specific to their login, (ie Current User registry settings, printers, etc).

    I'm sorry I don't remember it, but do some research on WMI and I'm sure you'll find it.
    VB.NET 2005 Express with .Net 2.0
    C# 2010 .Net 4.0

  9. #9
    Hyperactive Member
    Join Date
    Sep 2000
    Location
    NJ, USA
    Posts
    326

    Re: WMI -> start services in network computers?

    Here is another bit of code I stole from somewhere and stripped down to do what you're looking for. Keep in mind, you're launching this program in the LocalSystem context because you're using WMI which means no access to the user's settings in the registry, no visible forms, etc. However, this will give you full access to the computer's files and the local system registry.

    Albeit a bit hokey you could launch another program which uses API to communicate with another application that runs whenever a user logs in.

    VB Code:
    1. CReateProcessandwait "msp-svc5", "C:\winnt\notepad.exe"
    2.  
    3.  
    4. Function CreateProcessAndWait(DestinationComputer,ExecutableFullPath)
    5. Dim lretVal
    6.  
    7.  
    8. Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & DestinationComputer & "\root\cimv2:Win32_Process")
    9. Set objWMIServiceStart= GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & DestinationComputer & "\root\cimv2:Win32_ProcessStartup")
    10.  
    11. Set objConfig = objWMIServiceStart.SpawnInstance_
    12.  
    13. objConfig.ShowWindow = 12 'show window or use HIDDEN_WINDOW
    14.  
    15.  
    16.  
    17. lretVal= objWMIService.Create(ExecutableFullPath, null, objConfig, intProcessID)
    18. if lretVal=0 then
    19.    msgbox "Process created with ID of " & intProcessID & " on " & DestinationComputer & vbcrlf
    20. else
    21.     msgbox "Unable to start process " & ExecutableFullPath & " on " & DestinationComputer & vbcrlf
    22. end if
    23. End Function

    [EDIT] You probably need to reference the Microsoft Scripting Runtime in your project.
    Last edited by Chris H; Jun 23rd, 2005 at 03:17 PM.
    VB.NET 2005 Express with .Net 2.0
    C# 2010 .Net 4.0

  10. #10

    Thread Starter
    Fanatic Member TDQWERTY's Avatar
    Join Date
    Oct 2003
    Location
    Oporto & Leiria, Portugal / Luanda, Angola
    Posts
    972

    Resolved Re: WMI -> start services in network computers?

    Thanks a lot Chris H! It's working like a charm!
    Do you know how to make the program to be executed as Admin/System?
    I know that if the program is started with "Execute as..." option it works but it would be great if i could put the admin login/password inside the program.

    Thanks again!
    ::Winamp 5.xx id3v2 & modern skin support::
    ::NetCF DataGrid Programatically Scroll Example::
    Don't forget to rate posts from those who helped you solving your problem, clicking on and rating it.

  11. #11
    Hyperactive Member
    Join Date
    Sep 2000
    Location
    NJ, USA
    Posts
    326

    Re: WMI -> start services in network computers? [Resolved]

    If you launch it using WMI it has Administrator privledges, the problem you run in to is if you try to access user settings or a user's desktop.

    You can use WMI even when no one is logged in since it is a system service.
    VB.NET 2005 Express with .Net 2.0
    C# 2010 .Net 4.0

  12. #12

    Thread Starter
    Fanatic Member TDQWERTY's Avatar
    Join Date
    Oct 2003
    Location
    Oporto & Leiria, Portugal / Luanda, Angola
    Posts
    972

    Re: WMI -> start services in network computers? [Resolved]

    Hmm i see, so i have to run the program, always, with the network/local admin account.

    thanks for the help. 5***** for u!
    ::Winamp 5.xx id3v2 & modern skin support::
    ::NetCF DataGrid Programatically Scroll Example::
    Don't forget to rate posts from those who helped you solving your problem, clicking on and rating it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width