oneLess

[Solved] Help with PowerShell command

17 posts in this topic

#1 ·  Posted (edited)

if I run below command from PowerShell or PowerShell_ISE window , as admin is not necessary

will generate on the desktop a .txt file

which will contain all

saved names (SSID) and passwords for

all wireless networks connected now or in the past

for the active user profile on local machine.

(netsh wlan show profiles) | Select-String "\:(.+)$" | %{$name=$_.Matches.Groups[1].Value.Trim(); $_} | %{(netsh wlan show profile name="$name" key=clear)}  | Select-String "Key Content\W+\:(.+)$" | %{$pass=$_.Matches.Groups[1].Value.Trim(); $_} | %{[PSCustomObject]@{ PROFILE_NAME=$name;PASSWORD=$pass }} | Format-Table -AutoSize | Out-File "$env:userprofile\Desktop\WirelessNetworkPasswords.txt"

more info on tenforums site .

i want to run this powershell command from autoit script with Run or ShellExecute command or other way

but I see errors in the splash screen and I get an empty .txt file on the desktop.

any help ?

c

 

Edited by oneLess
close the topic

Share this post


Link to post
Share on other sites



Assuming you're using something like:

RunWait('PowerShell.exe -Command "& {(netsh wlan show profiles) | Select-String "\:(.+)$" | %{$name=$_.Matches.Groups[1].Value.Trim(); $_} | %{(netsh wlan show profile name="$name" key=clear)}  | Select-String "Key Content\W+\:(.+)$" | %{$pass=$_.Matches.Groups[1].Value.Trim(); $_} | %{[PSCustomObject]@{ PROFILE_NAME=$name;PASSWORD=$pass }} | Format-Table -AutoSize | Out-File "$env:userprofile\Desktop\WirelessNetworkPasswords.txt"}"')

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

11 minutes ago, Subz said:

Assuming you're using something like:

RunWait('PowerShell.exe -Command "& {(netsh wlan show profiles) | Select-String "\:(.+)$" | %{$name=$_.Matches.Groups[1].Value.Trim(); $_} | %{(netsh wlan show profile name="$name" key=clear)}  | Select-String "Key Content\W+\:(.+)$" | %{$pass=$_.Matches.Groups[1].Value.Trim(); $_} | %{[PSCustomObject]@{ PROFILE_NAME=$name;PASSWORD=$pass }} | Format-Table -AutoSize | Out-File "$env:userprofile\Desktop\WirelessNetworkPasswords.txt"}"')

 

yes with  appended

, '' , @SW_SHOW)

at the end instead of last

)

first error occur for (.+)

c

Edited by oneLess

Share this post


Link to post
Share on other sites

Well, why use powershell instead of pushing the commands directly?

 


Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

 

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

3 minutes ago, careca said:

Well, why use powershell instead of pushing the commands directly?

 

will be much convenient , but how , which command ?
the powershel way is the single one I found to do that silent

I want to integrate it in my main autoit (tool) script

c

Edited by oneLess

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

This is the idea:

netsh wlan show profiles ;<-This shows the available wifi profiles
netsh wlan show profile "your wifi name" ;<-Selects the one that you want
netsh wlan show profile "your wifi name" key=clear ;<-Show it's password within the security part.

Its a question of getting that with a method such as this:

Func Motherboard()
    Local $DSK, $Read, $Str, $Str1
    $DSK = Run('cmd', '', @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD)
    Do
        $Read = StdoutRead($DSK, True, False)
        $Str = StringInStr($Read, 'Microsoft Windows')
    Until $Str <> 0
    Sleep(300)
    StdinWrite($DSK, "wmic baseboard get product,manufacturer" & @CRLF)
    Do
        $Read = StdoutRead($DSK, True, False)
        $Str1 = StringInStr($Read, 'Manufacturer', 0, 2)
    Until $Str1 <> 0
    $Read = StdoutRead($DSK, True, False)
    Local $Spl = StringSplit($Read, 'Product', 1)
    Local $SplR = StringStripWS($Spl[2], 7)
    MsgBox(64, 'Motherboard', $SplR)
