Sign in to follow this  
Followers 0
gcue

process INI from combo box

14 posts in this topic

#1 ·  Posted (edited)

i created a combo box and am trying to process the selected PC through APING()

Edited by gcue

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi, are you sure the ini is in the script directory, does the ini have and [ASSETS] section to read?

Maybe specify the full path to the ini and also add a small error check to see the IniReadSection() is returning without error.

#include <GuiConstants.au3>

Global $Ini = @ScriptDir & "\assets.ini"

$Gui = GUICreate("", 350, 100)
$combo = GUICtrlCreateCombo("Select Asset...", 50, 34, 200, 20, $CBS_DROPDOWNLIST); create combobox and set first item
GUICtrlSetData(-1, LoadCombo(), "Select Asset...")

$filemenu = GUICtrlCreateMenu("&File")
$fileopenitem = GUICtrlCreateMenuItem("Edit Device List", $filemenu)
$fileexititem = GUICtrlCreateMenuItem("Exit", $filemenu)

$helpmenu = GUICtrlCreateMenu ("&Help")
$helpchangeitem = GUICtrlCreateMenuitem ("Change Log",$helpmenu)
$helpaboutitem = GUICtrlCreateMenuitem ("About",$helpmenu)

$btn = GUICtrlCreateButton ("OK", 255,34,40,25)
GUICtrlSetState(-1, $GUI_FOCUS)

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
          Exit
        case $btn
;~             APing()
        case $fileopenitem
;~             EditINI()
        case $fileexititem
;~             Xbutton()
        case $helpchangeitem
;~             Change()
        case $helpaboutitem
;~             About()
    EndSwitch
WEnd

Func LoadCombo()
    Local $arr = IniReadSection($Ini, "ASSETS"), $sAssets
    If Not @error Then
        For $i = 1 To $arr[0][0]
            $sAssets &= $arr[$i][0] & "|"
        Next
        Return StringTrimRight($sAssets, 1)
    EndIf
    Return "No assets loaded"
EndFunc

The ini I used with the above code

[ASSETS]
ANDS_ETS=d0090774
ANDS_ESERV=d0090775
DLG_ETS=d0049852
DLG_ESERV=d0075934
JASB_ETS=d0058259

Cheers

Edited by smashly

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

yep the assets.ini is in the same dir.

i am using this as the variable to process but am getting an error "variable being used without being declared" (using your code)

Func APing()

Ping ($arr[$i])

If @error Then

MsgBox(16, "Shot", $arr[$i] & " is offline")

Else

Call("ARights")

EndIf

EndFunc

Edited by gcue

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Hi, the Ping ($arr[$i]) is the problem..

$i in that function isn't declared.

#include <GuiConstants.au3>

Global $Ini = @ScriptDir & "\assets.ini"

$Gui = GUICreate("", 350, 100)
$combo = GUICtrlCreateCombo("Select Asset...", 50, 34, 200, 20, $CBS_DROPDOWNLIST); create combobox and set first item
GUICtrlSetData(-1, LoadCombo(), "Select Asset...")

$filemenu = GUICtrlCreateMenu("&File")
$fileopenitem = GUICtrlCreateMenuItem("Edit Device List", $filemenu)
$fileexititem = GUICtrlCreateMenuItem("Exit", $filemenu)

$helpmenu = GUICtrlCreateMenu ("&Help")
$helpchangeitem = GUICtrlCreateMenuitem ("Change Log",$helpmenu)
$helpaboutitem = GUICtrlCreateMenuitem ("About",$helpmenu)

$btn = GUICtrlCreateButton ("OK", 255,34,40,25)
GUICtrlSetState(-1, $GUI_FOCUS)

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
          Exit
        case $btn
            APing(GUICtrlRead($combo))
        case $fileopenitem
;~             EditINI()
        case $fileexititem
;~             Xbutton()
        case $helpchangeitem
;~             Change()
        case $helpaboutitem
;~             About()
    EndSwitch
WEnd

Func APing($iKey)
    Local $arr = IniReadSection($Ini, "ASSETS"), $iPing
    If Not @error Then
        For $i = 1 To $arr[0][0]
            If $iKey = $arr[$i][0] Then $iPing = $arr[$i][1]
        Next
    EndIf
    If $iPing <> "" Then
        Ping ($iPing)
        If @error Then  
            MsgBox(16, "Shot", $iPing & " is offline")
        Else
            ;Call("ARights")
        EndIf
    Else
        MsgBox(16, "Select Asset..", "Select Asset first.")
    EndIf   
