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".
Related
I have a folder on a remote computer containing security camera video footage. I want to only search the *.mp4 files for those that are created between 2300 and 0600. The code:
$root = "F:\ispy\video\SWVL"
(Get-ChildItem -Path $root) | Where-Object {$_.lastWriteTime.TimeOfDay.Hours -gt 23 -or $_.LastWriteTime.TimeOfDay.Hours -lt 06} | ls | Out-GridView -PassThru
Does this perfectly, and passes the output (file list) to a PowerShell gridview.... BUT, I need the out to show the files in Windows Explorer.
I'm essentially trying to use a PowerShell script as an advanced search filter.
Hoping someone has some ideas. Eventually, I'm planning to use this as a flow -somehow- in power automate and power apps.... but need to crack this first part.
Thanks,
Gregg
AZ
Your use case is not valid. Windows Explorer
You can, in your script, do something like this.. (dropping the call to Out-GridView as it's not needed for your end results)
# find those files
Get-ChildItem -Path 'F:\ispy\video\SWVL' |
Where-Object {
$PSItem.lastWriteTime.TimeOfDay.Hours -gt 23 -or
$PSItem.LastWriteTime.TimeOfDay.Hours -lt 06} |
# copy them to a temp location
Copy-Item -Destination 'SomeTempPath' -Verbose
# open explorer in that location
Invoke-Item -Path 'SomeTempPath'
... then delete that location when you are done.
Windows Explorer-specific search/filtering is only possible in Windows Explorer. So, that means you can only search to get a specific property, then use GUI automation to send that to the Windows Explorer search box.
Otherwise, just skip the script and know this to avoid overcomplicating what you are after.
In Windows Explorer, you can filter the files by date in File Explorer using the date: keyword. You can use this keyword to find files created before, on or after a certain date. You can use the “>” and “<” signs to find files created after or before the given date. “>=” and “<=” also apply here. While you can manually type the date, File Explorer provides a simple calendar that will show up every time you type date: on the search box.
In a script, you'd have to duplicate the aforementioned. Thus capturing the date in your search, opening Windows Explorer and using SendKeys or AutoIT to select the search box and paste the info then sending enter.
Update as per my comment regarding the pop-up calendar. You can do this, in Windows Explorer to filter by date/date ranges
Manually type it in manually, which of course you could GUI automate via SendKeys or AutoIT.
Click the down arrow on any date column.
In the built-in Windows Sandbox on the latest WinOS builds, the popup still works from the Windows Explorer searchbox.
... but not on other host systems.
Update as per our last comments ...
Yet, if you are really trying to send to the Explore serachbox, then this kludge can do it,...
Start-Process -FilePath 'Explorer' 'd:\temp'
Add-Type -AssemblyName System.Windows.Forms
Start-Sleep -Seconds 2
[System.Windows.Forms.SendKeys]::SendWait('+{TAB}'*2)
[System.Windows.Forms.SendKeys]::SendWait('date: 04-Apr-20..11-Jan-21')
Start-Sleep -Seconds 1
[System.Windows.Forms.SendKeys]::SendWait('{Enter}')
... but warning SendKeys is quirky, timing-wise, etc. Sometimes is works, sometimes it does not.
I am having trouble adding *.amazonaws.com to the trusted sites in Internet Explorer 11 (I am using the default browser shipped with Windows Server 2019)
I had tried the following combinations too, with the same error result:
*.amazonaws.com
*.amazonaws.*
*://*.amazonaws.com
http://*.amazonaws.com
https://*.amazonaws.com
etc
Since Internet Explorer is being difficult, I wanted to circumvent this by just adding the registry keys manually via PowerShell, using the following:
Set-Location "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
Set-Location "ZoneMap\EscDomains"
New-Item "amazonaws.com"
Set-Location "amazonaws.com"
New-ItemProperty . -Name * -Value 2 -Type DWORD
This doesn't seem to produce the correct output...
Not sure what I did wrong?
I also submitted the bug to the Microsoft Community here.
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"
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')\""
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.