EndFunc   ;==>Motherboard

Only this gives you the motherboard manufacturer and model. But you get the picture.

Now that i think of it, its kinda messy and a lot more code than 1 line like you have back there.

The advantages of something like this is that you can display it whenever you want. i guess.

Edited by careca

Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

 

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

53 minutes ago, careca said:

This is the idea:

netsh wlan show profiles ;<-This shows the available wifi profiles
netsh wlan show profile "your wifi name" ;<-Selects the one that you want
netsh wlan show profile "your wifi name" key=clear ;<-Show it's password within the security part.

---

thank you careca for idea . is also posted in tenforum link posted above.

thank you also for your script.

I also have mines but yours is more evolved and sure I will pay my attention.

 

but the ideea was the powershell command will bring you a LIST

with SSIDs and passwords for ALL ALL wireless connection SAVED in the past on local machine / active profile user

I suppose will work even you are NOT connected to a wireless network at the moment you run the command.

c

 

Edited by oneLess

Share this post


Link to post
Share on other sites

Im working in something like that, with a listview. stay tuned


Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

 

Share this post


Link to post
Share on other sites
Just now, careca said:

Im working in something like that, with a listview. stay tuned

 

and anyway , we cant run a working powershell command in autoit ?

Share this post


Link to post
Share on other sites

Not sure, i don't really use powershell, only to remove the appstore apps, it seems the best way.


Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

 

Share this post


Link to post
Share on other sites

This is what i got so far:

#Region ;Wrapper
#pragma compile(UPX, false)
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_UseX64=n
#AutoIt3Wrapper_Run_Tidy=y
#AutoIt3Wrapper_Res_SaveSource=y
;#AutoIt3Wrapper_Icon=
;#AutoIt3Wrapper_Res_Icon_Add=
;#AutoIt3Wrapper_Outfile=
;#AutoIt3Wrapper_Res_Comment=
;#AutoIt3Wrapper_Res_Description=
#AutoIt3Wrapper_Res_Fileversion=1.0
#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7
#EndRegion ;Wrapper
;=============================================================================
#Region ;FileInstall
;FileInstall("file", @ScriptDir & "\file")
#EndRegion ;FileInstall
;=============================================================================
#Region
#include <GUIConstants.au3>
#include <TrayConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <AutoItConstants.au3>
#EndRegion
;=============================================================================
#Region
OnAutoItExitRegister("Quit")
Opt("TrayMenuMode", 1)
Opt("TrayIconHide", 0)
Opt("GUICoordMode", 1)
Opt("GUIResizeMode", 1)
Opt("TrayIconDebug", 1)
Opt("TrayAutoPause", 0)
Opt("MouseCoordMode", 2)
Opt("GUIOnEventMode", 1)
Opt("MustDeclareVars", 0)
Opt("GUIEventOptions", 1)
Opt("TrayOnEventMode", 1)
Opt("ExpandEnvStrings", 1)
Opt("WinDetectHiddenText", 1)
#EndRegion
;=============================================================================
#Region
Local $GUI, $totray, $restore, $exititem, $WinState
Local $InptB, $DSK, $Read, $Str, $Str1, $SplR, $StrL, $StrTrim
Local $Ini = @ScriptDir & '\Wifi.ini'

$GUI = GUICreate("Test Window", 300, 200, 0, 0)
GUISetState()
TraySetState(1)
TraySetClick(16)
$WinState = 1

Local $Listview = GUICtrlCreateListView('|', 10, 10, 280, 180)
GUICtrlSetBkColor($Listview, 0x333333)
GUICtrlSetColor($Listview, 0xEEEEEE)

