How Symfony did its command alias? - windows

Apologies my french english ...
I would like to create an alias in Windows XP cmd, like Symfony.
This code works perfectly, but resets every system boot :
doskey kCLI= php C:\wamp\www\KinkamaCLI\KinkamaCLI.php
I tryed to put a .bat in "start" folder, but I think it's not beautifull, and I feel it doesn't work, because I can't see the generate batch file :
echo doskey kCLI= php C:\wamp\www\KinkamaCLI\KinkamaCLI.php >> C:\Documents and Settings\sartois\Menu Démarrer\Programmes\Démarrage\kCLI.bat
I would to create a permanent alias. Enter :
kCLI my-command-here
And not :
php C:\wamp\www\KinkamaCLI\KinkamaCLI.php my-command-here

I don't know how symfony proceed, but may be you should check your %PATH% environment variable and add this new path. Check http://support.microsoft.com/kb/310519 on how to modify this variable.

cmd.exe has support for running a list of commands at startup, add your doskey command to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor\AutoRun (Note that it is possible to start cmd.exe with /D to skip the autorun entry. I have also seen problems with doskey.exe crashing in 3rd party apps when autorun entry is parsed)

Related

Windows command prompt custom commands

I am looking for a way to customise some of the Windows command prompt (cmd.exe) commands. I would like the new command to be called instead of the one defined by Windows to do almost the same thing except some minor customisations. An example could be with the pushd command print a message saying which directory is changing to. This could be useful, for example, to have the output a .bat script parsed by another tool.
As an example, pushd.bat would look like:
#echo off
pushd %1
echo Entering directory `%cd%'
...but where should I put this so that it gets called instead of the internal command pushd?
You should not customize internal commands because some of these commands go all the way back to DOS and have hidden bugs and features that some tools might rely on and it is unlikely that you will implement them correctly.
You can add custom aliases with doskey. These are better than batch files. They allow you to add certain mini scripts that help you in your daily command line usage. These can actually override the names of internal commands.
doskey pushd=echo Entering $*^&pushd $*
pushd c:\Windows
You can add your doskey commands to HKCU\Software\Microsoft\Command Processor\AutoRun in the registry but you really need to be careful if you use it to change existing commands. I recommend that you invent new names for your commands.

Windows CMD interpret code following alias

Is it possible to get windows process some code after an alias in the cmd? Basically I want to do sth. like this:
doskey mysvn = D:\portableSVN\bin\svn.exe --config-dir D:\portableSVN\config
mysvn up
mysvn ci -m "message"
This does not work, after interpreting mysvn it just stops and I get:
Subcommand argument required
Type 'svn help' for usage.
Currently, I modify the PATHfor the session and use the standard config folder, but I would rather not have my credentials and proxy settings on every pc I use my portable svn on. Of course I can delete them afterwards, but still they are recoverable.
If necessary, it is also possible to execute batch files as long as they don't need admin rights.
Try with
doskey mysvn=D:\portableSVN\bin\svn.exe --config-dir D:\portableSVN\config $*
See doskey /? for more information

Adding doskey for an application in windows8

Please guide me as to how to add persistent doskey for an application in windows 8.
Also tell me how those doskey can be made to work in git bash?
All I know is how to make temporary doskey as
#doskey ls=dir
And in git I know of aliases as
alias dir=ls
You can edit your registry key HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun to run a batch file everytime cmd.exe runs. If you add your doskey commands into that batchfile then every cmd.exe instance will have your doskeys setup.
See my post for more info: http://www.declancook.com/aliases-in-windows-command-prompt/
doskey will load and work in a cmd.exe window.
It is not designed to work within other applications.

"edit" not a valid command in cmd.exe?

I'm trying to create a .cfg file for bcc32 compiler and I'm following the instructions. I have installed correctly and placed an environment path as instructed but when I type "edit bcc32.cfg" into the command prompt it says that edit isn't a valid command? What am I supposed to do?
You could also create a .bat file, edit.bat, to replace the 16-bit edit program (removed because x64 windows flavors won't run it) which would launch your favorite editor.
#echo off
notepad %1
#echo on
This is what I wound up doing as a simple patch so I could carry on the way I always had for the most part. Just type:
edit myfile.ext
in the command prompt to use it.
Note: notepad is not my favorite editor - this is just an example that will work with stock windows.
Note 2: #echo off and #echo on are shown for clarity. You may also shorten this by omitting the echo statements and simply placing the # before the command to be silenced.
#notepad %1
I just use notepad (since they took out the edit command) from the command window like so:
C:\Borland\BCC55\bin> notepad bcc32.cfg
The file will open in notepad for editing. When you've finished editing the file, save it and you're done.
I have found this works for seeing in-window text of a complete file, on a 64bit machine. Once your path is set in cmd prompt, type the word type... followed by "filename" do you see how I used the quotes around the filename only!
type "filename"
You type it just like this (changing filename for your files name) and you will be able to see the entire file text in the cmd window. Not sure how to edit from here on but maybe someone can figure it out from here and tell me.
Assuming you're using Windows 7 (where edit.exe and edlin.exe have been removed):
Use powershell.exe instead of cmd - thereby edit will be available via command line.
Take a look at: http://en.wikipedia.org/wiki/Windows_PowerShell
simple answer....
if your using an old version of windows (xp e.t.c...) you would be able to use edit
but since your using new version of windows, Microsoft has updated and removed the commands that they think are not relevant e.g.. (msg, edit) depending if its a bit32 bit64 or bit82...

Porting shell functions to cmd.exe: Is it possible to automatically source scripts on startup?

I'm porting a Linux tool-set that makes frequent use of shell functions to provide certain functionality. These functions are automatically sourced when you start a new shell and include things like changing the working directory, which is nigh impossible with stand-alone programs because child processes can't change their parent's environment.
For example, there is a function cdbm which changes the working directory to one that was previously bookmarked. Now I want to do the same on Windows, but I'm stuck with cmd.exe. As far as I understand the scripts could be ported to jscript, vbscript or plain batch, which shouldn't be a problem. But how do I make sure they automatically get sourced on startup and live in the shell's environment?
According to help cmd:
If /D was NOT specified on the command line, then when CMD.EXE starts, it
looks for the following REG_SZ/REG_EXPAND_SZ registry variables, and if
either or both are present, they are executed first.
HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun
and/or
HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun
As a test, in regedit I created a new key in the HLM branch shown above called "AutoRun" with the string value "echo Hi". When I started a new instance of cmd I got:
Microsoft Windows [Version 6.0.6000]
Copyright (c) 2006 Microsoft Corporation. All rights reserved.
Hi
C:\Users\Username>
You could put in the name of a script to run instead (I would put in a fully specified path to the script or one with a environment variable in it like "%HOMEPATH%\scripts\scriptname" (including the quotes in case there are spaces in the name).
Edit:
The registry key has some side effects. One example is help. If I have the echo command above, for example, in the AutoRun when I type help vol I get a "Hi" right above the help text. Doing vol /?, though doesn't do that.
You can set either of the following registry keys to a batch file or other executable to run that program when CMD is started:
HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun
HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun
A batch file should be able to change the current directory of the executing CMD process with the CD command, as it doesn't run as a subprocess. You can disable the autorun behaviour by supplying /D as a switch to CMD.
See CMD /? for more details.
Since cmd doesn't allow you to define functions in global scope, I'm a little at a loss to understand what exactly you're trying to achieve by auto-sourcing a script at startup. I tend to include a batch file directory in my path where you can put batch files I regularly need.
Look at cygwin.

Resources