I have successfully modified the common attributes of a a shortcut using Powershell; things like changing the icon, setting it to run elevated, etc.
But, in the case of a shortcut to PowerShell itself, that passes a script as an argument, there are some more attributes in the Layout tab of properties, and I would like to be able to modify those attributes as well.
But I can't seem to find any reference to how to get at them.
FWIW, I have been using PS to do this programmatically like this, but I find it problematic when used across different OSs and different versions of PowerShell. So, looking at alternatives.
Related
I try to find out, if it is possible to implement for example 3 different
functionalities within one Cmdlet.
For example: I use one Cmdlet that can change the Windows Desktop Picture, ADD a Shortcut to the Windows Desktop or remove one or more files from somewhere.
Depending on my use of this Cmdlet and my input.
The goal is to only have one command with different possibilities to use for.
I tried of course a search engine and I searched here. But also, I am not really sure what Im searching for other than my summarize title.
In Microsoft Dokumentation and in this Forum it is written, a cmdlet is for a single function. But when I can convert C# Code into a Cmdlet, then why is it not possible to choose between different functionalities within one Cmdlet?
I would be very happy to receive an answer. Thank you very much.
I use auto-complete heavily...
When I invoke the auto-completion with tab key...
Powershell also includes any files from the current folder
or in the current path in the autocomplete list
How can I configure Powershell to ignore these files
(eg. auto-complete only with Powershell commands/functions)
There is no simple way to get the behavior you're looking for.
At best, you can define your own function named TabExpansion2 and either fully implement tab completion yourself (definitely not recommended) or filter the results returned from the default implementation of TabExpansion2.
I recall discussing this idea recently, I thought there might even be an open issue, but I didn't see it after a quick search here.
I don't know the exact history, but at one point we did implement the behavior you're wanting. It did break some tests, and I think some people preferred seeing effectively useless completions over no completions, perhaps it was reassuring that completions were still working.
At any rate, I think it's a reasonable feature request, I'd suggestion opening an issue if you can't find one.
Is there a way to identify which shortcut was used to launch a script? Something that doesn't require any modification of the shortcut itself?
I know I can get the path of the script itself, but I can't seem to find a way to get the shortcut.
The need is because I am using different shortcut icons depending certain arguments present in the shortcut, and while I have a utility that processes all the shortcuts present, this utility doesn't get used all the time. I would like to be able to check each individual shortcut on use as well.
When I click the Windows button, I can type the name of an app and get completions in the menu to quickly find an app and run it.
But it looks like with PowerShell I must add the app's path to $ENV:Path which is very cumbersome to do per app. Is there a better way?
Kind of, but not really. PowerShell's tab completion function searches the current folder, known cmdlet names, and folders in the user and system path. Unless you want to rewrite the tab completion function yourself (which is possible, see PowerTab) you're stuck with that functionality.
You should be able to use Start-Process (alias start and saps), which does use some file association information similar to the Start Menu. However, you need to know the name of the application executable, not the friendly name you'd see on the Start Menu. You can't type Start-Process word. You'd have to say Start-Process winword, because the executable is winword.exe.
PowerShell is a modern command line, but it's still a command line. It doesn't help the user the same way the Windows search does because it doesn't make the same assumptions. PowerShell assumes you'll predominantly want to work with cmdlets, and that's really how most people use it, IMX. Unless you're managing servers, it's not meant to replace the GUI.
You can use tab completion with the folder names and the call operator, so you could type C:\Pro and hit tab and it will expand to (for example) & 'C:\Program Files\'. Note that it includes the call operator (&) for you here automatically, since the provider for file systems assumes you'll want it.
A trick I use is to create a batch file for things I use a lot from the command line and put that in a c:\tools folder, which is in my system path.
That way you don't have to add every executable to your path so it can find it with autocomplete.
I'm running Console2, which I believe is just an interface to windows cmd
I have a custom batch file that does most of my dirty work for me, but there are lot of commands in it now. Is there a way I can get a tap autocomplete working for it in the windows command prompt?
For example: my script is called rob.bat and it takes in a various number of arguments
It'd like to type rob set{Tab} and then have it cycle through
setup_envvars
setup_userprefs
setup_whateverothersetupscriptsIhave
Is there a way to do this?
Console2 has no special provisions for tab completion and instead relies on the program running within it to provide such features. Picture Console2 as little more than something that runs a console program hidden somewhere, regularly polls that hidden window for changes, and forwards all input to that window; this is, in essence, what's happening.
Note that Console2 does nothing special with cmd. You can run any shell within it. As for customizing tab completion, cmd offers nothing of that sort. You may be able to change this by installing clink, which has extension points for Lua code. Another option would be PowerShell, which has customizable tab completion out of the box, either by wrapping your program in a function that provides the necessary parameters, or by writing a custom TabExpansion or TabExpansion2 function.