TraySetOnEvent($TRAY_EVENT_PRIMARYDOUBLE, "Window")
GUISetOnEvent($GUI_EVENT_CLOSE, "Quit")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "Minimize")
GUISetOnEvent($GUI_EVENT_RESTORE, "Restore")

$totray = TrayCreateItem("Tray")
TrayItemSetOnEvent(-1, "ToTray")
$restore = TrayCreateItem("Restore")
TrayItemSetOnEvent(-1, "RestoreT")
$exititem = TrayCreateItem("Close")
TrayItemSetOnEvent(-1, "Quit")

WifiProf()
#EndRegion
;=============================================================================
Func WifiProf()
    $DSK = Run('cmd', '', @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD)
    Do
        $Read = StdoutRead($DSK, True, False)
        $Str = StringInStr($Read, 'Microsoft Windows')
    Until $Str <> 0
    Sleep(300)
    StdinWrite($DSK, "netsh wlan show profiles" & @CRLF)
    Do
        Sleep(100)
        $Read = StdoutRead($DSK, True, False)
        $Str1 = StringInStr($Read, 'All User Profile', 0, 2)
    Until $Str1 <> 0
    $Read = StdoutRead($DSK, True, False)
    Local $Spl = StringSplit($Read, 'All User Profile     : ', 1)
    For $i = 2 To $Spl[0]
        Local $SplR = StringStripWS($Spl[$i], 7)
        $Str1 = StringInStr($SplR, @ScriptDir & '>')
        If $Str1 <> 0 Then
            $StrL = StringLen(@ScriptDir)
            $StrTrim = StringTrimRight($SplR, $StrL + 2)
            ConsoleWrite($StrTrim & @CRLF)
            GUICtrlCreateListViewItem($StrTrim & '|', $Listview)
            GUICtrlSendMsg($Listview, $LVM_SETCOLUMNWIDTH, 0, -1)
        Else
            ConsoleWrite($SplR & @CRLF)
            GUICtrlCreateListViewItem($SplR & '|', $Listview)
            GUICtrlSendMsg($Listview, $LVM_SETCOLUMNWIDTH, 0, -1)
        EndIf
    Next
    ;WifiPass()
EndFunc   ;==>WifiProf
;=============================================================================
Func WifiPass()
    If $InptB <> '' Then
        StdinWrite($DSK, 'netsh wlan show profile "' & $InptB & '" key=clear' & @CRLF)
        Do
            Sleep(100)
            $Read = StdoutRead($DSK, True, False)
            MsgBox(64, 'WifiP', $Read)
            $Str1 = StringInStr($Read, 'All User Profile', 0, 2)
        Until $Str1 <> 0
        $Read = StdoutRead($DSK, True, False)
        GUICtrlCreateListViewItem('|'&$Read, $Listview)
        GUICtrlSendMsg($Listview, $LVM_SETCOLUMNWIDTH, 1, -1)
    EndIf
EndFunc   ;==>WifiPass
;=============================================================================
Func Window()
    If $WinState = 0 Then
        GUISetState(@SW_SHOW, $GUI)
        $WinState = 1
    Else
        GUISetState(@SW_HIDE, $GUI)
        $WinState = 0
    EndIf
EndFunc   ;==>Window
;=============================================================================
Func ToTray()
    TrayItemSetState($totray, $TRAY_UNCHECKED)
    GUISetState(@SW_HIDE)
    $WinState = 0
EndFunc   ;==>ToTray
;=============================================================================
Func RestoreT()
    TrayItemSetState($restore, $TRAY_UNCHECKED)
    GUISetState(@SW_SHOW)
    $WinState = 1
EndFunc   ;==>RestoreT
;=============================================================================
Func Minimize()
    WinSetState($GUI, '', @SW_MINIMIZE)
EndFunc   ;==>Minimize
;=============================================================================
Func Restore()
    WinSetState($GUI, '', @SW_RESTORE)
EndFunc   ;==>Restore
;=============================================================================
Func Quit()
    Exit
