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.
Related
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.
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.
I am trying to updating a software that is company wide. When the update is applied to the server, the client machines recognize they need an update and ask if you wish to update or not. To update, the user would need to run as admin, which is'nt an option in this case.
We would like to automate this process using powershell, using the Invoke-Command feature. For the most part, the only thing that the update does is copy new files to the programs folder, which we have achieved with robocopy. However, there is one registry key that needs to be added in multiple locations. There is a setup file that does this, but requires a user (with admin privileges) click a couple buttons, and we want this to be completely automated.
So I guess the short version of my question is, what is the best way to handle the registry changes that setup.exe does? It would be nice if there was a way to invoke the script that the executable does.
As for my question, I solved the problem with a slightly diferent approach. (One that should have been tried initially)
When (ProgramName).exe is run, if it sees that it needs updated, it runs a program called (ProgramName).setup.exe with the parameters :
Client="Local folder" server="server location"
These parameters did NOT work from the command line, however, and so I ended up using a powershell script to make a scheduled task that ran (ProgramName).setup.exe with said parameters.
Another huge advantage to this was the fact that I could create an icon that allowed a regular user to run the scheduled task with admin privileges. I couldn't setup a shortcut directly, however, I wrote an AUTO-it Executable that would run the task as admin.
I hope someone can get some level of help out of this post!
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.
I am looking to add a new item in a right click context menu for a certain file type. I suppose it would be easiest to run a batch file with the full path of the file as an argument. I need to rename the file, unzip it, then rezip it, then rename it. I suppose winzip command line would be appropriate tool to help with that, unless someone else has a suggestion.
My questions are:
- How can I add a custom context menu item based on file type
- How can I pass the file name as an argument to the batch file from the context menu
- Finally this may go out to 2-3 people, and it might be easier to simply have an installer that sets this up for them. Anyone know of any free installers that could do this?
Some details about why I am trying to do this:
I have a tool that is zipping things correctly, the program that is reading the zip files is not unzipping to standards it seems. It unzips in winzip legacy mode or something. Rather than fix a working program/investing time or attempt to do some ultra-fancy, crazy fix on a linux server for zipping into winzip legacy format a workaround seemed appropriate for now. These processes only really occur internally, but they are still painful/annoying to do.
7zip is free, you might want to use that if you need to bundle the zip utility
Customizing a Shortcut Menu Using Static Verbs
%1 in the command string in the registry is replaced with the filename
Inno Setup, NSIS or WiX