EndFunc

Func LoadCombo()
    Local $arr = IniReadSection($Ini, "ASSETS"), $sAssets
    If Not @error Then
        For $i = 1 To $arr[0][0]
            $sAssets &= $arr[$i][0] & "|"
        Next
        Return StringTrimRight($sAssets, 1)
    EndIf
    Return "No assets loaded"
EndFunc

Cheers

Edited by smashly

Share this post


Link to post
Share on other sites

how do i refer to the PC in later functions?

ive tried $combo and $iping and $arr[$i]

thank you for your help

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Hi, your welcome..

Maybe you could set $iPing as a global variable, so when the Aping() function finds a successful match in the ini to what is selected in the combo box then then $iPing will be set with the address and it will be accessable from outside the Aping function.

#include <GuiConstants.au3>

Global $Ini = @ScriptDir & "\assets.ini", $iPing

$Gui = GUICreate("", 350, 100)
$combo = GUICtrlCreateCombo("Select Asset...", 50, 34, 200, 20, $CBS_DROPDOWNLIST); create combobox and set first item
GUICtrlSetData(-1, LoadCombo(), "Select Asset...")

$filemenu = GUICtrlCreateMenu("&File")
$fileopenitem = GUICtrlCreateMenuItem("Edit Device List", $filemenu)
$fileexititem = GUICtrlCreateMenuItem("Exit", $filemenu)

$helpmenu = GUICtrlCreateMenu ("&Help")
$helpchangeitem = GUICtrlCreateMenuitem ("Change Log",$helpmenu)
$helpaboutitem = GUICtrlCreateMenuitem ("About",$helpmenu)

$btn = GUICtrlCreateButton ("OK", 255,34,40,25)
GUICtrlSetState(-1, $GUI_FOCUS)

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE, $fileexititem
          Exit
        case $btn
            APing(GUICtrlRead($combo))
        case $fileopenitem
            EditINI()
        case $helpchangeitem
;~             Change()
        case $helpaboutitem
;~             About()
    EndSwitch
WEnd

Func APing($iKey)
    $iPing = IniRead($Ini, "ASSETS", $iKey, "")
    If $iPing Then 
        Ping($iPing)
        If @error Then  
            MsgBox(16, "Shot", $iPing & " is offline")
        Else
            ;Call("ARights")
        EndIf
    Else
        MsgBox(16, "Select Asset..", "Select Asset first.")
    EndIf
EndFunc 

Func EditINI()
    ShellExecuteWait("notepad.exe", $Ini)
    GUICTrlSetdata($combo,"")
    GUICTrlSetdata($combo, "Select Asset...|" & LoadCombo(), "Select Asset...") 
EndFunc

Func LoadCombo()
    Local $arr = IniReadSection($Ini, "ASSETS"), $sAssets
    If Not @error Then
        For $i = 1 To $arr[0][0]
            $sAssets &= $arr[$i][0] & "|"
        Next
        Return StringTrimRight($sAssets, 1)
    EndIf
    Return "No assets loaded"
EndFunc

PS. I couldn't help myself but to ad the Edit ini function.. once you close the ini the combo will be reloaded.

Side Note: While the ini is open from the edit function the script will be paused until the ini has been closed.

Cheers

Edit: Redid the Aping() function, to make it briefer...

Edited by smashly

Share this post


Link to post
Share on other sites

lol now it says select an asset first... hehheeh

hmm maybe i should just send ya the whole script.

#Include <GuiConstants.au3>
#Include <Constants.au3>
#include <file.au3>


Dim $objWMIService = ObjGet("winmgmts:\\.\root\cimv2")

Dim $colDrives = $objWMIService.ExecQuery ("Select * From Win32_LogicalDisk Where DriveType = 4")

Dim $mapped = false

For $objDrive in $colDrives
    ;ConsoleWrite("Drive letter: " & $objDrive.DeviceID & @CRLF)
    ;ConsoleWrite("Network path: " & $objDrive.ProviderName & @CRLF)
    
    If StringLeft(@ScriptDir, 2) = $objDrive.DeviceID OR StringInStr(@ScriptDir, $objDrive.ProviderName) Then
        $mapped = True
        ExitLoop
    EndIf
Next

If $mapped Then
    ;MsgBox(0,"","Drive is mapped")