EndFunc   ;==>Quit
;=============================================================================
Do
    Sleep(100)
Until GUIGetMsg() = $GUI_EVENT_CLOSE
;=============================================================================

When i comeback from lunch, i attack the password function.


Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

 

Share this post


Link to post
Share on other sites

Just tried on my laptop and found that you need to enclose the Select-String pattern with single quotes example:

RunWait('PowerShell.exe -Command "& {(netsh wlan show profiles) | Select-String ' & "'\:(.+)$'" & ' | %{$name=$_.Matches.Groups[1].Value.Trim(); $_} | %{(netsh wlan show profile name="$name" key=clear)}  | Select-String ' & "'Key Content\W+\:(.+)$'" & ' | %{$pass=$_.Matches.Groups[1].Value.Trim(); $_} | %{[PSCustomObject]@{ PROFILE_NAME=$name;PASSWORD=$pass }} | Format-Table -AutoSize | Out-File "$env:userprofile\Desktop\WirelessNetworkPasswords.txt"}"')

That worked for me.

2 people like this

Share this post


Link to post
Share on other sites
14 minutes ago, careca said:

.... i don't really use powershell, only to remove the appstore apps, it seems the best way.

yes is the best way . I use it also for that .

and I have a second use : for set regionals stuff

(zone time  , country , location , culture ... override inputs/language ...even add a second keyboard )

but looks is more powerfull than that

c

Share this post


Link to post
Share on other sites
56 minutes ago, Subz said:

Just tried on my laptop and found that you need to enclose the Select-String pattern with single quotes example:

RunWait('PowerShell.exe -Command "& {(netsh wlan show profiles) | Select-String ' & "'\:(.+)$'" & ' | %{$name=$_.Matches.Groups[1].Value.Trim(); $_} | %{(netsh wlan show profile name="$name" key=clear)}  | Select-String ' & "'Key Content\W+\:(.+)$'" & ' | %{$pass=$_.Matches.Groups[1].Value.Trim(); $_} | %{[PSCustomObject]@{ PROFILE_NAME=$name;PASSWORD=$pass }} | Format-Table -AutoSize | Out-File "$env:userprofile\Desktop\WirelessNetworkPasswords.txt"}"')

That worked for me.

Worked here also. So i guess it's solved.


Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

 

Share this post


Link to post
Share on other sites

In case anyone is interested in an alternative:

#Region ;Wrapper
#pragma compile(UPX, false)
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_UseX64=n
#AutoIt3Wrapper_Run_Tidy=y
#AutoIt3Wrapper_Res_SaveSource=y
;#AutoIt3Wrapper_Icon=
;#AutoIt3Wrapper_Res_Icon_Add=
;#AutoIt3Wrapper_Outfile=
;#AutoIt3Wrapper_Res_Comment=
;#AutoIt3Wrapper_Res_Description=
#AutoIt3Wrapper_Res_Fileversion=1.0
#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7
#EndRegion ;Wrapper
;=============================================================================
#Region ;FileInstall
;FileInstall("file", @ScriptDir & "\file")
#EndRegion ;FileInstall
;=============================================================================
#Region
#include <GuiListView.au3>
#include <GUIConstants.au3>
#include <TrayConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <AutoItConstants.au3>
#EndRegion
;=============================================================================
#Region
OnAutoItExitRegister("Quit")
Opt("TrayMenuMode", 1)
Opt("TrayIconHide", 0)
Opt("GUICoordMode", 1)
Opt("GUIResizeMode", 1)
Opt("TrayIconDebug", 1)
Opt("TrayAutoPause", 0)
Opt("MouseCoordMode", 2)
Opt("GUIOnEventMode", 1)
Opt("MustDeclareVars", 0)
Opt("GUIEventOptions", 1)
Opt("TrayOnEventMode", 1)
Opt("ExpandEnvStrings", 1)
Opt("WinDetectHiddenText", 1)
#EndRegion
;=============================================================================
#Region
Local $GUI, $totray, $restore, $exititem, $WinState, $ItemCount, $ItemTxt
Local $InptB, $DSK, $Read, $Str, $Str1, $Spl, $SplR, $StrL, $StrTrim, $Strsplt
Local $Ini = @ScriptDir & '\Wifi.ini'

