Retrieve current SSID and write to registry

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
apoklyps3
Posts: 116
Joined: 13 Feb 2016, 13:20

Retrieve current SSID and write to registry

07 Apr 2018, 07:12

Since Windows 10 doesn't automaticaly connect to wifi when restarted in Safe mode with networking , i"m trying to create a script that creates a RunOnce reg entry to run a CMD the connects to the detected SSID

here is my code, but nothing is written in RunOnce reg key. What am I missing?

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

full_command_line := DllCall("GetCommandLine", "str")

if not (A_IsAdmin or RegExMatch(full_command_line, " /restart(?!\S)"))
{
    try
    {
        if A_IsCompiled
            Run *RunAs "%A_ScriptFullPath%" /restart
        else
            Run *RunAs "%A_AhkPath%" /restart "%A_ScriptFullPath%"
    }
    ExitApp
}

RunWait %comspec% /c netsh wlan show interface > out.txt
	FileRead, Var, out.txt
	RegExMatch(Var, "mi)State\s*:\s*connected\s*SSID\s*:\s*([^\R]+)", SSID)
RegWrite, REG_SZ, HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce, *WIFI, "C:\\Windows\\system32\\cmd.exe /c netsh wlan connect name=%SSID1%"
apoklyps3
Posts: 116
Joined: 13 Feb 2016, 13:20

Re: Retrieve current SSID and write to registry

07 Apr 2018, 08:10

the culprit seems to be RegWrite. It won't write to registry even if I modify key name and string. Is it broken
'?
donovv
Posts: 108
Joined: 15 Apr 2017, 21:06

Re: Retrieve current SSID and write to registry

07 Apr 2018, 14:28

so i dont have a laptop or anything to even attempted to help with this right now but i can see 1 possible issue
"C:\\Windows\\system32\\cmd.exe /c netsh wlan connect name=%SSID1%"
you have the variable within quotes its going to run that as a litteral string you would want to do
"C:\\Windows\\system32\\cmd.exe /c netsh wlan connect name="%SSID%
also i know the docs says subpat1 but it should be just the var you put

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Draken, oktavimark and 394 guests