Refresh Internet Options through command - windows

I have two .bat files to enable and disable proxy through registry:
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet
Settings" /v ProxyEnable /t REG_DWORD /d 1 /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet
Settings" /v ProxyEnable /t REG_DWORD /d 0 /f
However the only way to make them work is to open up Internet Options and open up the LAN Settings tab.
The changes are made, but it's as if they aren't being applied/saved.
Is there a way I can do this through a command etc.

To apply change in registry for enable and disable the proxy in Internet Explorer from command line you have Two way.
First way:
1- Run command line As Administrator
2- Terminate Internet Explorer before change your registry.
Taskkill /F /IM iexplore.exe
3- change the proxy enable or disable from registry as you did in your question.
second way :
1- Run command line as administrator
2- Change proxy enable/disable as you did in your question
3- Terminate the windows Explorer and then Reopen after you change registry Already
taskkill /F /IM explorer.exe && start /w /b explorer.exe

In my case Internet Explorer is disabled so terminating iexplore.exe first is not possible as it's not runnung, and restarting explorer.exe each time is undesirable. But I have found out that at least in Windows 7 proxy settings refresh the moment you click OK in the 'LAN settings' window inside Internet Options.
As I was unable to find any other way to do this using command prompt, I wrote a simple AutoHotkey script that clicks all the necessary buttons automatically. The only downside is that this happens in the foreground, changing window focus, and there is no way to minimize or hide this that I'm aware of.
Enter this in run/command prompt or add to a bat file to open Internet Options window:
control /name Microsoft.InternetOptions
Run this AHK script before opening Internet Options window because script waits for the window to appear and may not work if the window already exists:
; wait for 'Internet Options' window to appear
WinWait, Internet Properties
; delays should account for any interface lag. Increase them if you find them insufficient for your particular case
Sleep 100
; focus on 'Internet Options' window, just in case focus is stolen by other window
WinWaitActive, Internet Properties
Sleep, 50
; hold Ctrl and press Tab 4 times to switch to 'Connections' tab
Send {Ctrl down}{tab 4}{Ctrl up}
Sleep, 250
; press Alt+l (keyboard shortcut for 'LAN Settings'). Change this if your system/user locale differs from English
send !l
Sleep, 500
; pressing enter here clicks OK in 'LAN settings' window, closing it. Using 'ControlClick OK' here results in AHK pressing OK button of the parent window instead to no effect
send {enter}
Sleep, 250
; click OK
ControlClick OK
return

Related

How to stop windows console cursors from blinking

I know how to completely hide a cursor,
But is their any way to just stop it from blinking?
It's oddly disturbing...
I'm not gonna install 3rd party software for this,
what I want is simple solution using few lines of C++.
Go to Run prompt (Win+R)
Paste into Open box:
control main.cpl keyboard
Press OK Keyboard properties dialog appears.
Set Cursor blink rate to None. Press OK
For the record, by cmd you can do the same
You can save this code as desable_cursor_blink.cmd, and click/run...
Windows Registry Editor Version 5.00; [HKEY_CURRENT_USER\Control Panel\Desktop]"CursorBlinkRate"="-1"
reg import %~f0
By command line, you also can try:
%__APPDIR__%reg add "HKCU\Control Panel\Desktop" /v CursorBlinkRate /t REG_SZ /d -1 /f

A native way to automate clicking a windows form button? (batch) [duplicate]

This question already has answers here:
How to click a button using a batch file?
(4 answers)
Closed 4 years ago.
I have a simple batch file that automates a task we do frequently. (End all internet explorer processes, open Control Panel>Internet Settings>Advanced>Reset IE). This is the code
#echo off
taskkill /F /IM iexplore.exe /T
timeout /t 2 /nobreak > NUL
rundll32.exe InetCpl.cpl,ResetIEtoDefaults
The problem is that this Windows function throws up a final approval window:
Is there a native way in the batch file to simulate pressing the Reset button, or bypassing this and just executing it? *No third party software download.
Just use SendKeys() from Windows Script Host to simulate keyboard navigation. Generically, you could send Tab or Shift+Tab to move the focus to different window controls, or Spacebar to toggle a check box or activate a button. Or if the controls you want to activate are already assigned hotkeys (usually labeled with one letter underlined), just send Alt + whatever letter is underlined. In the case of this Internet Explorer dialog you're opening, Alt+P will toggle the check box, and Alt+R will activate the Reset button. See Microsoft's SendKeys() documentation for more details.
Here's a Batch + JScript hybrid example:
#if (#CodeSection == #Batch) #then
#echo off & setlocal
2>NUL taskkill /F /IM iexplore.exe /T
timeout /t 2 /nobreak > NUL
start "" rundll32.exe InetCpl.cpl,ResetIEtoDefaults
cscript /nologo /e:Jscript "%~f0"
goto :EOF
#end // end Batch / begin JScript hybrid code
var sh = WSH.CreateObject('Wscript.Shell');
sh.AppActivate("Reset Internet Explorer Settings");
sh.SendKeys("%p%r");
Here's another example, this time calling PowerShell from a .bat script:
#echo off & setlocal
2>NUL taskkill /F /IM iexplore.exe /T
timeout /t 2 /nobreak > NUL
start "" rundll32.exe InetCpl.cpl,ResetIEtoDefaults
powershell "$sh=new-object -COM Wscript.Shell;$sh.AppActivate('Reset Internet Explorer Settings');$sh.SendKeys('%p%r')"
Of course if there's a chance your scripts will be running on a Windows installation in a different language, you'd probably need to focus the reset window by its HWND rather than its title. That's a subject for another lesson, though.