$GUI = GUICreate("WifiP", 300, 200, 0, 0)
GUISetState()
TraySetState(1)
TraySetClick(16)
$WinState = 1

Local $Listview = GUICtrlCreateListView('Profile|Password', 10, 10, 280, 180)
GUICtrlSetBkColor($Listview, 0x333333)
GUICtrlSetColor($Listview, 0xEEEEEE)

TraySetOnEvent($TRAY_EVENT_PRIMARYDOUBLE, "Window")
GUISetOnEvent($GUI_EVENT_CLOSE, "Quit")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "Minimize")
GUISetOnEvent($GUI_EVENT_RESTORE, "Restore")

$totray = TrayCreateItem("Tray")
TrayItemSetOnEvent(-1, "ToTray")
$restore = TrayCreateItem("Restore")
TrayItemSetOnEvent(-1, "RestoreT")
$exititem = TrayCreateItem("Close")
TrayItemSetOnEvent(-1, "Quit")

WifiProf()
#EndRegion
;=============================================================================
Func WifiProf()
    $DSK = Run('cmd', '', @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD)
    Do
        $Read = StdoutRead($DSK, True, False)
        $Str = StringInStr($Read, 'Microsoft Windows')
    Until $Str <> 0
    Sleep(300)
    StdinWrite($DSK, "netsh wlan show profiles" & @CRLF)
    Do
        Sleep(100)
        $Read = StdoutRead($DSK, True, False)
        $Str1 = StringInStr($Read, 'All User Profile', 0, 2)
    Until $Str1 <> 0
    $Read = StdoutRead($DSK, True, False)
    Local $Spl = StringSplit($Read, 'All User Profile     : ', 1)
    For $i = 2 To $Spl[0]
        Local $SplR = StringStripWS($Spl[$i], 7)
        $Str1 = StringInStr($SplR, @ScriptDir & '>')
        If $Str1 <> 0 Then
            $StrL = StringLen(@ScriptDir)
            $StrTrim = StringTrimRight($SplR, $StrL + 2)
            GUICtrlCreateListViewItem($StrTrim & '|', $Listview)
            GUICtrlSendMsg($Listview, $LVM_SETCOLUMNWIDTH, 0, -1)
        Else
            GUICtrlCreateListViewItem($SplR & '|', $Listview)
            GUICtrlSendMsg($Listview, $LVM_SETCOLUMNWIDTH, 0, -1)
        EndIf
    Next
    WifiPass()
EndFunc   ;==>WifiProf
;=============================================================================
Func WifiPass()
    $ItemCount = _GUICtrlListView_GetItemCount($Listview)
    If $ItemCount <> 0 Then
        For $c = 0 To $ItemCount - 1
            $ItemTxt = _GUICtrlListView_GetItemText($Listview, $c)
            StdioClose($DSK)
            $DSK = Run('cmd', '', @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD)
            Do
                Sleep(100)
                $Read = StdoutRead($DSK, True, False)
                $Str = StringInStr($Read, 'Microsoft Windows')
            Until $Str <> 0
            StdinWrite($DSK, 'netsh wlan show profile "' & $ItemTxt & '" key=clear' & @CRLF)
            ConsoleWrite('Profile: ' & $ItemTxt & ' - ' & @MSEC & @CRLF)
            Do
                Sleep(100)
                $Read = StdoutRead($DSK, True, False)
                $Str1 = StringInStr($Read, 'Key Content            : ')
            Until $Str1 <> 0
            $Spl = StringSplit($Read, 'Key Content            : ', 1)
            $SplR = StringStripWS($Spl[2], 7)
            $Str1 = StringInStr($SplR, 'Cost settings')
            $Strsplt = StringSplit($SplR, 'Cost settings', 1)
            _GUICtrlListView_SetItem($Listview, $Strsplt[1], $c, 1)
            GUICtrlSendMsg($Listview, $LVM_SETCOLUMNWIDTH, 1, -1)
        Next
    EndIf
