I am getting following error while starting jboss 7.1
The filename, directory name, or volume label syntax is incorrect.
The filename, directory name, or volume label syntax is incorrect.
'-jar' is not recognized as an internal or external command,
operable program or batch file.
I have set JAVA_HOME,PATH variables properly but still getting error---
I am using jdk 1.6 and sqljdbc4 driver
hi Frederic ,
I am pasting standalone.bat which is used to start jboss---
#echo off
rem -------------------------------------------------------------------------
rem JBoss Bootstrap Script for Windows
rem -------------------------------------------------------------------------
rem $Id$
#if not "%ECHO%" == "" echo %ECHO%
#if "%OS%" == "Windows_NT" setlocal
if "%OS%" == "Windows_NT" (
set "DIRNAME=%~dp0%"
) else (
set DIRNAME=.\
)
rem Read an optional configuration file.
if "x%STANDALONE_CONF%" == "x" (
set "STANDALONE_CONF=%DIRNAME%standalone.conf.bat"
)
if exist "%STANDALONE_CONF%" (
echo Calling "%STANDALONE_CONF%"
call "%STANDALONE_CONF%" %*
) else (
echo Config file not found "%STANDALONE_CONF%"
)
pushd %DIRNAME%..
set "RESOLVED_JBOSS_HOME=%CD%"
popd
if "x%JBOSS_HOME%" == "x" (
set "JBOSS_HOME=%RESOLVED_JBOSS_HOME%"
)
pushd "%JBOSS_HOME%"
set "SANITIZED_JBOSS_HOME=%CD%"
popd
if "%RESOLVED_JBOSS_HOME%" NEQ "%SANITIZED_JBOSS_HOME%" (
echo WARNING JBOSS_HOME may be pointing to a different installation - unpredictable results may occur.
)
set DIRNAME=
if "%OS%" == "Windows_NT" (
set "PROGNAME=%~nx0%"
) else (
set "PROGNAME=standalone.bat"
)
rem Setup JBoss specific properties
set JAVA_OPTS=-Dprogram.name=%PROGNAME% %JAVA_OPTS%
if "x%JAVA_HOME%" == "x" (
set JAVA=java
echo JAVA_HOME is not set. Unexpected results may occur.
echo Set JAVA_HOME to the directory of your local JDK to avoid this message.
) else (
set "JAVA=%JAVA_HOME%\bin\java"
)
if not "%PRESERVE_JAVA_OPTS%" == "true" (
rem Add -client to the JVM options, if supported (32 bit VM), and not overriden
echo "%JAVA_OPTS%" | findstr /I \-server > nul
if errorlevel == 1 (
"%JAVA%" -client -version 2>&1 | findstr /I /C:"Client VM" > nul
if not errorlevel == 1 (
set "JAVA_OPTS=-client %JAVA_OPTS%"
)
)
rem Add compressed oops, if supported (64 bit VM), and not overriden
echo "%JAVA_OPTS%" | findstr /I "\-XX:\-UseCompressedOops \-client" > nul
if errorlevel == 1 (
"%JAVA%" -XX:+UseCompressedOops -version > nul 2>&1
if not errorlevel == 1 (
set "JAVA_OPTS=-XX:+UseCompressedOops %JAVA_OPTS%"
)
)
rem Add tiered compilation, if supported (64 bit VM), and not overriden
echo "%JAVA_OPTS%" | findstr /I "\-XX:\-TieredCompilation \-client" > nul
if errorlevel == 1 (
"%JAVA%" -XX:+TieredCompilation -version > nul 2>&1
if not errorlevel == 1 (
set "JAVA_OPTS=-XX:+TieredCompilation %JAVA_OPTS%"
)
)
)
rem Find jboss-modules.jar, or we can't continue
if exist "%JBOSS_HOME%\jboss-modules.jar" (
set "RUNJAR=%JBOSS_HOME%\jboss-modules.jar"
) else (
echo Could not locate "%JBOSS_HOME%\jboss-modules.jar".
echo Please check that you are in the bin directory when running this script.
goto END
)
rem Setup JBoss specific properties
rem Setup the java endorsed dirs
set JBOSS_ENDORSED_DIRS=%JBOSS_HOME%\lib\endorsed
rem Set default module root paths
if "x%JBOSS_MODULEPATH%" == "x" (
set "JBOSS_MODULEPATH=%JBOSS_HOME%\modules"
)
rem Set the standalone base dir
if "x%JBOSS_BASE_DIR%" == "x" (
set "JBOSS_BASE_DIR=%JBOSS_HOME%\standalone"
)
rem Set the standalone log dir
if "x%JBOSS_LOG_DIR%" == "x" (
set "JBOSS_LOG_DIR=%JBOSS_BASE_DIR%\log"
)
rem Set the standalone configuration dir
if "x%JBOSS_CONFIG_DIR%" == "x" (
set "JBOSS_CONFIG_DIR=%JBOSS_BASE_DIR%/configuration"
)
rem Set memory configuration
set JAVA_OPTS=%JAVA_OPTS% -Xms512M -Xmx1024m -XX:MaxPermSize=512m -Dfile.encoding=UTF-8 -Duser.timezone=GMT"
echo ===============================================================================
echo.
echo JBoss Bootstrap Environment
echo.
echo JBOSS_HOME: %JBOSS_HOME%
echo.
echo JAVA: %JAVA%
echo.
echo JAVA_OPTS: %JAVA_OPTS%
echo.
echo ===============================================================================
echo.
:RESTART
"%JAVA%" %JAVA_OPTS% ^
"-Dorg.jboss.boot.log.file=%JBOSS_LOG_DIR%\boot.log" ^
"-Dlogging.configuration=file:%JBOSS_CONFIG_DIR%/logging.properties" ^
-jar "%JBOSS_HOME%\jboss-modules.jar" ^
-mp "%JBOSS_MODULEPATH%" ^
-jaxpmodule "javax.xml.jaxp-provider" ^
org.jboss.as.standalone ^
-Djboss.home.dir="%JBOSS_HOME%" ^
%*
if ERRORLEVEL 10 goto RESTART
:END
if "x%NOPAUSE%" == "x" pause
:END_NO_PAUSE
Related
I have a ClickOnce application called "Ulti", and I need to run three of this application at once due to my project requirements. During the course of the application, there is a possibility that one or more copies of the application will close due to certain requirements being met.
I have a .bat file scheduled to run every 10 minutes; if not all three copies of the application are running, it should open another instance of the application. However because all three processes of the application are all named "Ulti", my .bat file is unable to differentiate whether or not there are 3 copies of it running, and if not which one is shut down.
As such, is it possible to rename the process of a ClickOnce application dynamically via code at runtime?
You can't rename a process name in runtime. But if your bat file is processes starter you can pass some "Fake" parameter like "1", "2" etc, to your application. It hasn't any effect for your application, but you can differentiate your process by parse command line.
To get process command line parameters you can use WMIC /?. Here is an example:
#echo off
SET PROCESSNAME=notepad.exe
SET PROCESSDIR=C:\Windows
SET PROCESSFULLPATH=%PROCESSDIR%\%PROCESSNAME%
SET WMIC=C:\Windows\System32\wbem\WMIC.exe
SET PID1=1
SET PID2=2
SET PID3=3
REM Prepare
taskkill /IM notepad.exe
CLS
REM 3 Fake notepads
start /b /d "%PROCESSDIR%" %PROCESSNAME% %PID1%
start /b /d "%PROCESSDIR%" %PROCESSNAME% %PID2%
start /b /d "%PROCESSDIR%" %PROCESSNAME% %PID3%
echo You have a time for manual kill some notepad
pause
REM Restart if not founded 1 or 2 or 3 process.
REM 2nd loop doesn't working
REM Process 1
SET PROCESSID=%PID1%
SET KILLED=1
FOR /F "tokens=2" %%x IN ('%WMIC% /OUTPUT:STDOUT process where Name^="%PROCESSNAME%" get Commandline ^|find "%PROCESSNAME%"') DO (
IF "%%x"=="%PROCESSID%" (
SET KILLED=0
)
)
IF %KILLED%==1 (
echo Process %PROCESSID% killed. Restarting...
REM Restart dead copy with %KILLED% index
start /b /d "%PROCESSDIR%" %PROCESSNAME% %PROCESSID%
)
REM Process 2
SET PROCESSID=%PID2%
SET KILLED=1
FOR /F "tokens=2" %%x IN ('%WMIC% /OUTPUT:STDOUT process where Name^="%PROCESSNAME%" get Commandline ^|find "%PROCESSNAME%"') DO (
IF "%%x"=="%PROCESSID%" (
SET KILLED=0
)
)
IF %KILLED%==1 (
echo Process %PROCESSID% killed. Restarting...
REM Restart dead copy with %KILLED% index
start /b /d "%PROCESSDIR%" %PROCESSNAME% %PROCESSID%
)
REM Process 3
SET PROCESSID=%PID3%
SET KILLED=1
FOR /F "tokens=2" %%x IN ('%WMIC% /OUTPUT:STDOUT process where Name^="%PROCESSNAME%" get Commandline ^|find "%PROCESSNAME%"') DO (
IF "%%x"=="%PROCESSID%" (
SET KILLED=0
)
)
IF %KILLED%==1 (
echo Process %PROCESSID% killed. Restarting...
REM Restart dead copy with %KILLED% index
start /b /d "%PROCESSDIR%" %PROCESSNAME% %PROCESSID%
)
I want to develop a batch script which will execute each .sql SQL scripts present in the folder where the batch file is placed to and record the logs to a filename_sqloutput.txt file .
The condition is : If any script gives any error message like column name incorrect , or table name etc. The script execution should stop immediately and further scripts should not executed .
I tried with the below code: But its not working as even if the script is giving errors in the output file . The script execution is not stopping ..
Need your help !!!
#echo off
for /f %%a IN ('dir /b *.sql') do (call sqlcmd -S AMRVSP000000318 -i %%a -o"%%~na_sqloutput.txt"
findstr "Msg" %%~na_sqloutput.txt >nul & if %errorlevel% EQU 1 (exit) else (echo Successfully executed %%~na_sqloutput.txt)
)
pause
FINDSTR will set %ERRORLEVEL% as follows:
0 (False) a match is found in at least one line of at least one file.
1 (True) if a match is not found in any line of any file, (or if the file is not found at all).
2 Wrong syntax
An invalid switch will only print an error message in error stream.
Moreover, follow EnableDelayedExpansion article and rewrite the script to more readable structure:
#echo off
SETLOCAL EnableExtensions EnableDelayedExpansion
for /f %%a IN ('dir /b *.sql') do (
call sqlcmd -S AMRVSP000000318 -i %%a -o"%%~na_sqloutput.txt"
findstr "Msg" "%%~na_sqloutput.txt" 2>NUL
if !errorlevel! EQU 0 (
echo error occured %%~na_sqloutput.txt
rem pause to see error
pause
exit /B
) else (
echo Successfully executed %%~na_sqloutput.txt
)
)
pause
.... if errorlevel 1 (exit...
%errorlevel% is the initial value of errorlevel as it stands when the for is encountered.
See endless SO articles about using delayed expansion as another solution.
This syntax means "if the current errorlevel is 1 or greater dothis else dothat"
This script processes all the sql files in a given folder and outputs the result to a csv. Do you have any ideas how could I adapt it to retry the sql file in case of error or failure?
#ECHO OFF
SET SQLCMD="C:\Program Files\Microsoft SQL Server\100\Tools\Binn\SQLCMD.EXE"
SET PATH="C:\Users\username\Desktop\Scripts\Reports\sql"
SET SERVER="localhost"
SET DB="database"
SET LOGIN="username"
SET PASSWORD="password"
SET OUTPUT="C:\Users\username\Desktop\Scripts\Reports\output_%date%-%time:~0,2%-%time:~3,2%-%time:~6,2%.csv"
CD %PATH%
ECHO %date% %time% > %OUTPUT%
for %%f in (*.sql) do (
%SQLCMD% -S %SERVER% -d %DB% -E -i %%~f >> %OUTPUT% -W -w 1024 -s";")
Thank you!
You cant test the ERRORLEVEL environment variable. typically a zero ERRORLEVEL value means success. also you need to enable delayed expansion to check it inside a block.
something like this may help,
SetLocal EnableDelayedExpansion
for %%f in (*.sql) do (
Set /a success=1
for /L %%w in (1,1,5) do ( rem retry five times
if !success! NEQ 0 (
%SQLCMD% -S %SERVER% -d %DB% -E -i %%~f >> %OUTPUT% -W -w 1024 -s";"
if !ERRORLEVEL! EQU 0 set /a success=0
)
)
if !success! NEQ 0 (
rem sql failed, log or advise
)
)
EndLocal
another important point, be careful with the PATH environment variable. you should better use another name as SQL_PATH or MY_PATH.
or you can use PUSHD & POPD to change your working dir
#echo off
SET ...
rem save current dir and jump to...
pushd "C:\Users\username\Desktop\Scripts\Reports\sql"
for %%f in (*.sql) do (
...
...
)
rem restore dir saved by pushd
popd
I've tried looking every where how to do this but I cant find out how.
How do I check if a variable is defined and if it is replace every in variable in that file with a different variable. thanks
okay here is the code
#echo off
set/p "directoryname= Name of directory (to run on startup type "startup"). : "
if %directoryname%==startup goto startup
:namedirectory
if not exist "%directoryname%" (
mkdir "%directoryname%"
if "!errorlevel!" EQU "0" (
echo Folder created successfully
) else (
echo Error while creating folder
)
) else (
echo Folder already exists
)
goto skip_startup
:startup
:: here i would like to check if the variable %directoryname% is defined,
:: and it is, replace the variable named %directoryname% with
:: (Not changing the variables name) with the directory,
:: "C:\Documents and Settings\All Users\Start Menu\Programs\Startup". that
:: way when ever i can recall my variables in my file i can change my folder
:: to the startup directory.
:skip_startup
cd %directoryname%
:: ^
:: |_ replaced variable
Here is the commented batch code with the requested and some more enhancements:
#echo off
setlocal EnableExtensions DisableDelayedExpansion
rem Define as default directory name "startup". The user has to hit just
rem ENTER or RETURN with this default value and variable DirectoryName
rem keeps the default value "startup". Then ask user for directory name
rem and remove all double quotes from the entered directory name.
:EnterDirectory
set "DirectoryName=startup"
echo Please enter the name of the directory.
echo/
echo Hit just RETURN or ENTER to run on startup directory.
echo/
set /P "DirectoryName=Name of directory: "
set "DirectoryName=%DirectoryName:"=%"
rem Check if something other than just one or more double quotes was entered.
rem Prompt user once more after clearing screen if this is really the case.
if not defined DirectoryName cls & goto EnterDirectory
if "%DirectoryName%" == "startup" goto Startup
rem Check if entered directory name does not contain only spaces.
if "%DirectoryName: =%" == "" cls & goto EnterDirectory
echo/
if not exist "%DirectoryName%" (
mkdir "%DirectoryName%"
if errorlevel 1 (
echo Error on creating folder: "%DirectoryName%"
) else (
echo Folder "%DirectoryName%" created successfully.
)
) else (
echo Folder "%DirectoryName%" already exists.
)
goto SetDirectory
rem The variable DirectoryName has the default value "startup". Replace
rem this value by directory path of "Startup" folder in all users start
rem menu of Windows.
:Startup
set "DirectoryName=%ALLUSERSPROFILE%\Start Menu\Programs\Startup"
rem Set current directory to "Startup" directory or entered directory.
:SetDirectory
endlocal & cd /D "%DirectoryName%"
For understanding the used commands and how they work, open a command prompt window, execute there the following commands, and read entirely all help pages displayed for each command very carefully.
cd /?
cls /?
echo /?
endlocal /?
goto /?
if /?
mkdir /?
rem /?
set /?
setlocal /?
See also:
Single line with multiple commands using Windows batch file
DosTips forum topic: ECHO. FAILS to give text or blank line - Instead use ECHO/
I have been trying to work this 1 out it's a fairly simple batch but I'm pretty much lost, the searches got my close but none seemed to work so I'm hoping somebody can help with this.
I have a batch file, it is far from optimized but basically what I am trying to do now is use the ping I have running in the batch which is written to check.csv should then populate the individual IP's at the beginning (hope that makes sense).
in a nut shell
The variables at the beginning should be populated from check.csv
Here is the code
'#echo off
rem set the individual IP addresses
Rem these are manually set at present, I want these set automatically from check.csv which is created at the end of this file at present but will be moved infront..
set sarah=10.1.14.106
set richard=10.1.15.135
set kathh=10.1.12.79
edited out a number of these to reduce the code on screen for you, but they are all the same format, name & IP
rem set the individual profile name
set n1=sharman
set n2=rburrell
removed more of the same (just duplicates the above code for a different user)
rem set the computer name
set sarahPC=PB7B237
set richardPC=PB1VAL9
removed more of the same
REM set the main install paths
set M3="C:\Users\dclare\Documents\VW Compiler\Installers\M3.exe"
set H3="C:\Users\dclare\Documents\VW Compiler\Installers\H3.exe"
set MooresInst="C:\Users\dclare\Documents\VW Compiler\Catalogues\PD PS\Catalogue"
Rem menu
#echo off
cls
:start
echo.
echo 1 Ping
echo 2 List
echo 3 DBase Installers
echo 4 EXE Installers
echo 5 End
echo.
#CHOICE /C:12345
if errorlevel 5 goto End
if errorlevel 4 goto EXEInstallers
if errorlevel 3 goto DBase
if errorlevel 2 goto List
if errorlevel 1 goto Ping
goto End
:End
Pause
Exit
:EXEInstallers
echo EXE Installers
echo.
echo Upload folder
Xcopy %M3% "S:\# All Public\Information Technology\CAD\VWorlds" /s /y /q
Xcopy %H3% "S:\# All Public\Information Technology\CAD\VWorlds" /s /y /q
echo.
echo %sarah%
Xcopy %M3% "\\%sarah%\c$\Users\%n1%\Desktop\" /s /y /q
Xcopy %H3% "\\%sarah%\c$\Users\%n1%\Desktop\" /s /y /q
echo.
echo %richard%
Xcopy %M3% "\\%richard%\c$\Users\%n2%\Desktop\" /s /y /q
Xcopy %H3% "\\%richard%\c$\Users\%n2%\Desktop\" /s /y /q
echo.
removed more of the same (just duplicates the above code for a different user)
goto Start
:DBase
echo Database Installers
echo.
echo %sarah%
Xcopy %MooresInst% "\\%sarah%\c$\Virtual Worlds\Catalogue" /s /y /q
echo.
echo %richard%
Xcopy %MooresInst% "\\%richard%\c$\Virtual Worlds\Catalogue" /s /y /q
echo.
removed more of the same (just duplicates the above code for a different user)
echo
Goto Start
:List
echo.
echo This is a list of the IP's used currently, check against any that fail.
echo.
echo Name Puter IP
echo sarah %sarahPC%%sarah%
echo richard %richardPC% %richard%
echo kathh %kathhPC% %kathh%
echo amarie %amariePC% %amarie%
removed more of the same (just duplicates the above code for a different user)
echo.
Pause
Goto Start
:Ping
#echo off
if exist "C:\Users\dclare\Documents\VW Compiler\Copy to Desktop\Results.csv" Del /s /q "C:\Users\dclare\Documents\VW Compiler\Copy to Desktop\Results.csv"
Echo Pinging list...
set ComputerList=list.txt
pause
Echo Computername,IP Address>Final.csv
setlocal enabledelayedexpansion
for /f "usebackq tokens=*" %%A in ("%ComputerList%") do (
for /f "tokens=3" %%B in ('ping -n 1 -l 1 %%A ^|findstr Reply ^|^| echo Not found Failed:') do (
set IPadd=%%B
echo %%A,!IPadd:~0, -1!>>Check.csv
))
pause
Goto Start'
here is the check.csv file contents
PB1VAL9 10.1.15.135
PB7B218 Failed
PB1VAL8 10.1.15.111
PB7B210 10.1.5.253
removed more of the same (just duplicates the above code for a different user)
Try this routine out to set your variables to ip addresses:
echo off
for /f "usebackq tokens=1,2" %%a in ("check.csv") (
echo setting %%a=%%b
set "%%a=%%b"
)
With this ping routine it shows if it is online or offline. I had to guess what you were trying to do as we don't have your files to test it.
Give us a sample of Check.csv if you want to populate a set of variables with the IP addresses inside it.
:Ping
#echo off
Del /s /q "C:\Users\dclare\Documents\VW Compiler\Copy to Desktop\Results.csv" 2>nul
Echo Pinging list...
set "ComputerList=list.txt"
pause
Echo Computername,IP Address>Final.csv
for /f "usebackq delims=" %%A in ("%ComputerList%") do (
ping -n 1 -l 1 %%A >nul
if not errorlevel 1 (
>>Check.csv echo %%A,online
) else (
>>Check.csv echo %%A,offline
)
)
pause
Goto Start