In Powershell, how can I prevent my insert key status from turning to "overwrite" every time I run a command?

First off, I know this is not default behavior. In fact, I've never seen anything like this happen and I'm a long time Powershell user.
I have no problems with the Insert key in any other application. However, in Powershell, its initial state is off, or "overwrite" - which is barely if every used anymore. When I press Insert to turn it on and run a command, it then turns back off.
This has become overwhelmingly frustrating as I frequently press Up Arrow to go to the previous command to edit it, and find that it's in overwrite mode and it really messes me up.
I googled and found nothing, so I decided screw it, I'm getting a new work PC soon anyhow, so I'll just get in the habit of hitting Insert every time I press Enter. Works fine - until I switch PCs and now at home I've been hitting Insert by habit and driving myself nuts.
This behavior happens in all Powershell windows - 64-bit, inside VSCode, etc.
On demand answer:
Check the InsertMode value in HKCU\Console registry key (and all subkeys). If present, then the value should be 1 for most console prompt-like programs, e.g. as follows (output truncated for brief: removed Ubuntu and multiple Command Prompt):
^^> reg query HKCU\Console /V InsertMode /S
HKEY_CURRENT_USER\Console
InsertMode REG_DWORD 0x1
HKEY_CURRENT_USER\Console\Command Prompt
InsertMode REG_DWORD 0x1
HKEY_CURRENT_USER\Console\powershell
InsertMode REG_DWORD 0x1
HKEY_CURRENT_USER\Console\Windows PowerShell
InsertMode REG_DWORD 0x1
HKEY_CURRENT_USER\Console\Windows PowerShell (x86)
InsertMode REG_DWORD 0x1
End of search: 9 match(es) found.
You'll probably want to go to the PowerShell properties to make sure that the Insert Mode is checked (set on) at the Options tab.
%APPDATA%\Microsoft\Windows\Start Menu\Programs\Windows PowerShell\ folder seems to be the right place where the Windows PowerShell.lnk shortcut is used to be saved. However, there could be more PowerShell shortcuts. Check
where.exe /R "%USERPROFILE%" *Powershell*.lnk|findstr /V /C:"Shell ISE"
or even (run from an elevated command prompt)
2>NUL where.exe /R C:\ *Powershell*.lnk|findstr /V /C:"Shell ISE"

Windows 10 System settings using CMD

Can you change windows 10 system settings using cmd.
I try to make a batch file that change the Windows settings how i want them.
Eexample : my screen is 100% and i want to make my screen 125% can i use a commannd for that ?
i was just wondering if its possible to change windows user options using a batch file. doesnt matter if its the monitor or other windows settings.
Various Windows settings are controlled by Registry keys. You can find the right key for your particular setting by Google search. As an example, to change DPI scaling to 150%, save this script to test.bat, run from open Admin Cmd Prompt, then re-login:
#echo off
reg add "HKCU\Control Panel\Desktop" /v LogPixels /t reg_dword /d 144
exit /b

Start->Run Dialog - "Run as Administrator" checkbox?

I'm trying to find if there's a registry key to enable the "Run as Administrator" checkbox on the Start->Run Dialog in Windows 7 (similar to the "Run in Seperate Memory Space" checkbox which can be enabled in the registry). At a couple of sites I remember I had this option, however on my current PC it's not enabled/visible.
If you know of a way to enable this checkbox via registry, or if it's available by a 3rd-party toolkit, please point me in the right direction?
I already know how to create a shortcut and set "Run as Administrator" on a specific application, and the "runas" command, I'm looking to enable the checkbox in the Start->Run command specifically in this instance.
Thanks.
Disabling UAC will give that option
To disable:
reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA /t REG_DWORD /d 0 /f
To re-enable
reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA /t REG_DWORD /d 1 /f
After restarting you will see the run box with admin privilege

Resources