EndFunc   ;==>WifiPass
;=============================================================================
Func Window()
    If $WinState = 0 Then
        GUISetState(@SW_SHOW, $GUI)
        $WinState = 1
    Else
        GUISetState(@SW_HIDE, $GUI)
        $WinState = 0
    EndIf
EndFunc   ;==>Window
;=============================================================================
Func ToTray()
    TrayItemSetState($totray, $TRAY_UNCHECKED)
    GUISetState(@SW_HIDE)
    $WinState = 0
EndFunc   ;==>ToTray
;=============================================================================
Func RestoreT()
    TrayItemSetState($restore, $TRAY_UNCHECKED)
    GUISetState(@SW_SHOW)
    $WinState = 1
EndFunc   ;==>RestoreT
;=============================================================================
Func Minimize()
    WinSetState($GUI, '', @SW_MINIMIZE)
EndFunc   ;==>Minimize
;=============================================================================
Func Restore()
    WinSetState($GUI, '', @SW_RESTORE)
EndFunc   ;==>Restore
;=============================================================================
Func Quit()
    Exit
EndFunc   ;==>Quit
;=============================================================================
Do
    Sleep(100)
Until GUIGetMsg() = $GUI_EVENT_CLOSE
;=============================================================================

 

1 person likes this

Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

 

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

I confirm too , the code modified by Subz is working

Also the command works :

1. without error on machines w/o wireless , will create an empty file

2. on machines with wireless disabled will create the proper file

3. on machines with wireless not connected or in airplane mode will create the proper file

 

I confirm also , the careca script is working .

 

I use this script to get the name of active wireless network if is connected by wireless

Is not mine , is grabbed from this forum , sorry , not remember from where for mention the author

Func _GetActiveSSID ( )
  Local $STDERR_CHILD = 4  
  Local $STDOUT_CHILD = 2  
  Local $iPID = Run(@ComSpec & ' /u /c ' & 'netsh wlan show interfaces', @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)  
  Local $sOutput = ''  
  While 1   
    $sOutput &= StdoutRead ( $iPID )   
    If @error Then    
      ExitLoop   
    EndIf   
    $sOutput = StringStripWS ( $sOutput , 7)  
  WEnd
  $sReturn = StringRegExp ( $sOutput , '(?s)(?i)SSID\s*:\s(.*?)' & @CR , 3 )  
  If @error Then   
    Return 
    SetError ( 1 , 0 , '' )  
  EndIf
  Return $sReturn[0]
 EndFunc   ;==>_GetActiveSSID

Happy New Year for all

And Thank You Subz  , careca  and ALL community

c

Edited by oneLess

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

On ‎23‎.‎12‎.‎2016 at 2:59 PM, oneLess said:

thank you careca for idea . is also posted in tenforum link posted above.

thank you also for your script.

I also have mines but yours is more evolved and sure I will pay my attention.

based on careca way

I wrote a similar script , but using the huge allinone powershell command from OP

