PowerShell Setting up a folder to open in - powershell

My teacher gave me this instruction : "To set-up the default folder for PowerShell to open in, right click the PowerShell icon in the tool tray and select Properties. In the Properties dialog box and in the Start in: text box enter the path to the new directory “C:\Users\Administrator\MyScripts”, then click OK."
However when I go into the properties tab I do not see what he is talking about :( .
This is what I see:
How do I I Do what he wants?

Your teacher is asking you to change the properties of the executable. You are currently looking at the PowerShell console properties.
As you can partially see mine is located:
%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe

By "tool tray" I assume your teacher meant the Windows taskbar and by "to set-up" I assume he/she meant "to set up"1:
If you:
right-click the PowerShell icon in the taskbar, you get a shortcut menu,
in which you can right-click the first entry in the last section to edit the properties of the shortcut file that started the application:
The resulting dialog will show you the desired Start in: field, which determines that shortcut file's startup folder:
Enter the desired startup folder (C:\Users\Administrator\MyScripts in your case), and click OK.
To determine the shortcut file's own location, switch to the General tab of the dialog and inspect the Location: field.
If you haven't yet pinned PowerShell to your taskbar, the Location: field probably contains C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Windows PowerShell.
The shortcut file's own name is Windows PowerShell.lnk, though the .lnk extension is typically hidden.
In other words: by default, the shortcut file's full path is C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Windows PowerShell\Windows PowerShell.lnk.
In general, shortcut files (*.lnk) store properties such as executable location, startup folder, initial window state, and shortcut key.
As for what you've tried:
As Matt states in his answer, you've invoked the Properties dialog for the open PowerShell console window via its system menu (windows menu), which allows you to persistently change window properties, but not the startup folder.
1 "To set up" is a phrasal verb - no punctuation needed, and not to be confused with the noun derived from it, "setup".

Related

Differences between blue background and black background PowerShell

I'm wondering why the background of the PowerShell is different when I open it from Run (or Start) and from the shortcut on desktop PowerShell.exe. In the first case the background is blue, in the latter case it's black.
Are there other differences between the two windows of the PowerShell?
EDIT
EDIT 2: in the figure below you can see the powershell processes. Moreover, if I open powershell.exe directly from C:\Windows\System32\WindowsPowerShell\v1.0, the background is blue instead of black (remember that its link on desktop opens a black background powershell).
Regarding the below figure, both processes powershell.exe and Windows PowerShell are located in C:\Windows\System32\WindowsPowerShell\v1.0.
P.S.: the situation described here is the same on Windows 10 and 7.
EDIT 3
If I go in the folder C:\Windows\System32\WindowsPowerShell\v1.0 and I right click on powershell.exe, there isn't the tab Colours, but its link on Desktop has the tab Colours.
Are there other differences between the two windows of the PowerShell?
Probably yes but it's likely to be on the same level. (e.g. from your screenshot the blue console is wider so probably has a higher Width layout setting).
afaics it looks they're both the same powershell.exe with different host settings. But only you can confirm.
How to check if they're the same "PowerShell"
Open Task Manager > Details tab.
You should see 2 processes with name powershell.exe.
Right click > Properties and look at the Location
I suspect they're both C:\Windows\System32\WindowsPowerShell\v1.0
Why is one black and the other blue?
Right click on desktop shortcut > Properties > Colours
These settings are applied when you open PowerShell using this shortcut.
You can do the same for the Windows PowerShell shortcut in the start menu.
(You may have to right click > Open file location to get to the actual shortcut)
For Run > powershell.exe, it's using the settings in the registry as described here.
Edit: So running the powershell.exe directly uses the settings stored in the registry at path HKEY_CURRENT_USER\Console\%SystemRoot%_System32_WindowsPowerShell_v1.0_powershell.exe. Copying and pasting a shortcut does not copy these settings because they are not stored in the exe. I believe but am I not certain that shortcuts will use the settings in HKEY_CURRENT_USER\Console\ by default. You need to edit the properties to change the settings for the shortcut. You could edit them in the registry but this seems like a bad idea as it's not just used by PowerShell.
Related stuff
You can change the defaults in the Properties above.
Options, Font and Layout settings may also differ.
You can see the values for the current console (including run > powershell.exe) by clicking on the PowerShell logo in the top left and going to Properties
related links: $Host, Get-Host and (if using PSReadLine module) Get-PSReadLineOption, Set-PSReadLineOption

Windows Powershell and Command Prompt Issue on Windows 10 OS

I have two queries that needs to be resolved.
How can I resize Windows Powershell to a considerable size in Windows 10? I have already tried using the Properties options and via ** Layout**.
But the moment I re-launch it, the window size goes to an in-proportionate size. (Please check the image attached for this query)
P.S - I also browsed Stack-overflow and found this link - [https://superuser.com/questions/68013/how-can-i-set-the-powershell-default-window-size-in-windows-7] but wasn't able to eliminate the issue. :(
Image - 1: In-proportionate size of Windows Powershell
Other than query #1, I also want to know - when I try to open cmd window in a particular folder, I am not able to see the option reading open cmd window here in the context sensitive menu. For quick reference, I am also attaching one image for this query.
Image - 2: No option to open Command Prompt via context-sensitive menu.
P.S: I am getting the option to open Windows Powershell in the above image
I earnestly request the experts here to guide me on these two queries so that I can use both Windows Powershell and Command Prompt without worrying about the size of the window every time.
I look forward to some quick guidance.
Regards.
You can set it in the properties on Powershell window.
After,
When you reopen Powershell, these settings will be saved. Tune Window Position values as well as needed.
For your 2nd issue, read on this link - https://fossbytes.com/powershell-replaces-command-prompt-windows/
If you aren’t ready to accept this change and ditch Command Prompt,
you can opt out of the WIN+X change. To do this, open Settings >
Personalization > Taskbar. Now, turn the “Replace Command Prompt with
Windows PowerShell in the menu when I right-click the Start button or
press Windows key+X” option to “Off”.
As for this...
open cmd window here in the context sensitive
Option:
You can just select any directory and click the Explorer search bar and type cmd or powershell or pwsh (v6 if you have it installed) and it will start in that directory; As long as you don't have directory configured in you PowerShell profile.
You can add thing to the context menu using the Registry editor
See instructions here:
Add the Command Prompt to the Windows Explorer Right-Click Menu
A hidden functionality in Windows allows you to right click on a directory, and select “Command Prompt Here” from the menu.
https://www.howtogeek.com/howto/windows/add-the-command-prompt-to-the-windows-explorer-right-click-menu
Just as you can for PowerShell
Add PowerShell to Windows Explorer Context Menu in Windows 10
Ever since the days of Windows Vista, it was possible to use Windows Explorer’s context menu to quickly open a command prompt window to a specific location by holding the shift key and right-clicking a folder. The “Open Command Prompt Here” appeared, allowing you to open the command prompt in the folder of your choice.
https://www.petri.com/add-powershell-windows-explorer-context-menu-windows-10
BTW, you can add anything you wish to your SendTo menu as well, just by copying the short cut there, and then that too will show up in the explore context menu for use.
As far as your PowerShell Window being overly large/small. Of course the is not the default and something / someone did that. I seen that, but never had it happen to me.
Have you made a lot of customizations?
Is this only happen in your logged on session, vs other users of the system?
So, are you saying also, you cannot resize the Window using your mouse to another size?
Try this first.
Exit the console host.
Open the PowerShell_ISE
Reset the defaults there using these commands
$PSise.Options.RestoreDefaults()
$PSise.Options.RestoreDefaultConsoleTokenColors()
$PSise.Options.RestoreDefaultTokenColors()
$PSise.Options.RestoreDefaultXMLTokenColors()
Next start the console host from the ISE by clicking the console host icon in the toolbar.
Try and work the properties from there, then close and reopen the console host form the ISE to see if the settings stayed.
Then open the console host from whatever shortcut you normally use and see if the changes remained.
If that does not reposition / resize the console windows then this is Windows proper causing this. Similar to a Window being off screen that you can't get to.
Then right click an open space on the taskbar and select Cascade windows.
If that does not work use the move option from the Taskbar.
Use Shift+Tab to select the console Windows.
Shift+RightClick the taskbar icon of the Window and select move.
The close and check again.
Lastly, if you have not done a lot of customizations, you can grab the default PowerShell regkey from another user / profile and import that into your registry.
If you don't have another default logon to use, just create one, check PowerShell state and the get that regkey to use.
Last thing, I meant to add, if none of the above works and you don't want to take the RegKey route. Create a PowerShell console profile and add this code to it. This of course will run each time you start you console using your profile. Of course adjust as needed,
$ConsoleSettings = (Get-Host).ui.rawui
$ScreenBufferSettings = $ConsoleSettings.buffersize
$ScreenBufferSettings.height = 50
$ScreenBufferSettings.width = 120
# $ConsoleSettings.buffersize = $ScreenBufferSettings
$ScreenSizeSettings = $ConsoleSettings.windowsize
$ScreenSizeSettings.height = 50
$ScreenSizeSettings.width = 120
$ConsoleSettings.windowsize = $ScreenSizeSettings

How do I *PREVENT* a Windows batch file from executing in Eclipse?

On Windows in Eclipse, when I double click on a batch file name in navigator, or even a repo browser, the batch file opens in a command window and is executed.
How do I make the default double-click behavior to open in an editor instead?
Note that I can select "open in text editor", but if I choose "open in system editor", that too causes it to execute.
I honestly googled for this, but only found "how to run", and no explanations of "how NOT to run". I can't imagine this hasn't been asked before, but I couldn't figure out the incantation.
[Editorial comment: there are tons of references describing how to run a batch file, implying its difficult to do or figure out. Its odd that mine appears to behave that way out of the box.]
Open the Preferences and go to 'General > Editors > File Associations'.
If there is an association in the list for *.bat change the association to be 'Text Editor'.
If there is no association change the setting for 'open unassociated file' at the bottom of the preference page to be 'Text Editor'. Alternatively, if you don't want to change the 'no association' setting, add a new file association for *.bat
Note that if you have used 'Open With' on a file that choice is remembered and used in future.

How do I stop VSCode from the Side Bar moving to the folder that the current file is in?

In Visual Studio Code, whenever I close a file, the next open file becomes active in the editor and the Side Bar moves to that file's location in the folder structure. This is usually not the behavior I want. I often want to open another file in the same location as the one I just closed, but now my Side Bar has shifted around to what could be a totally different place in a large project.
I like the behavior of the main Visual Studio product where the Solution does not automatically shift. Instead, if I want to see where in the solution a file is, I can use a keyboard shortcut to move there ("Find File in Solution"), instead of automatically moving there every time the active file changes.
Is there any way to change/disable this functionality in VSCode?
The is an option explorer.autoReveal in settings (either user or workspace) which controls if the explorer should automatically reveal files when opening them.
Open VS User Settings (Preferences > User Settings). This will open two side-by-side documents.
Add a new "explorer.autoReveal": false setting to the User Settings document on the right if it's not already there. This is so you aren't editing the Default Setting directly, but instead adding to it.
Save the User Settings file.
in Version: 1.42.1
Open VS User Settings (Preferences > User Settings).
Search for "explorer auto reveal" without quotes.
Now uncheck the checkbox.
There is a new setting in v1.46 that will select the files in the explorer but not scroll to reveal them:
We have introduced a new value focusNoScroll to the
explorer.autoReveal setting. For this value Explorer will
automatically select files when opening them but will not reveal them.
from v1.46 release notes.
So that setting will highlight the active editor in the explorer but not scroll to it.

XP Start Menu Context Menu not opening folders

I'm having an issue with the "Open"/"Open All Users", "Explore"/"Explore All Users" context menu options (right click menu) for shortcut folders (such as "Accessories") under the "All Programs" list on the "Start Menu" in Windows XP Home Edition.
Performing this action is supposed to open a My Computer/Windows Explorer window browsing the selected start menu folder. Normally, double clicking a start menu folder will also "Open" a My Computer window browsing the
selected start menu folder.
Currently, these actions don't function and simply close the context menu/Start Menu without bringing up a My Computer/Windows Explorer window.
If I right click the "Start" button directly and select the corresponding options ("Open"/"Open All Users", "Explore"/"Explore All Users") a My Computer/Windows Explorer window is brought up as expected browsing "C:\Documents and Settings\Owner\Start Menu" and "C:\Documents and Settings\All Users\Start Menu" respectively.
It's caused be third part programs.
Search in the windows registry for these keys:
HKEY_CLASSES_ROOT\AllFilesystemObjects\shellex\ContextMenuHandlers
HKEY_CLASSES_ROOT*\shellex\ContextMenuHandlers
HKEY_CLASSES_ROOT\Directory\shellex\ContextMenuHandlers
HKEY_CLASSES_ROOT\Drive\shellex\ContextMenuHandlers
HKEY_CLASSES_ROOT\Folder\shellex\ContextMenuHandlers
Export all five keys (on the File Menu) (First two keys apply to files, 1st, 3rd to 5th apply to folders/drives).
Delete all two/five
Check if context menu works correctly (No need to reboot)
It is known that AVG anti virus adds a key that makes the context menu stop working.
MagicISO can be another cause.
In my experience I needed to remove MagicISO from the last key