Question

I'm developing a java desktop application to access information, format, change labels and volume id. This app's target are Windows users that will be using mainly Windows XP or Windows 7.

I'm getting basic info using java's File and FileSystemView; and I'm using Runtime.getRuntime().exec() to execute external Windows applications to do the other tasks.

I tried to use 'vol' and 'dir' to get the volumeId information but I get the following error:

Starting: vol E:
java.io.IOException: Cannot run program "vol": CreateProcess error=2, O sistema não pode  encontrar o arquivo especificado
        at java.lang.ProcessBuilder.start(Unknown Source)
        at java.lang.Runtime.exec(Unknown Source)
        at java.lang.Runtime.exec(Unknown Source)
        at java.lang.Runtime.exec(Unknown Source)
        at app.CommandRunnerWithReturn.run(CommandRunnerWithReturn.java:24)
Caused by: java.io.IOException: CreateProcess error=2, O sistema não pode encontrar o arquivo especificado
        at java.lang.ProcessImpl.create(Native Method)
        at java.lang.ProcessImpl.<init>(Unknown Source)
        at java.lang.ProcessImpl.start(Unknown Source)
        ... 5 more

Is there a Java API or Windows program I can use to get volumeid info?

Thanks in advance.

Was it helpful?

Solution

Some commands are built in to a shell. To run these commands you need to run the shell to run the command. For CMD you need something like

CMD /C VOL

for unix shell you need something like

sh -c "cd /path ; command > file"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top