Tag Archives: cygwin

Make Windows Shortcuts with Cygwin

Did you know that you can make Windows shortcuts with Cygwin and ln? I did not know this, just tried it out today and it works!

This is probably the smallest thing I’m blogging about, but read on you might get some new ideas (like I did) about file organization in Windows. I swear some days Cygwin is the only thing that keeps me sane on this office Windows XP computer.

I like to keep my /projects folder separate from my /clients folder. It just saves clicks I guess and I’m a separation junkie I can’t help it. I could have manually created these shortcuts for each project but now I can do it in a bash script. Yay!

Still not following? Let me explain. I have a clients folder like this.


/clients/a/projects/a
/clients/a/projects/b
/clients/b/projects/c
/clients/a/projects/d

But I like to keep my projects in a root level projects folder like this for easy access and backups etc.


/projects/a
/projects/b
/projects/c
/projects/d

I have simple, unique, short project names. That helps a lot. Here is the magical command that can help me a great deal.


ln -s /cygdrive/d/clients/a/projects/a /cygdrive/d/projects/a

This way I can keep projects I’m currently working on in /projects and move others back to /clients/x/projects. Ideas for a project folder management script is brewing will post about that later.

Running Bash Scripts in Windows Scheduler

Normally you can run scripts in the Cygwin shell. But I wanted to run a bash script in Windows scheduler. Find the Cygwin.bat file probably located in C:\cygwin. It looks something like this.


@echo off

C:
chdir C:\cygwin\bin

bash --login -i

This batch file doesn’t let you run an external script with it. Add a %1 at the bash command’s end like this. What you are doing is passing the first parameter in Windows to bash.


@echo off

C:
chdir C:\cygwin\bin

bash --login -i %1

Now drag and drop the Cygwin.bat file into the Windows scheduler window and edit running time properties etc. Now add the script to run at the end of the Cygwin command. For example like

C:\cygwin\Cygwin.bat ./bin/mysql/db.dilantha.info.sh

Windows Scheduler