#137891 - 2005-04-19 08:38 PM
Re: Need help with EnumProcess
|
Broxoth
Getting the hang of it
Registered: 2005-04-07
Posts: 78
|
Two things. 1) Once tested and I know where the WMI problem lies, how would I go about repairing it? I'd be more than happy to read up on doing such if someone could tell me where to find that info. 2) The whole idea behind the NET SEND was discussed earlier in the thread. The original code had a line: Code:
$=SendMessage(@wksta,$computer +' is running '+ $proc)
I was looking to put together some pseudo-front end to the script that would just put the info I was after into a message box plainly with no more than a couple of lines. As it stands, what I'd like to see, is a messagebox that states that either, Yes, the $computer was pinged and that this $process was found to be running....or, No, this $computer was not pinged, we're moving on to the next $computer. That's the general idea. Now, as much as I appreciate the enormous amount of help that I've received, (honestly, I have never seen so many people be so generous with their help!) I always intended on putting this thing together myself. Just saying that to make it clear that it's not like I'm expecting anyone else to do my dirty work. Thank you, everyone!
|
Top
|
|
|
|
#137892 - 2005-04-19 08:50 PM
Re: Need help with EnumProcess
|
NTDOC
Administrator
Registered: 2000-07-28
Posts: 11624
Loc: CA
|
Reinstalling WMI If you experience behavior when using WMI, such as application errors or scripts that used to work are no longer working, you may have a corrupted WMI repository. To fix a corrupted WMI repository, you have to reinstall WMI.
Windows Management Instrumentation - Repair
As for the NET SEND I'm still not sure why you would send that to a user. What purpose does it serve either to you or the user? It is not logged, when the user clicks okay the message is now gone, etc..
We can setup a MessageBox command that would alert YOU as the Administrator about a system if you want which I'm guessing is more of what you're really wanting.
|
Top
|
|
|
|
#137894 - 2005-04-19 09:51 PM
Re: Need help with EnumProcess
|
Kdyer
KiX Supporter
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
Couple of things to ponder..
Does the following directory exist? %windir%\system32\wbem
or.. Code:
$check=GetObject("winmgmts:{impersonationLevel=impersonate}!\\"+$scomputer+'\root\cimv2') IF @error<>0 ?'WMI Appears to be having trouble' ENDIF
HTH,
Kent
|
Top
|
|
|
|
#137895 - 2005-04-19 10:07 PM
Re: Need help with EnumProcess
|
Broxoth
Getting the hang of it
Registered: 2005-04-07
Posts: 78
|
Good thought, kdyer. I'll consider adding that. Here's the final code with the MessageBox implemented: Code:
Break On Dim $SO,$Pause $SO=SetOption('Explicit','On') $SO=SetOption('NoVarsInStrings','On') $SO=SetOption('WrapAtEOL','On') Dim $ArrayComputers, $sComputer, $Process, $Processes, $List, $Item $ArrayComputers = 'OFF-FRONTDESK','OFF-TSINGERY','OFF-JHUFF','OFF-SGONZALEZ','OFF-HOYT','OFF-SBERGER','OFF-RLOCKWOOD' $Processes = 'School.exe','SMinder.exe','SMAdmin.exe','SMReport.exe','SMBill.exe','Admission.exe' For Each $sComputer in $ArrayComputers If $sComputer If Ping($sComputer) Goto "EnumDisplay" :EnumDisplay For Each $Process in $Processes If $Process $List = EnumProcess($Process,,$sComputer) If $List MessageBox($sComputer + " was pinged and is running " + $Process + " with a PID of" + $List + ".","SMChecks",0) EndIf EndIf Next EndIf EndIf Next
Kind of nasty with the goto statement but it gets the job done.
|
Top
|
|
|
|
#137896 - 2005-04-19 11:19 PM
Re: Need help with EnumProcess
|
NTDOC
Administrator
Registered: 2000-07-28
Posts: 11624
Loc: CA
|
Well if you really want a GOOD LOOKING GUI then take a look at implementing this with KiXforms written by our very own Admin/Moderator Shawn Tassie.
KiXforms Home Page
|
Top
|
|
|
|
#137898 - 2005-04-20 02:24 AM
Re: Need help with EnumProcess
|
NTDOC
Administrator
Registered: 2000-07-28
Posts: 11624
Loc: CA
|
KiXforms is completely FREE to use. Not sure if it was included as part of the ASE install, but I think you're correct that it does install it.
Just need to visit the KiXforms site and start learning how to use it.
|
Top
|
|
|
|
#137908 - 2005-04-21 12:22 AM
Re: Need help with EnumProcess
|
Broxoth
Getting the hang of it
Registered: 2005-04-07
Posts: 78
|
As a board moderator elsewhere, I fully understand. Wish I'd asked before I posted. Would've made more sense to keep the conversation rolling on this thread. Oh well, here's the link.
|
Top
|
|
|
|
#137909 - 2005-04-21 01:45 AM
Re: Need help with EnumProcess
|
Shawn
Administrator
Registered: 1999-08-13
Posts: 8611
|
Here is some thoughts ... might want to use the ListBox instead of Textboxes - idk - its your call, here is some code based on Listboxes though ...
Code:
Break On ;SetConsole("hide")
$System = CreateObject("Kixtart.System")
;KD START
$Form = $System.Form() $Form.BackColor = 224,223,227 $Form.Height = 477 $Form.Left = 209 $Form.MaximizeBox = "False" $Form.Text = "SM Process Checker" $Form.Top = 89 $Form.Width = 532 $UI_COMPNAMES = $Form.Controls.ListBox() $UI_COMPNAMES.Height = 150 $UI_COMPNAMES.Left = 15 $UI_COMPNAMES.Text = "" $UI_COMPNAMES.Top = 45 $UI_COMPNAMES.Width = 150 $UI_COMPNAMES.Sorted = 1
$COMPNAME_LABEL = $Form.Controls.Label() $COMPNAME_LABEL.BackColor = 224,223,227 $COMPNAME_LABEL.FontBold = "True" $COMPNAME_LABEL.FontUnderline = "True" $COMPNAME_LABEL.Height = 20 $COMPNAME_LABEL.Left = 15 $COMPNAME_LABEL.Text = "Computer Name(s)" $COMPNAME_LABEL.Top = 30 $COMPNAME_LABEL.Width = 114
$PROCGROUP = $Form.Controls.GroupBox() $PROCGROUP.BackColor = 224,223,227 $PROCGROUP.Height = 141 $PROCGROUP.Left = 15 $PROCGROUP.Text = "Processes to Search For:" $PROCGROUP.Top = 202 $PROCGROUP.Width = 268
$UI_SCHOOL = $PROCGROUP.Controls.CheckBox() $UI_SCHOOL.BackColor = 224,223,227 $UI_SCHOOL.CheckAlign = 16 $UI_SCHOOL.Height = 24 $UI_SCHOOL.Left = 15 $UI_SCHOOL.Text = "School.exe" $UI_SCHOOL.Top = 15 $UI_SCHOOL.Width = 104
$UI_SMINDER = $PROCGROUP.Controls.CheckBox() $UI_SMINDER.BackColor = 224,223,227 $UI_SMINDER.CheckAlign = 16 $UI_SMINDER.Height = 24 $UI_SMINDER.Left = 15 $UI_SMINDER.Text = "SMinder.exe" $UI_SMINDER.Top = 45 $UI_SMINDER.Width = 104
$UI_SMADMIN = $PROCGROUP.Controls.CheckBox() $UI_SMADMIN.BackColor = 224,223,227 $UI_SMADMIN.CheckAlign = 16 $UI_SMADMIN.Height = 24 $UI_SMADMIN.Left = 15 $UI_SMADMIN.Text = "SMAdmin.exe" $UI_SMADMIN.Top = 75 $UI_SMADMIN.Width = 104
$UI_SMREPORT = $PROCGROUP.Controls.CheckBox() $UI_SMREPORT.BackColor = 224,223,227 $UI_SMREPORT.CheckAlign = 16 $UI_SMREPORT.Height = 24 $UI_SMREPORT.Left = 135 $UI_SMREPORT.Text = "SMReport.exe" $UI_SMREPORT.Top = 15 $UI_SMREPORT.Width = 104
$UI_SMBILL = $PROCGROUP.Controls.CheckBox() $UI_SMBILL.BackColor = 224,223,227 $UI_SMBILL.CheckAlign = 16 $UI_SMBILL.Height = 24 $UI_SMBILL.Left = 135 $UI_SMBILL.Text = "SMBill.exe" $UI_SMBILL.Top = 45 $UI_SMBILL.Width = 104
$UI_ADMISSION = $PROCGROUP.Controls.CheckBox() $UI_ADMISSION.BackColor = 224,223,227 $UI_ADMISSION.CheckAlign = 16 $UI_ADMISSION.Height = 24 $UI_ADMISSION.Left = 135 $UI_ADMISSION.Text = "Admission.exe" $UI_ADMISSION.Top = 75 $UI_ADMISSION.Width = 104
$UI_ALLPROCS = $PROCGROUP.Controls.CheckBox() $UI_ALLPROCS.BackColor = 224,223,227 $UI_ALLPROCS.CheckAlign = 16 $UI_ALLPROCS.FontItalic = "True" $UI_ALLPROCS.Height = 21 $UI_ALLPROCS.Left = 75 $UI_ALLPROCS.Text = "Search for ALL" $UI_ALLPROCS.Top = 105 $UI_ALLPROCS.Width = 105
$COMPLIST_LABEL = $Form.Controls.Label() $COMPLIST_LABEL.BackColor = 224,223,227 $COMPLIST_LABEL.FontBold = "True" $COMPLIST_LABEL.FontUnderline = "True" $COMPLIST_LABEL.Height = 17 $COMPLIST_LABEL.Left = 270 $COMPLIST_LABEL.Text = "Search these computers:" $COMPLIST_LABEL.Top = 30 $COMPLIST_LABEL.Width = 144
$UI_MOVETOLIST = $Form.Controls.Button() $UI_MOVETOLIST.FontBold = "True" $UI_MOVETOLIST.Height = 28 $UI_MOVETOLIST.Left = 205 $UI_MOVETOLIST.Text = ">>" $UI_MOVETOLIST.Top = 60 $UI_MOVETOLIST.Width = 30 $UI_MOVETOLIST.OnClick = "MoveToListClick()"
$UI_MOVEFROMLIST = $Form.Controls.Button() $UI_MOVEFROMLIST.FontBold = "True" $UI_MOVEFROMLIST.Height = 28 $UI_MOVEFROMLIST.Left = 205 $UI_MOVEFROMLIST.Text = "<<" $UI_MOVEFROMLIST.Top = 120 $UI_MOVEFROMLIST.Width = 30 $UI_MOVEFROMLIST.OnClick = "MoveFromListClick()"
$UI_SEARCHBUTTON = $Form.Controls.Button() $UI_SEARCHBUTTON.FontBold = "True" $UI_SEARCHBUTTON.Height = 23 $UI_SEARCHBUTTON.Left = 315 $UI_SEARCHBUTTON.Text = "Search" $UI_SEARCHBUTTON.Top = 210 $UI_SEARCHBUTTON.Width = 75
$UI_CLEARLISTBUTTON = $Form.Controls.Button() $UI_CLEARLISTBUTTON.Height = 23 $UI_CLEARLISTBUTTON.Left = 180 $UI_CLEARLISTBUTTON.Text = "Clear list" $UI_CLEARLISTBUTTON.Top = 165 $UI_CLEARLISTBUTTON.Width = 75 $UI_CLEARLISTBUTTON.OnClick = "ClearListClick()"
$UI_CLEARALLBUTTON = $Form.Controls.Button() $UI_CLEARALLBUTTON.Height = 23 $UI_CLEARALLBUTTON.Left = 315 $UI_CLEARALLBUTTON.Text = "Clear ALL" $UI_CLEARALLBUTTON.Top = 255 $UI_CLEARALLBUTTON.Width = 75
$UI_CLOSEBUTTON = $Form.Controls.Button() $UI_CLOSEBUTTON.Height = 23 $UI_CLOSEBUTTON.Left = 315 $UI_CLOSEBUTTON.Text = "Close" $UI_CLOSEBUTTON.Top = 300 $UI_CLOSEBUTTON.Width = 75
$UI_COMPLIST = $Form.Controls.ListBox() $UI_COMPLIST.Height = 150 $UI_COMPLIST.Left = 270 $UI_COMPLIST.ReadOnly = "True" $UI_COMPLIST.Top = 45 $UI_COMPLIST.Width = 150 $UI_COMPLIST.Sorted = 1
;KD END
For $i = 0 To 100 $UI_COMPNAMES.AddItem("HOST#$i") Next
$Form.Show While $Form.Visible $=Execute($Form.DoEvents()) Loop Exit 1
Function MoveToListClick()
If $UI_COMPNAMES.ListIndex <> -1 $UI_COMPLIST.AddItem($UI_COMPNAMES.Text) $UI_COMPNAMES.RemoveItem($UI_COMPNAMES.ListIndex) Endif
EndFunction
Function MoveFromListClick()
If $UI_COMPLIST.ListIndex <> -1 $UI_COMPNAMES.AddItem($UI_COMPLIST.Text) $UI_COMPLIST.RemoveItem($UI_COMPLIST.ListIndex) Endif
EndFunction
Function ClearListClick()
$UI_COMPLIST.Clear
EndFunction
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 718 anonymous users online.
|
|
|