Else
    MsgBox(0,"Remote Screenshot","Please run this script from a mapped drive. Exiting.")
    Exit
EndIf


Dim $aAuthorizedUsers[11] = ["10","GXM","JJBC","MXK","RACM","FWK","JONE","MALB","KXT","SWT","MONB"]
$iAuthorized = 0

For $i = 1 To $aAuthorizedUsers[0]
    If @UserName = $aAuthorizedUsers[$i] Then
        $iAuthorized = 1
        ExitLoop
    EndIf
Next

If Not $iAuthorized Then
    MsgBox(16,"Access Denied - Invalid Account","You are not authorized to use this application." &@CRLF &@CRLF &"Exiting...",5)
    Exit(5)
EndIf



If Not FileExists("sc.src") Then
 MsgBox(16, "Remote Screenshot", "Error: SC.SRC is missing. Application will now exit.")
 Exit
EndIf

If Not FileExists("psexec.exe") Then
 MsgBox(16, "Remote Screenshot", "Error: PSEXEC.EXE is missing. Application will now exit.")
 Exit
EndIf

If Not FileExists(@DesktopDir & "\Screenshots") Then
    DirCreate(@DesktopDir & "\Screenshots")
EndIf


If Not FileExists("assets.ini") Then
    MsgBox(262144, "Remote Screenshot", "assets.ini is missing. One has been created for you.")
    IniWrite("assets.ini", "ASSETS", "Asset_Label1","Asset1")
    IniWrite("assets.ini", "ASSETS", "Asset_Label2","Asset2")
    IniWrite("assets.ini", "ASSETS", "Asset_Label3","Asset3")
    ShellExecute("assets.ini")
EndIf


Global $Ini = @ScriptDir & "\assets.ini", $iPing

$Gui = GUICreate("", 350, 100)
$combo = GUICtrlCreateCombo("Select Asset...", 50, 34, 200, 20, $CBS_DROPDOWNLIST); create combobox and set first item
GUICtrlSetData(-1, LoadCombo(), "Select Asset...")

$filemenu = GUICtrlCreateMenu("&File")
$fileopenitem = GUICtrlCreateMenuItem("Edit Device List", $filemenu)
$fileexititem = GUICtrlCreateMenuItem("Exit", $filemenu)

$helpmenu = GUICtrlCreateMenu ("&Help")
$helpchangeitem = GUICtrlCreateMenuitem ("Change Log",$helpmenu)
$helpaboutitem = GUICtrlCreateMenuitem ("About",$helpmenu)

$btn = GUICtrlCreateButton ("OK", 255,34,40,25)
GUICtrlSetState(-1, $GUI_FOCUS)

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
          Exit
        case $btn
             APing($iPing)
        case $fileopenitem
             EditINI()
        case $fileexititem
             Xbutton()
        case $helpchangeitem
             Change()
        case $helpaboutitem
             About()
    EndSwitch
WEnd

Func APing($iKey)
    Local $arr = IniReadSection($Ini, "ASSETS"), $iPing
    If Not @error Then
        For $i = 1 To $arr[0][0]
            If $iKey = $arr[$i][0] Then
                $iPing = $arr[$i][1]
            EndIf
        Next
    EndIf
    If $iPing <> "" Then
        Ping ($iPing)
        If @error Then  
            MsgBox(16, "Shot", $iPing & " is offline")
        Else
            ARights()
        EndIf
    Else
        MsgBox(16, "Select Asset..", "Select Asset first.")
    EndIf   
EndFunc

Func LoadCombo()
    Local $arr = IniReadSection($Ini, "ASSETS"), $sAssets
    If Not @error Then
        For $i = 1 To $arr[0][0]
            $sAssets &= $arr[$i][0] & "|"
        Next
        Return StringTrimRight($sAssets, 1)
    EndIf
    Return "No assets loaded"
EndFunc

Func ARights()
RegRead ( "\\" & $iPing & "\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion", "ProgramFilesDir" )

If @error Then 
    MsgBox(16, "Remote Screenshot", "You do not have local admin rights on " & $iPing)    
Else     
    Call("Open")    
EndIf
EndFunc


Func Open()

If FileExists ("\\" & $iPing & "\c$\temp\sc.exe") Then
  FileDelete ( "\\" & $iPing & "\c$\temp\sc.exe")
EndIf

FileCopy ("sc.src", "\\" & $iPing & "\c$\temp",1)
FileMove ("\\" & $iPing & "\c$\temp\sc.src", "\\" & $iPing & "\c$\temp\sc.exe")

