Jump to content

Admin Tool


GaryFrost
 Share

Recommended Posts

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

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

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...

Yes yes yes, there it was. Youth must go, ah yes. But youth is only being in a way like it might be an animal. No, it is not just being an animal so much as being like one of these malenky toys you viddy being sold in the streets, like little chellovecks made out of tin and with a spring inside and then a winding handle on the outside and you wind it up grrr grrr grrr and off it itties, like walking, O my brothers. But it itties in a straight line and bangs straight into things bang bang and it cannot help what it is doing. Being young is like being like one of these malenky machines.

Link to comment
Share on other sites

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

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

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.


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

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


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

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)

NEWHeader1.png

Link to comment
Share on other sites

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

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

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.

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

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
    
    

            
        

        

        
            

    
        

        
            
        
    

        
    

    

    




    Link to comment
    
        
    
    
    

    
    Share on other sites
    

    
        
            

    

        
            

    

        
            

    

        
            

    

        
    


    
    More sharing options...

    


    

                    
                    
                    
                

                    

                    
                    





    

    

    
        
            
                


    
        
    

                
                
                    
                        

                    
                
            
        
        
            
                


Valuater
            
            
                Posted 
                
            
        
    
    
        


Valuater
            
        
        
            
                
                    


    
        
    

                    
                    
                        

                    
                
            
            
                MVPs
                
                    
                
            
            
                
                    
                        
                            
                                
                            
                                 11.1k
                            
                                
                            
                        
                        
                            
                                
                                    
                                        
                                        7
                                
                                    
                                
                            
                        
                    
                
            
            
                

            
        
    
    
        



    
        
            
                
                    
                    
                    
                    
                    
                
            
            
                
                    
                    
                        
                        
                            Share
                        
                        
                        
                        
                        
                            
                                
                            
                            
                            
                            
                            
                            
                        
                    
                
                
            
        

        
            Posted 
            
            
                
                    (edited)
                
                
            
        
    

    

    

    
        
        
            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

NEWHeader1.png

Link to comment
Share on other sites

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

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

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

NEWHeader1.png

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...