I'm trying to place the taskbar location to the top with powershell and let it auto-hide.
I found this website with option three what works for most people. The only problem is I'm trying to get this fixed in Windows 10 build 14393.
https://www.sevenforums.com/tutorials/1066-taskbar-move-location-desktop-screen.html
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects2]
I came across one forum who told that it was changing a registry value. I tried to do so but it didn't work. When I changed the location to the top, I looked in the regedit again and the same value was still here.
Does anyone know the location of where the registry key is stored in?
$RegKey = "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\StuckRects2"
$RegName = "Settings"
Set-ItemProperty -Path $RegKey -Name $RegName -Value $RegValue
Does anyone knows what I need to change?
A PS Script to toggle taskbar top or bottom, restarts Explorer in the process.
$RegistryPath = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects3'
$Name = "Settings"
$NewValue = Get-ItemProperty -Path $RegistryPath
$NewValue.Settings[12] = 4-$NewValue.Settings[12]
Set-ItemProperty -Path $RegistryPath -Name $Name -Value $NewValue.Settings
Stop-Process -Name "Explorer"
Related
I am trying to delete a binary value within my registry with this code the code prompts an error stating the value at DefaultConnectionSettings does exist but it's able to find the SID path, but not the exact DefaultConnectionSettings Value. I'm running this script on a test machine that has the DefaultConnectionSettings.
RegEdit.exe screenshot
Any input would be helpful Thanks,
if (!(Test-Path 'HKU:\')) {
New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS
}
($path = Get-ChildItem -Path 'HKU:\*\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections' -ErrorAction SilentlyContinue) |
ForEach-Object { Remove-ItemProperty -Path $path -name "DefaultConnectionSettings" -force }
The registry value you're trying to delete is a value of the registry::HKEY_USERS\*\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections registry keys themselves.
Note that you can target the HKEY_USERS hive simply by prepending the provider prefix registry:: to the native registry path - no need to map a new drive with New-PSDrive first.
By contrast, Get-ChildItem looks for subkeys of the targeted keys.
Note that registry values are considered properties of registry keys, not child items (the way that files are in the file-system).
Thus, the immediate fix is to switch from Get-ChildItem to Get-Item, which returns objects representing the target keys themselves.
However, you can do it all with a single Remove-ItemProperty call (as with your own attempt, running from an elevated session is assumed):
$path = 'registry::HKEY_USERS\*\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections'
Remove-ItemProperty -WhatIf -Force -Path $path -Name DefaultConnectionSettings -ErrorAction SilentlyContinue
Note: The -WhatIf common parameter in the command above previews the operation. Remove -WhatIf once you're sure the operation will do what you want.
I want align the taskbar of windows 11 to the left side using PowerShell.
I did this:
New-ItemProperty "HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "TaskbarAl" -Value "0" -PropertyType Dword
I review and the value was changed but the taskbar don't move.
I don't know why but with Powershell I could not did it. Finally I did with "reg add".
I'd like to add a Windows right-click menu entry to quickly open text files in WSL Vim, without manually opening up a terminal.
Thanks #romainl.
Create a registry key at Computer\HKEY_CLASSES_ROOT\*\shell named Open in Vim, and a subkey for it as command:
Computer\HKEY_CLASSES_ROOT\*\shell\Open in Vim
Computer\HKEY_CLASSES_ROOT\*\shell\Open in Vim\command
Edit the string value of the command\(Default) as bash.exe -c "wslpath '%1' | xargs nvim" (alternatively, you can substitute nvim with vim).
Download a Vim logo which you can convert online to an .ico extension. Create an Icon string value under the Open in Vim key, and edit its value with the path of the .ico image.
You can see the resulting entry below. Clicking on it would open up a WSL terminal with the selected textfile opened in Vim. Upon exitting Vim, the terminal closes, too.
Add an item to the context menu to open a file in WSL VIM with PowerShell:
New-Item -Path 'Registry::HKEY_CLASSES_ROOT\*\shell\VIM\command' -Force | Out-Null;
Set-ItemProperty -Path 'Registry::HKEY_CLASSES_ROOT\`*\shell\VIM' -Name '(default)' -Value 'Open in VIM' -Force | Out-Null;
Set-ItemProperty -Path 'Registry::HKEY_CLASSES_ROOT\`*\shell\VIM' -Name 'Icon' -Value 'C:\Windows\System32\wsl.exe,0' -Force | Out-Null;
Set-ItemProperty -Path 'Registry::HKEY_CLASSES_ROOT\`*\shell\VIM\command' -Name '(default)' -Value "wsl vim -p `"`$(wslpath '%1')`"" -Force | Out-Null;
Or use a registry file as an alternative.
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\*\shell\VIM\command]
#="wsl sudo vim -p \"$(wslpath '%1')\""
During the course of day I often have to turn on and off "Use automatic configuration script" option in proxy settings to access web destinations that are otherwise blocked and vice versa. In other words, this checkbox:
I found that it changes AutoConfigURL property in HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings. When checkbox is on, the property is set to configuration script URL, when it's off the property is removed. So I wrote a simple PowerShell script to do the job:
$regKey = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
$propertyName = "AutoConfigURL"
$configurationScript = "http://example.com/config.dat"
$proxyStatus = (Get-ItemProperty -Path $regKey -ErrorAction SilentlyContinue).$propertyName
If ([string]::IsNullOrEmpty($proxyStatus)) {
Set-ItemProperty -Path $regKey -Name $propertyName -Value $configurationScript
} Else {
Remove-ItemProperty -Path $regKey -Name $propertyName
}
It changes the registry the way I need, however these changes have no effect. I need to open the LAN settings window under Internet properties / Connections and only then my proxy settings are changed (I don't even need to press OK or Cancel buttons, just open the window).
Are there any additional commands that should be executed after making changes to the registry to apply changes?
I found the answer to your question in the below Powershell script (It's a nicely written script).
https://github.com/majkinetor/posh/blob/master/MM_Network/Update-Proxy.ps1
This script actually forces/refreshes the internet settings. The above script refers to the msdn forum, where C# solution was mentioned.
https://social.msdn.microsoft.com/Forums/vstudio/en-US/19517edf-8348-438a-a3da-5fbe7a46b61a/how-to-change-global-windows-proxy-using-c-net-with-immediate-effect?forum=csharpgeneral
I use cygwin version of gvim to edit files in windows, for that I created a bat script that opens a file with cygwin version of gvim(by converting the path to cygwin format). I also wrote a small powershell script to register this bat script with windows explorer so I can associate file extensions using the 'open with' context menu. Here is the script:
$ErrorActionPreference = "Stop"
$classes="hkcu:\software\classes"
$appid="cygwin.gvim"
$apps="$classes\applications"
$cmd='...SOMEDIRECTORY...\edit-gvim.bat'
$friendlyname='gVim (Cygwin)'
$icon='...ANOTHERDIRECTORY...\vim.ico'
$filetypes=#(".txt", ".ps1", ".sh", ".py", ".cs", ".cpp", ".c", ".rb",
".zsh", ".bash", ".vbox", ".xml", ".yml", ".yaml", ".bat")
if (test-path "$apps\$appid") {
# cleanup
remove-item -recurse "$apps\$appid"
}
# register open commands to know filetypes
new-item -path "$apps\$appid\shell\open\command" -value "$cmd `"%1`"" -force
# add a context menu item(edit with gVim) to every file in windows explorer
new-item -path "$classes\*\shell\Edit with $friendlyname\command" -value "$cmd `"%1`"" -force
# friendly name for the 'open with' dialog
new-itemproperty -path "$apps\$appid\shell\open" -name 'FriendlyAppName' -value $friendlyname
# register the icon
# FIXME this has no effect
new-item -path "$apps\$appid\DefaultIcon" -value $icon -type expandstring
# register supported file extensions
new-item -path "$apps\$appid\SupportedTypes"
foreach ($ext in $filetypes) {
new-itemproperty -path "$apps\$appid\SupportedTypes" -name $ext -PropertyType string -value ''
}
Everything works except the line below the 'FIXME' comment, which aparently has no effect. Instead of seeing my provided icon with applications associated with gvim, I see windows default icon for unknown file types. What am I missing here?
Here are some resources I used to write this script:
http://msdn.microsoft.com/en-us/library/windows/desktop/ee872121(v=vs.85).aspx
http://msdn.microsoft.com/en-us/library/cc144158(VS.85).aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/cc144101(v=vs.85).aspx
Create registry entry to associate file extension with application in C++
I can make a mistake, but as far as I understand the syntax of DefaultIcon is :
"Full path to a file,ordinal"
This is usefull when you want to point to a resource in an EXE or a DLL
C:\Program Files (x86)\PowerGUI\ScriptEditor.exe,1
But you have to keep the same syntax if you want to point to an icon file :
[HKEY_CLASSES_ROOT\AcroExch.acrobatsecuritysettings.1\DefaultIcon]
#="C:\\Windows\\Installer\\{AC76BA86-7AD7-1036-7B44-A95000000001}\\PDFFile_8.ico,0"
So, in your case, I would try :
$icon='...ANOTHERDIRECTORY...\vim.ico,0'
or
$icon='...ANOTHERDIRECTORY...\\vim.ico,0'
Edited
Don't forget to restart explroer.exe to see the new icon.