2

I often need to access some command line programs such as mysql. Is there a way to assign these programs a shortcut so I am no longer required to type whole paths? I think it's called symbolic links, but those are not present in xp from what I read. But it should be possible somehow, when I previously installed MySQL from installer, 'mysql' as a keyword to access the db was available everywhere in cmd.

I tried messing with the registry and setting system variables behind My Computer, but the only result was I could access these as %xyz% which is not exactly the same. Nothing else works.

Thanks

1
  • "to assing these programs" I think you meant "to assign these programs".
    – Hello71
    Aug 12, 2010 at 18:07

3 Answers 3

0

Do this: Get the full path to the mysql exe and copy this.

Right-click "My Computer" and then Properties, then Advanced, then Environment Variables.

You should have a variable called PATH. Edit this one. At the end of the current one you add a semicolon and the path to the directory where your mysql executable is placed so it looks like OLDPATH;PATHWHEREMYSQLEXECUTABLE is located

0
2

You could just add the directories to your path using...

setx path "%path%;c:\foo" -m

But what I usually do is make a very simple script for each command, and name it using the shortcut I want to use. All my scripts are placed in a directory that is added to the path. All I have to do to run the script is type that shortcut, whichever CD I am in.

You can also develop these scripts to use parameters, so that you can make complex commands very easy, without having to remember them.

This is basically what scripting is all about.

Here is an example of a simple script I made that shows the hard disk drive information for any machine on the network, using the Sysinternals command psinfo.exe. I saved it as driveinfo.cmd, and I can type driveinfo /? to remind me of the syntax.

@echo off

echo.
echo DriveInfo v1.1
REM dependencies:  psinfo.exe
echo.

if [%1] == [] goto :command
if [%1] == [/?] goto :help
setlocal
set parm=%1
for %%U in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) do (
call set "parm=%%parm:%%U=%%U%%"
)
if [%parm:~0,2%] == [\\] goto :command
goto :error

:command
if [%1] == [] (
echo Drive information for %COMPUTERNAME%:
) else (
echo Drive information for %parm:~2%:
)
psinfo -d volume %1 2>nul | findstr /v "System information for" || (
goto :noresponse
)
goto :eof

:error
echo Syntax error
goto :eof

:noresponse
echo.
echo %parm:~2% cannot be found
goto :eof

:help
echo Usage: driveinfo [\\computer]
goto :eof
4
  • You get basically the same thing with: psinfo -d volume 2>nul | grep -e "Volume" -e "[A-Z]:"
    – BillP3rd
    Aug 12, 2010 at 18:57
  • So what are you saying? Use grep instead of findstr? Grep is not a standard CMD command, while findstr is. The GnuWin32 tools cannot be simply placed in a synced directory or flash drive either, so I cannot guarantee that I will have it on any machine I happen to be using.
    – paradroid
    Aug 12, 2010 at 19:08
  • 1
    Sure. A stand-alone grep would do, but yes, the GnuWin32 utilities can be installed on and run from a flash drive. The installer generates a shortcut that takes care of the necessary environment settings. BTW, my comment wasn't intended as a criticism and I hope you didn't interpret it as such. I like your driveinfo script. My intended contribution was merely to suggest a more concise (and readable) way of dealing with the output of psinfo.exe. NB. SETX is not a valid command in XP.
    – BillP3rd
    Aug 12, 2010 at 21:04
  • Okay, thanks - I get your point. I cannot even remember how I found out how findstr manages to deal with the psinfo output that way. The reason I did not use grep is that I find it a lot easier to only keep scripts and standalone executables in my command director, which I sync with all my machines and keep on USB flash drive. If there is a way to do that with the GnuWin32 commands, I'll look into that again. I totally forgot that setx is not included in XP as standard.
    – paradroid
    Aug 13, 2010 at 1:08
0

Since you mention symbolic links, you can download the GnuWin32 tools. The package you'll need is FileUtils which includes the "LN" command. Once installed, they'll need to be in the path. You can then create either symbolic links or hard links. You might like to create a folder for the purpose of housing your links. That folder would also need to be in the path.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .