Question: I have created a java class to execute a batch file that is in my desktop so that the commands in the batch file will be executed too. The problem is that, i keep getting the error: 

> 
> The filename, directory name, or volume label syntax is incorrect.
>  The filename, directory name, or volume label syntax is incorrect.
> 
> 
> 

I have checked the .bat name and the directory. It is correct. When i type `cmd /c start C:/Users/attsuap1/Desktop`, windows explorer opens the desktop tab. However when i type `cmd /c start C:/Users/attsuap1/Desktop/DraftBatchFile.bat`, it gives the error. My DraftBatchFile.bat is in my desktop. 

Here are my java codes:

```
public class OpenDraftBatchFile{
public OpenDraftBatchFile() {
    super();
}

/**Main Method
 * @param args
 */
public static void main(String[] args) {
    //Get Runtime object
    Runtime runtime = Runtime.getRuntime();
    try {
        //Pass string in this format to open Batch file
        runtime.exec("cmd /c start C:/Users/attsuap1/Desktop/DraftBatchFile.bat");
    } catch (IOException e) {
        System.out.println(e);
    }
}

```

Why is it that the batch file cannot be executed even if the directory is correct? Someone please help me. Thank you so much.

**These are the codes in DraftBatchFile.bat**

`@echo off
 echo.>"Desktop:\testing\draft.txt"
@echo Writing text to draft.txt> Desktop:\testing\draft.txt`

When i execute the DraftBatchFile.bat by running the java class, i want a draft.txt file to be created in a testing folder that i have created (in desktop).

Answer: 
there is no such thing as `desktop:\`

Instead try something like this.

```
@echo off
echo . %userprofile%\Desktop\testing\dblank.txt
@echo Writing text to draft.txt > %userprofile%\Desktop\testing\dblank.txt

```
You just need to change a directory and create new subdirectory if it not exist. My offer is change .bat file like this:

```
@echo off
if not exist "%userprofile%\Desktop\testing" mkdir "%userprofile%\Desktop\testing"
echo.>"%userprofile%\Desktop\draft.txt"
@echo Writing text to draft.txt>"%userprofile%\Desktop\draft.txt"

```

Also you can create .txt file and write in it text through Java code:

```
    File directory = new File(System.getProperty("user.home")+"//Desktop//testing");
    if (!directory.exists())
         directory.mkdirs();
    String content = "Writing text to draft.txt";
    File file = new File(System.getProperty("user.home")+"//Desktop//testing//draft.txt");
    BufferedWriter writer = null;
    try {
        writer = new BufferedWriter(new FileWriter(file));
        writer.write(content);
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        try {
            if (writer != null)
                writer.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

```