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 :afrog:
Thanks
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 :afrog:
Thanks
dobackup.exe is a service?
also tell me what operating system your network computers have?
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)
Re: WMI -> start services in network computers?
Doesn't anyone have an ideia?
frmMain.frm (5.8 KB, 5 views) and no answers??
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.
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:
Private Sub StartService(ServiceName As String, strComputer as String)
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colListOfServices = objWMIService.ExecQuery("Select * from Win32_Service Where Name ='" & ServiceName & "'")
For Each objService In colListOfServices
objService.StartService
Next
End Sub
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
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.
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:
CReateProcessandwait "msp-svc5", "C:\winnt\notepad.exe"
Function CreateProcessAndWait(DestinationComputer,ExecutableFullPath)
Dim lretVal
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & DestinationComputer & "\root\cimv2:Win32_Process")
Set objWMIServiceStart= GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & DestinationComputer & "\root\cimv2:Win32_ProcessStartup")
Set objConfig = objWMIServiceStart.SpawnInstance_
objConfig.ShowWindow = 12 'show window or use HIDDEN_WINDOW
lretVal= objWMIService.Create(ExecutableFullPath, null, objConfig, intProcessID)
if lretVal=0 then
msgbox "Process created with ID of " & intProcessID & " on " & DestinationComputer & vbcrlf
else
msgbox "Unable to start process " & ExecutableFullPath & " on " & DestinationComputer & vbcrlf
end if
End Function
[EDIT] You probably need to reference the Microsoft Scripting Runtime in your project.
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!
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.
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!