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%"