RunWait("psexec.exe " & "\\" & $iPing & " -d -i c:\temp\sc.exe" )

Sleep(5000)

If FileExists ( "\\" & $iPing & "\c$\temp\" & "*" & $iPing & "*.jpg") Then
  FileMove("\\" & $iPing & "\c$\temp\" & "*" & $iPing & "*.jpg", @DesktopDir & "\Screenshots\")
  Run(@WindowsDir & "\explorer.exe " & @DesktopDir & "\Screenshots")
Else
  MsgBox(16, "Remote Screenshot", 'Unable to take a screenshot from ' & $iPing &@CRLF & _
                                  ''&@CRLF & _
                                  'Probable KNOWN reasons:'&@CRLF & _
                                  ''&@CRLF & _
                                  '1.  Asset is on CAD screen.'&@CRLF & _
                                  '2.  Bloomberg is the active window.')
EndIf
  Call("Cleanup")
EndFunc



Func Cleanup()
If FileExists ("\\" & $iPing & "\c$\temp\sc.exe") Then
   FileDelete ( "\\" & $iPing & "\c$\temp\sc.exe")
EndIf
EndFunc

Func EditINI()
  ShellExecuteWait("assets.ini")
  MsgBox(262144, "Remote Screenshot", "INI changes won't show until Remote Screenshot is restarted.")
EndFunc


Func Change()
MsgBox(262144, "Remote Screenshot v0.2", 'Change Log'&@CRLF & _
                        ''&@CRLF & _
                        'Changes from v0.12 to v0.2'&@CRLF & _
                        ''&@CRLF & _
                        '1. Added this change log.'&@CRLF & _
                        '2. Added INI capability to reference a list of commonly used assets.')
EndFunc

Func About()
MsgBox(64, "About", 'Remote Screenshot v0.2'&@CRLF & _
                        ''&@CRLF & _
                        'Take a screenshot of a remote PC.'&@CRLF & _
                        ''&@CRLF & _
                        'Cannot take remote screenshots when:'&@CRLF & _
                        ''&@CRLF & _
                        '1. PC is on the CAD screen.'&@CRLF & _
                        '2. PC has Bloomberg as the active window.'&@CRLF & _
                        '3. Tech does not have admin rights on target PC.'&@CRLF & _
                        '4. Target PC is offline.'&@CRLF & _
                        ''&@CRLF & _
                        'Contact GXM x90760 for questions/suggestions.')
EndFunc


Func Xbutton()
  Exit
EndFunc

Share this post


Link to post
Share on other sites

Hi, found the reason you get the "Select an asset first" msg..

You had

case $btn
             APing($iPing)oÝ÷ Øl¥u·ºÚ"µÍØÙH  ÌÍØT[ÊÕRPÝXY
    ÌÍØÛÛXÊJoÝ÷ Øw«zÚò¶¬jëh×6#Include <GuiConstants.au3>
#Include <Constants.au3>
#include <file.au3>


Dim $objWMIService = ObjGet("winmgmts:\\.\root\cimv2")

Dim $colDrives = $objWMIService.ExecQuery ("Select * From Win32_LogicalDisk Where DriveType = 4")

Dim $mapped = false

For $objDrive in $colDrives
    ;ConsoleWrite("Drive letter: " & $objDrive.DeviceID & @CRLF)
    ;ConsoleWrite("Network path: " & $objDrive.ProviderName & @CRLF)
   
    If StringLeft(@ScriptDir, 2) = $objDrive.DeviceID OR StringInStr(@ScriptDir, $objDrive.ProviderName) Then
        $mapped = True
        ExitLoop
    EndIf
Next

If $mapped Then
    ;MsgBox(0,"","Drive is mapped")
Else
    MsgBox(0,"Remote Screenshot","Please run this script from a mapped drive. Exiting.")
    Exit
EndIf


Dim $aAuthorizedUsers[11] = ["10","GXM","JJBC","MXK","RACM","FWK","JONE","MALB","KXT","SWT","MONB"]
$iAuthorized = 0

For $i = 1 To $aAuthorizedUsers[0]
    If @UserName = $aAuthorizedUsers[$i] Then
        $iAuthorized = 1
        ExitLoop
    EndIf
Next

If Not $iAuthorized Then
    MsgBox(16,"Access Denied - Invalid Account","You are not authorized to use this application." &@CRLF &@CRLF &"Exiting...",5)
    Exit(5)
EndIf



If Not FileExists("sc.src") Then
 MsgBox(16, "Remote Screenshot", "Error: SC.SRC is missing. Application will now exit.")
 Exit
EndIf

If Not FileExists("psexec.exe") Then
 MsgBox(16, "Remote Screenshot", "Error: PSEXEC.EXE is missing. Application will now exit.")
 Exit
EndIf

If Not FileExists(@DesktopDir & "\Screenshots") Then
    DirCreate(@DesktopDir & "\Screenshots")
EndIf


If Not FileExists("assets.ini") Then
    MsgBox(262144, "Remote Screenshot", "assets.ini is missing. One has been created for you.")
    IniWrite("assets.ini", "ASSETS", "Asset_Label1","Asset1")
    IniWrite("assets.ini", "ASSETS", "Asset_Label2","Asset2")
    IniWrite("assets.ini", "ASSETS", "Asset_Label3","Asset3")
    ShellExecute("assets.ini")
EndIf


Global $Ini = @ScriptDir & "\assets.ini", $iPing

$Gui = GUICreate("", 350, 100)
$combo = GUICtrlCreateCombo("Select Asset...", 50, 34, 200, 20, $CBS_DROPDOWNLIST); create combobox and set first item
GUICtrlSetData(-1, LoadCombo(), "Select Asset...")

$filemenu = GUICtrlCreateMenu("&File")
$fileopenitem = GUICtrlCreateMenuItem("Edit Device List", $filemenu)
$fileexititem = GUICtrlCreateMenuItem("Exit", $filemenu)

$helpmenu = GUICtrlCreateMenu ("&Help")
$helpchangeitem = GUICtrlCreateMenuitem ("Change Log",$helpmenu)
$helpaboutitem = GUICtrlCreateMenuitem ("About",$helpmenu)

$btn = GUICtrlCreateButton ("OK", 255,34,40,25)
GUICtrlSetState(-1, $GUI_FOCUS)

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE, $fileexititem
          Exit
        case $btn
             APing(GUICtrlRead($combo))
        case $fileopenitem
             EditINI()
        case $helpchangeitem
             Change()
        case $helpaboutitem
             About()
    EndSwitch
WEnd

Func APing($iKey)
    $iPing = IniRead($Ini, "ASSETS", $iKey, "")
    If $iPing Then 
        Ping($iPing)
        If @error Then  
            MsgBox(16, "Shot", $iPing & " is offline")
        Else
            ;Call("ARights")
        EndIf
    Else
        MsgBox(16, "Select Asset..", "Select Asset first.")
    EndIf
EndFunc

Func EditINI()
    ShellExecuteWait("notepad.exe", $Ini)
    GUICTrlSetdata($combo,"")
    GUICTrlSetdata($combo, "Select Asset...|" & LoadCombo(), "Select Asset...") 
EndFunc

Func LoadCombo()
    Local $arr = IniReadSection($Ini, "ASSETS"), $sAssets
    If Not @error Then
        For $i = 1 To $arr[0][0]
            $sAssets &= $arr[$i][0] & "|"
        Next
        Return StringTrimRight($sAssets, 1)
    EndIf
    Return "No assets loaded"
EndFunc

Func ARights()
RegRead ( "\\" & $iPing & "\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion", "ProgramFilesDir" )

If @error Then
    MsgBox(16, "Remote Screenshot", "You do not have local admin rights on " & $iPing)   
Else     
    Call("Open")   
EndIf
EndFunc


Func Open()

If FileExists ("\\" & $iPing & "\c$\temp\sc.exe") Then
  FileDelete ( "\\" & $iPing & "\c$\temp\sc.exe")
EndIf

FileCopy ("sc.src", "\\" & $iPing & "\c$\temp",1)
FileMove ("\\" & $iPing & "\c$\temp\sc.src", "\\" & $iPing & "\c$\temp\sc.exe")

RunWait("psexec.exe " & "\\" & $iPing & " -d -i c:\temp\sc.exe" )

Sleep(5000)

If FileExists ( "\\" & $iPing & "\c$\temp\" & "*" & $iPing & "*.jpg") Then
  FileMove("\\" & $iPing & "\c$\temp\" & "*" & $iPing & "*.jpg", @DesktopDir & "\Screenshots\")
  Run(@WindowsDir & "\explorer.exe " & @DesktopDir & "\Screenshots")
Else
  MsgBox(16, "Remote Screenshot", 'Unable to take a screenshot from ' & $iPing &@CRLF & _
                                  ''&@CRLF & _
                                  'Probable KNOWN reasons:'&@CRLF & _
                                  ''&@CRLF & _
                                  '1.  Asset is on CAD screen.'&@CRLF & _
                                  '2.  Bloomberg is the active window.')
EndIf
  Cleanup()
EndFunc



Func Cleanup()
If FileExists ("\\" & $iPing & "\c$\temp\sc.exe") Then
   FileDelete ( "\\" & $iPing & "\c$\temp\sc.exe")
EndIf
EndFunc

Func Change()
MsgBox(262144, "Remote Screenshot v0.2", 'Change Log'&@CRLF & _
                        ''&@CRLF & _
                        'Changes from v0.12 to v0.2'&@CRLF & _
                        ''&@CRLF & _
                        '1. Added this change log.'&@CRLF & _
                        '2. Added INI capability to reference a list of commonly used assets.')
EndFunc

Func About()
MsgBox(64, "About", 'Remote Screenshot v0.2'&@CRLF & _
                        ''&@CRLF & _
                        'Take a screenshot of a remote PC.'&@CRLF & _
                        ''&@CRLF & _
                        'Cannot take remote screenshots when:'&@CRLF & _
                        ''&@CRLF & _
                        '1. PC is on the CAD screen.'&@CRLF & _
                        '2. PC has Bloomberg as the active window.'&@CRLF & _
                        '3. Tech does not have admin rights on target PC.'&@CRLF & _
                        '4. Target PC is offline.'&@CRLF & _
                        ''&@CRLF & _
                        'Contact GXM x90760 for questions/suggestions.')
EndFunc
No promises it'll work as I can't test the screenshot from a mapped drive atm.

Cheers

Share this post


Link to post
Share on other sites

hmm nothing happens after i select an asset and run it.

i took out the check for a mapped drive also. no need for it anymore ;-)

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Without any code apart from the ping() are the pc's responding to the ping?

Sorry for my understanding but when you set the Ini you have for example

ANDS_ETS=d0090774

Is ANDS_ETS the pc name?

What is "d0090774" ?, I was assuming this is meant to be an IP

So the ini would look something like.

PC_NAME=192.168.1.55

If I pick PC_Name from the Combobox then the value would be $iPing = 192.168.1.55

When I ping a pc on my local home network I use the machine name for example on my pc

ping(smashly1)

Or

ping(192.168.1.14)

or on the net I ping a web address

ping(www.autoitscript.com)

When I try and ping a Physical Address of the network hardware eg: 00-1A-4D-61-68-69) then the ping fails

More input please.

Cheers

Edited by smashly

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

sorry about the confusion..

here's a breakdown:

===

INI

[ASSETS]

ANDS_ETS=d0090774

===

ANDS_ETS is the lable of the PC

d0090774 is the computername which resolves to the ip

the point of the script is to take a remote screenshot of a remote pc (using psexec).

the process is:

1. the pc is pinged if the ping fails the user is notified that the pc/asset is offline

APING()

2. the pc is also tested for admin rights (as you would need them to run psexec)

ARIGHTS()

3. if the above pass, then the remote screenshot is taken and copied to script user's desktop

OPEN()

i know how to do the checks for failed tests - havent put them in yet..

(setting a $errorcount =+1 when a test fails and a check for $errorcount before doing the next test)

i just need help with the variable handling along the way - i think =)

thanks again for all your help.

Edited by gcue

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Hi, did you uncomment the ;Call("ARights")

Func APing($iKey)
    $iPing = IniRead($Ini, "ASSETS", $iKey, "")
    If $iPing Then
        Ping($iPing)
        If @error Then  
            MsgBox(16, "Shot", $iPing & " is offline")
        Else
            Call("ARights") ;<---- If you just direct copy and pasted the script above did you uncomment this like so?
        EndIf
    Else
        MsgBox(16, "Select Asset..", "Select Asset first.")
    EndIf
EndFunc

I commented it out when I was running the script on my pc, just so I could see the combo and hostname were being retrieved correctly..

Cheers

Edited by smashly

Share this post


Link to post
Share on other sites

LOL!!!!

thank you soooooooooo much!!!!

Share this post


Link to post
Share on other sites

it works great!

would it be possible to make the field so u can ENTER an asset on the fly other than selecting one from the ini?

know what i mean?

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