I'm running with both Java and JBossAS7 installed in directories that include spaces. This causes problems in the definition of JAVA_HOME and in the classpath used in the vault.bat file.
Given:
JAVA_HOME set to C:\Program Files (x86)\Java\jdk1.7.0_07
JBoss installed to C:\My Application Name\jboss-as-7.1.1.Final
This is the error message I got when running the vault.bat file:
\Java\jdk1.7.0_07\bin\java was unexpected at this time.
I fixed it by editing the \bin\vault.bat batch file as follows:
-- Add quotes around %JAVA_HOME% in the code that sets the JAVA environment variable (line 17):
set JAVA="%JAVA_HOME%"\bin\java
-- Add quotes around %JBOSS_VAULT_CLASSPATH% in the line that invokes the VaultTool (line 52):
%JAVA% -classpath "%JBOSS_VAULT_CLASSPATH%" org.jboss.as.security.vault.VaultTool