need this script to change icons when used

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nkotbox
    New Member
    • Aug 2006
    • 1

    need this script to change icons when used

    I have this script to enable/disable my wireless nic on my laptop. Is it possible for the scripts icon or shortcut to the script to change icons depending on whether or not the nic is enabled. So if the wireless nic was enabled then the script icon would be my on.ico and if it were disabled the the icon would be my off.ico heres the script

    Const ssfCONTROLS = 3

    sConnectionName = "wireless network Connection"

    sEnableVerb = "En&able"
    sDisableVerb = "Disa&ble"

    set shellApp = createobject("s hell.applicatio n")
    set oControlPanel = shellApp.Namesp ace(ssfCONTROLS )

    set oNetConnections = nothing
    for each folderitem in oControlPanel.i tems
    if folderitem.name = "Network Connections" then
    set oNetConnections = folderitem.getf older: exit for
    end if
    next

    if oNetConnections is nothing then
    msgbox "Couldn't find 'Network Connections' folder"
    wscript.quit
    end if

    set oLanConnection = nothing
    for each folderitem in oNetConnections .items
    if lcase(folderite m.name) = lcase(sConnecti onName) then
    set oLanConnection = folderitem: exit for
    end if
    next

    if oLanConnection is nothing then
    msgbox "Couldn't find '" & sConnectionName & "' item"
    wscript.quit
    end if

    bEnabled = true
    set oEnableVerb = nothing
    set oDisableVerb = nothing
    s = "Verbs: " & vbcrlf
    for each verb in oLanConnection. verbs
    s = s & vbcrlf & verb.name
    if verb.name = sEnableVerb then
    set oEnableVerb = verb
    bEnabled = false
    end if
    if verb.name = sDisableVerb then
    set oDisableVerb = verb
    end if
    next

    'debugging displays left just in case...
    '
    'msgbox s ': wscript.quit
    'msgbox "Enabled: " & bEnabled ': wscript.quit

    'not sure why, but invokeverb always seemed to work
    'for enable but not disable.
    '
    'saving a reference to the appropriate verb object
    'and calling the DoIt method always seems to work.
    '
    if bEnabled then
    ' oLanConnection. invokeverb sDisableVerb
    oDisableVerb.Do It
    else
    ' oLanConnection. invokeverb sEnableVerb
    oEnableVerb.DoI t
    end if

    'adjust the sleep duration below as needed...
    '
    'if you let the oLanConnection go out of scope
    'and be destroyed too soon, the action of the verb
    'may not take...
    '
    wscript.sleep 1000
Working...