• Announcements

Sign in to follow this  
Followers 0

Admin Tool

137 posts in this topic

Posted (edited) · Report post

This started as a way to learn more about wmi and ldap

Removed any info pertaining to my work-place, so info in ini will need to be changed

The ldap method worked, but was to slow amongst other things, so used net view to

get the browser info for systems online on the domain, haven't had time to figure out

a better way (maybe active directory)

link to external free tools used Sysinternals PSTools

Currently it (requires beta)

gets the list of pc's online on domain and populates a listview

populates 6 listviews

Tab 1:

Software that can be removed via msiexec command silently and remotely (right click,

select uninstall) (list populated using wmi)

Tab 2:

List of PID, process names, and paths, and (right click, select kill "uses wmi") remote

process (list populated using wmi)

Tab 3:

Services (list populated using wmi) (right click, select stop/start/pause/restart/delete service

using wmi)

Tab 4:

Some system info in editbox

List of Logged on users (using psloggedon from sysinternals)

Drive information (Drive Letter, type, size, free space, format type i.e ntfs using wmi), right

clicking on drive can explore remote drive (configured in ini to use iexplorer))

Tab 5:

List of all applications installed on the remote machine (using psinfo from sysinternals)

Plan on adding more, for example export of data.

Comments/suggestions/improvements are most welcome.

CODE

Edit: v1.9.1.4

Fixed up the IP Range Filtering Function (back-spacing, tabs, length)

Also fixed so that Filter is updated imediatly so that refresh can be done right away.

Edit: v1.9.1.3

Added IP Range Filtering

Edit: v1.9.1.2

Added a couple of context menu items, look for them in the machine list

Some code optimization, also took some of the code out of the main loop and put into functions

Edit: v1.9.1.1

Ping time out configurable

Checks to see what $Domain is, if it is equal to "your-domain" then

the domain configscreen will pop up (doesn't populate machine list

if it is equal to "your-domain").

Must change to your domains name.

Context menu for populate software instead of $GUI_EVENT_PRIMARYDOWN

Selecting machine through search does not automatically populate pc info anymore

(might have populate for one not wanted)

If machine filter changes, no longer automatically re-populates list, will have to

selectRefresh Machine List from context menu

Edit: v1.9.1.0

User now has choice of retrieving list of pcs by either ldap or net view, select config menu

some internal changes.

Edit: v1.9:

I replaced the net view with the retrievial of the pcs with ldap

Added the ip address to the machine list

All pcs will have the offline icon at this time, select one if it is pingable it changes the

icon to online

Edit:

corrected error with context menu on services

Edit: v1.8

added Change Start Mode to Services (Boot,System,Automatic,Manual,Disabled)

Edit: v1.7

now using all wmi for process and service tabs, no longer need pskill and psservice

from sysinternals, Changed from label to editbox read-only for system info on Tab 4

Edit: v1.6

since there seems to be some interest (47 downloads of 1st version) I decided to put

the latest up, added all the files need from sysinternals into the zip file.

Enjoy,

Gary

Edited by Jon

Share this post


Link to post
Share on other sites



Posted · Report post

I did something like this a year ago, I haven't updated it in a while, although someone asked me to post the scripts again because the file manager no longer had them. It was pretty similar to this.

Domain PC Info

Share this post


Link to post
Share on other sites

Posted · Report post

Please post complete topic..

Or GUIListview.au3 file

Share this post


Link to post
Share on other sites

Posted · Report post

Please post complete topic..

Or GUIListview.au3 file

Beta

Share this post


Link to post
Share on other sites

Posted · Report post

This is pretty lavish, Gary. Nice work!

Comments/suggestions/improvements are most welcome.

Gary

StdoutRead makes everything better. ;) I don't know if the Sysinternals tools use STDERR in the case of a problem (surely they do) but you could read the native error message with StderrRead if that were the case...

Share this post


Link to post
Share on other sites

Posted (edited) · Report post

This is pretty lavish, Gary. Nice work!

StdoutRead makes everything better. :P I don't know if the Sysinternals tools use STDERR in the case of a problem (surely they do) but you could read the native error message with StderrRead if that were the case...

Thanks ;)

I forced one of the tools to error, but stderr didn't get any info

Updated AdminTool, see first post

Gary

Edited by gafrost

Share this post


Link to post
Share on other sites

Posted · Report post

v1.7 now using all wmi for process and service tabs, no longer need pskill and psservice from sysinternals

