Escaping character in batch

Sometimes in Programming we can escape character by \. However in batch, the escape character is ^.

Example of the special characters are & (ampersand), < (less than) and > (greater than)

For example:

Escaping & would look like ^&

<html> would be ^<html^>

PS. Today I have to escape the url.

Advertisements

Change working directory in batch

Today I found that I need /d parameter to change directory in a batch file.

For example:

cd /d c:\java

It should look something like this during the execution:

c:>test.bat

c:\java>

Open a website in a browser from commandline

My attempt to open a website in command prompt or a batch file.

I found that, for Windows, I could run

explorer https://waoewaoe.wordpress.com

In batch script, I can do:

start explorer https://waoewaoe.wordpress.com

Ps. Actually, I don’t really have to use start 🙂

In Linux, we should be able to run

firefox https://waoewaoe.wordpress.com

(if there is Firefox)

Java JDK 6 also supports it using Browse class: http://java.sun.com/javase/6/docs/api/java/awt/Desktop.html#browse(java.net.URI)

Exception when starting tomcat

Starting Tomcat throws:

java.net.BindException: Address already in use: JVM_Bind

This is because the port has been used. To find out which program is using that port, open a command prompt

1. Get PID of the process by running netstat -a -n -o

2. Go to Task Manager (CTRL+ALT+DEL) under tab Services

3. Kill the process or change tomcat shutdown port

Error when deleting file that has a long name

Today while I’m trying to delete a folder. I’ve received this ” The folder ‘                   ‘ contains items whose name is too long for the Recycle Bin.”

longname

longname

Does it make any sense to you?

Installing Fedora 3 on Windows

This is a record of my attempt to install Fedora 3 on Windows

1. Install JDK 6. Can be downloaded from: http://java.sun.com

1.1 In order to prevent spacing problem in the directory name, I chose to install Java at C:\Java (Normally, it goes to C:\Program Files\Java

2. Install fedora 2. It can be downloaded from: http://www.fedora.info

2.1 Navigate to folder in Command Prompt (cmd.exe). I ran the Command Prompt as Administrator by right click > Run as Administrator. Then I run

java -jar fedora-installer.jar

2.2 I selected custom and parameters [roughly] can be found here.

3. Setting Environment Variables. This can be done in 2 ways.

3.1 Right click at My Computer > Properties >Advanced >Environment Variable

3.2 Through command (only for that session)

SET FEDORA_HOME=C:\fedora

SET JAVA_HOME=C:\Java

SET CATALINA_HOME=C:\fedora\tomcat

3.3 Navigate to FEDORA_HOME\tomcat\bin

3.4 Run startup.bat

Please find your fedora at the url, for example, http://localhost:8080/fedora

Ps. It also works when setting up java to C:\Program files\Java\…

Pss. Everything seems to work fine, there must be something wrong with my installer lol

Auto Shutdown for Windows XP

There is a shutdown command in Microsoft Windows. To use the command go to Start > Run and start typing.

For example:

shutdown -s -f -m \\myComName -t 10800 -c “I will shutdown by myself”

-t take time in seconds as parameter.

Please replace myComName with the actual computer name.

To find out the computer name,

1. Right click at My Computer

2. Properties

To cancel type:

shutdown -a

This is a link to a full documentation on Microsoft’s website: http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/shutdown.mspx?mfr=true