;=============================================================================
    ;
    ; more info at : https://www.tenforums.com/tutorials/27997-wireless-network-security-key-password-see-windows-10-a.html
    ;          and : https://www.autoitscript.com/forum/topic/186200-help-with-powershell-command/
    ;
    ; oneLess , 28 Dec 2016
    ;
    ;=============================================================================
    ;
    #include <GUIConstantsEx.au3>
    #include <Array.au3>            ;   --->>> is needed only if you use [_ArrayDisplay ( )] function in script
    ;
    Global $_wi_fi_array [1][2]
    $_wi_fi_array [0][0] = 0
    $_wi_fi_array [0][1] = "[number of saved wireless networks]"
    ;
    ;
    _populate_wi_fi_array ( )
    ;
    ;
    _ArrayDisplay ( $_wi_fi_array , "Saved Wireless Networks Info" , "" , 0 , -1 , "SSID|Password" )
    ; or process as your need the array
    ;
    ;
    ;=============================================================================
    Func _populate_wi_fi_array ( )
        ;
        Local $_i = 1 , $_j , $_k = 0
        Local $_command = '(netsh wlan show profiles) | Select-String "\:(.+)$" | %{$name=$_.Matches.Groups[1].Value.Trim(); $_} | %{(netsh wlan show profile name="$name" key=clear)}  | Select-String "Key Content\W+\:(.+)$" | %{$pass=$_.Matches.Groups[1].Value.Trim(); $_} | %{[PSCustomObject]@{ PROFILE_NAME=$name;PASSWORD=$pass }} | Format-Table -AutoSize'
        Local $_string_to_check = 'PS ' & @ScriptDir
        Local $_run , $_in_str = 0
        Local $_read , $_read_2 , $_read_3 , $_read_4 , $_read_5
        ;
        $_run = Run ( 'powershell' , @ScriptDir , @SW_HIDE , $STDIN_CHILD + $STDOUT_CHILD )
        Do
            Sleep ( 20 )
            $_read      = StdoutRead ( $_run , True , False )
            $_in_str    = StringInStr ( $_read , $_string_to_check )
        Until $_in_str <> 0
        ;
        Sleep(300)
        StdinWrite ( $_run , $_command & @CRLF)
        ;
        Do
            Sleep ( 20 )
            $_read      = StdoutRead($_run, True, False)
            $_read      = StringStripWS($_read, 3)
            $_in_str    = StringInStr($_read, 'PROFILE_NAME' & ' ')
            $_read      = StringReplace ( $_read , $_string_to_check , $_string_to_check )
        Until @extended = 2
        ;
        $_read_2 = StringSplit($_read, 'PROFILE_NAME ', 1 )
        If $_read_2[0]  = 1 Then
            ; no saved wireless networks
        Else
            $_read_3    = $_read_2[$_read_2[0]]
            $_read_4    = StringSplit ( $_read_3 , @CRLF )
            ;
            For $_j = 1 To $_read_4 [0]
                Select
                    Case StringInStr ( $_read_4 [$_j] , " PASSWORD" , 1 ) > 0
                        ; do nothing , so will be excluded
                    Case StringInStr ( $_read_4 [$_j] , "------" ) > 0
                        ;
                    Case StringInStr ( $_read_4 [$_j] , $_string_to_check ) > 0
                        ;
                    Case StringLen ( $_read_4 [$_j] ) = 0
                        ;
                    Case Else
                        $_k = $_k + 1
                        ReDim $_wi_fi_array [$_k+1][2]
                        $_wi_fi_array [0][0] = $_k              ; number of SSIDs
                        $_read_5 = StringSplit ( StringStripWS ( $_read_4 [$_j] , 7 ) , " " )
                        $_wi_fi_array [$_k][1-1] = $_read_5 [1]     ; SSID
                        $_wi_fi_array [$_k][2-1] = $_read_5 [2]     ; password
                EndSelect
            Next
        EndIf
        ;
    EndFunc   ;==>_populate_wi_fi_array
    ;=============================================================================

Thank again careca for your clear script.

I never understand before how to working proper with the console in/out .

 

/edit :

added @ScriptDir as working folder in run/powershell command

if is not added , the script works ok anywhere on hdd

but no from %temp% folder (download and run from internet link)

I don't know why, but now is working.

 

The script compiled x86 will work also in x64 environment.

No need for 2 compilations.

 

c

Edited by oneLess
complete post
1 person likes this

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