see 1st post

Enjoy,

Gary

Share this post


Link to post
Share on other sites

Posted · Report post

v1.7 now using all wmi for process and service tabs, no longer need pskill and psservice from sysinternals

see 1st post

Enjoy,

Gary

Is there an easy way to get it to work on a workgroup instead of a domain. All my customers use peer to peer networks as they are not large enough to require servers.

Share this post


Link to post
Share on other sites

Posted · Report post

I tried it at home (no domain), just MyHome workgroup, and it worked

Share this post


Link to post
Share on other sites

Posted (edited) · Report post

I tried it at home (no domain), just MyHome workgroup, and it worked

I must be doing something wrong, I will try again.

Edit

I have tried it again and it sees all three computers. It comes up with an error on one computer (see attached). It also cant ping the computer it is running on.

Edited by BigDod

Share this post


Link to post
Share on other sites

Posted · Report post

I was wrong, thought i had to setup this network up in workgroup, but it's a domain thru my router.

Share this post


Link to post
Share on other sites

Posted · Report post

v1.8 added Change Start Mode to Services (Boot,System,Automatic,Manual,Disabled)

Adding as I learn/figure things out.

see 1st post

Share this post


Link to post
Share on other sites

Posted · Report post

First

Looks real nice gafrost.... good job

Second

it did not work for me

Win Xp SP2

Shared network through router

I use "net send" and that works

Third

I tried this and it worked inside your script ... but still no info ???

I added these to your existing script because I did not know the answer to "your-domain"

Global Const $wbemFlagForwardOnly = 0x20
Dim $set_Domain, $s_Domain; ************ added this line
opt('MustDeclareVars', 1)

*************************** and *********************************

If $s_Domain = "your-domain" Then;*************** added from here
		Set_Domain()
		Local $domain_input = GUICtrlCreateCombo("your-domain", 20, 40, 250, 20)
		GUICtrlSetState(-1,$GUI_FOCUS) 
		GUICtrlSetData(-1,$set_Domain)
	Else	
		Local $domain_input = GUICtrlCreateInput($s_Domain, 20, 40, 250, 20)
	EndIf;**************to here
	$Save = GUICtrlCreateButton("Save", 20, 100, 120, 25)
	$CLOSE = GUICtrlCreateButton("Close", 160, 100, 120, 25)
	GUISetState()


************************* and ***********************************

; **************************** all of this function below

Func Set_Domain()

	Local $file, $line, $result, $blankpos,  $len
;delete last listing
Filedelete(@TempDir & "\b.tmp")

; make sure net send is running
RunWait("net start messenger","",@SW_HIDE)

;gets the computer list and a few other things
RunWait(@ComSpec & ' /c net view > ' & @TempDir & '\a.tmp',"", @SW_HIDE)
Sleep(300)
;open the file for working
$file = FileOpen(@TempDir & "\a.tmp", 0)

; Check if file opened for reading OK
If $file = -1 Then
	MsgBox(0, "QT - Error", "Unable to open file.")
	Exit
EndIf

;Creates new file in which the result will be written
FileOpen(@TempDir & "\b.tmp", 1)

; Read in lines of text until the EOF is reached in file a.tmp
While 1
	$line = FileReadLine($file)
	If @error = -1 Then ExitLoop
  ;find the string "\\"
	$result = StringInStr($line,"\\")
	  if $result = 1 Then 
	 ;find next blank
	  $blankpos = StringInStr($line," ")
	;Find length of line
	  $len = StringLen($line)
	;calculate from what position to Trim string to the right
	  $len = $len - $blankpos
	;Trim all characters after the computer name
	  $line = StringTrimRight($line, $len)
	;Trim the //
	  $line = StringTrimLeft($line,2)
	;Write line to file, adding "|"
	  FileWrite(@TempDir & "\b.tmp", $line & "|")
	  EndIf

Wend

FileClose($file)
FileDelete(@TempDir & "\a.tmp")
$set_Domain = FileReadline(@TempDir & "\b.tmp", 1)


EndFunc

it worked... gave me choices and no errors... i saved it... closed it....

and again no info????

8)

Share this post


Link to post
Share on other sites

Posted (edited) · Report post

First

Looks real nice gafrost.... good job

Second

it did not work for me

Win Xp SP2

Shared network through router

I use "net send" and that works

Third

I tried this and it worked inside your script ... but still no info ???

I added these to your existing script because I did not know the answer to "your-domain"

Global Const $wbemFlagForwardOnly = 0x20
Dim $set_Domain, $s_Domain; ************ added this line
opt('MustDeclareVars', 1)

*************************** and *********************************

If $s_Domain = "your-domain" Then;*************** added from here
        Set_Domain()
        Local $domain_input = GUICtrlCreateCombo("your-domain", 20, 40, 250, 20)
        GUICtrlSetState(-1,$GUI_FOCUS) 
        GUICtrlSetData(-1,$set_Domain)
    Else    
        Local $domain_input = GUICtrlCreateInput($s_Domain, 20, 40, 250, 20)
    EndIf;**************to here
    $Save = GUICtrlCreateButton("Save", 20, 100, 120, 25)
    $CLOSE = GUICtrlCreateButton("Close", 160, 100, 120, 25)
    GUISetState()


************************* and ***********************************

; **************************** all of this function below

Func Set_Domain()

    Local $file, $line, $result, $blankpos,  $len
;delete last listing
Filedelete(@TempDir & "\b.tmp")

; make sure net send is running
RunWait("net start messenger","",@SW_HIDE)

;gets the computer list and a few other things
RunWait(@ComSpec & ' /c net view > ' & @TempDir & '\a.tmp',"", @SW_HIDE)
Sleep(300)
;open the file for working
$file = FileOpen(@TempDir & "\a.tmp", 0)

; Check if file opened for reading OK
If $file = -1 Then
    MsgBox(0, "QT - Error", "Unable to open file.")
    Exit
EndIf

;Creates new file in which the result will be written
FileOpen(@TempDir & "\b.tmp", 1)

; Read in lines of text until the EOF is reached in file a.tmp
While 1
    $line = FileReadLine($file)
    If @error = -1 Then ExitLoop
;find the string "\\"
    $result = StringInStr($line,"\\")
      if $result = 1 Then 
    ;find next blank
      $blankpos = StringInStr($line," ")
  ;Find length of line
      $len = StringLen($line)
  ;calculate from what position to Trim string to the right
      $len = $len - $blankpos
  ;Trim all characters after the computer name
      $line = StringTrimRight($line, $len)
  ;Trim the //
      $line = StringTrimLeft($line,2)
  ;Write line to file, adding "|"
      FileWrite(@TempDir & "\b.tmp", $line & "|")
      EndIf

Wend

FileClose($file)
FileDelete(@TempDir & "\a.tmp")
$set_Domain = FileReadline(@TempDir & "\b.tmp", 1)


EndFunc

it worked... gave me choices and no errors... i saved it... closed it....

and again no info????

8)

no need to add to script, i just put a dummy domain name in the ini, either edit the ini and change to name of your domain or load program, because domain doesn't exist will take a few moments to finish loading

then select config, domain, then change it to your domain name

This has only been tested on WinXP Pro SP2 on a domain.

Gary

Edited by gafrost

Share this post


Link to post
Share on other sites

Posted · Report post

then... it wont work i guess

Win Xp Home Sp2

Shared access ( hand under hard-drives)

net-send working

anything i can try

?

8)

Share this post


Link to post
Share on other sites

Posted · Report post

try commenting out the

If $ping_time Then

and corresponding endif's

ping might be the problem, had that problem on one of my machines here at home, turned off the software firewall for a minute and the ping worked.

Share this post


Link to post
Share on other sites

Posted (edited) · Report post

i did this...no errors, but no info

Local $ping_time = Ping($s_Machine)

;If $ping_time Then

GUICtrlSetData($Status, $s_Machine & " roundtrip was:" & $ping_time & " ms")

_GUICtrlListViewDeleteAllItems ($lv_software)

_GUICtrlListViewDeleteAllItems ($lv_allsoftware)

_GUICtrlListViewDeleteAllItems ($lv_pid)

_GUICtrlListViewDeleteAllItems ($lv_services)

_GUICtrlListViewDeleteAllItems ($lv_drives)

_GUICtrlListViewDeleteAllItems ($lv_loggedin)

GUICtrlSetData($Status, "Getting Role: " & $s_Machine)

GUICtrlSetImage(_GUICtrlListViewGetItemText ($lv_pcs, -1, 1), @ScriptDir & "\OnLine.ico")

GUISetState(@SW_LOCK)

_GetRole ($s_Machine, $Status)

GUISetState(@SW_UNLOCK)

GUISetState(@SW_LOCK)

_RetrieveSoftware ($lv_software, $s_Machine)

_RetrieveAllSoftware ($lv_allsoftware, $s_Machine)

_RetieveOSInfo ($eb_system, $s_Machine)

_RetrieveProcessList ($lv_pid, $s_Machine)

_RetrieveServices ($lv_services, $s_Machine)

_RetrieveLoggedInUsers ($lv_loggedin, $s_Machine)

_DriveInfo ($lv_drives, $s_Machine)

GUISetState(@SW_UNLOCK)

; Else

;GUICtrlSetData($Status, $s_Machine & " is Offline")

;GUICtrlSetImage(_GUICtrlListViewGetItemText ($lv_pcs, -1, 1), @ScriptDir & "\OffLine.ico")

; EndIf

GUISetCursor($Cursor_ARROW, 1)

EndIf

[code=auto:0]

8)

Edited by Valuater

Share this post


Link to post
Share on other sites

Posted (edited) · Report post

this worked... no error

$var = Ping("BLINGBLING",250)
If $var Then; also possible:  If @error = 0 Then ...
    Msgbox(0,"Status","Online, roundtrip was:" & $var)
Else
    Msgbox(0,"Status","An error occured with number: " & @error)
EndIf

8)

EDIT

it also worked on my other two computers from BLINGBLING running the script

Edited by Valuater

Share this post


Link to post
Share on other sites

Posted · Report post

Are you getting a list of pcs in the left list?

if not, then try the following replacing MyHome with your domain name

net view /domain:MyHome

if so then try the following replacing GAF with your machine name:

Global Const $wbemFlagReturnImmediately = 0x10
Global Const $wbemFlagForwardOnly = 0x20
$s_Machine = "GAF"

$objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $s_Machine & "\root\cimv2")
If @error Then
 MsgBox(16, "Test wmi", "ObjGet Error: winmgmts")
 Exit
EndIf
$colSoftware = $objWMIService.ExecQuery ("Select * from Win32_Product", "WQL", _
  $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
If @error Then
 MsgBox(16, "Test wmi", "ExecQuery Error: Select * from Win32_Product")
 Exit
EndIf
For $objSoftware In $colSoftware
 If $objSoftware.Caption <> "0" Then
  MsgBox(0, "Test wmi", "Caption: " & $objSoftware.Caption & @LF & _
	"Version: " & $objSoftware.Version & @LF & _
	"IdentifyingNumber: " & $objSoftware.IdentifyingNumber)
 EndIf
Next

Share this post


Link to post
Share on other sites

Posted (edited) · Report post

OK... we got some where

i changed this... net view /domain:MyHome

to my local network name

And **** Admin Tools **** worked

i got the three comp pics on the left and it gave me the info for BLINGBLING

... but it says "Unable to retrieve Role" at the bottom of the screen

****** then

i tried to get info on another comuter and it keep locking up with error messages... this is the first one

then the ProcessList error

then i had to hard stop it with ctrl-alt-del

but thats progress... right??

8)

.

ALSO

Your code above worked with BLINGBLING

Edited by Valuater

Share this post


Link to post
Share on other sites

Posted · Report post

the error your getting is from the code above, i just took the function and trimmed it down to just what was needed to test the wmi.

Share this post


Link to post
Share on other sites

Posted (edited) · Report post

the error is not from the code above...

it is from AdimTools

ok...

maybe you mean the error i am getting is from the code above that was inside Admin tools and you trimmed that code down for your example

if so... the example above errored the same way when i placed the other computer names in it

8)

Edited by Valuater

Share this post


Link to post
Share on other sites

Posted · Report post

Now i am using Beat... but still not working.

Error is

Line 236 (file "c:\AdminTool.au3):

Case $GUI_EVENT_CLOSE, $exititem

Error: "Case" Statement with no matching "Select" Statement.

Please help I want to run & use this tool. I am using windows 2000.

Share this post


Link to post
Share on other sites

Posted · Report post

Working... Showing All PCs.

But getting same error as posted by VALUATER.

Second thing is don't want to scan Domain. Because it very very Big.. I am concerned only for my Subnet.

I want to scan range of IP ... is it possible???

Share this post


Link to post
Share on other sites

Posted · Report post

Thanks ;)

I forced one of the tools to error, but stderr didn't get any info

Updated AdminTool, see first post

Gary

That's kind of a disappoinment, but I guess you can test for the string "Error" in the output in any case...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0