I have this script in BASH (linux) shells script that adds all *.jar files into the classpath automatically. Is there a way to do the in window's batch file or do I have to add all the files manually?
CLASSPATH=.
for file in ./libs/*.jar; do
CLASSPATH=$CLASSPATH:$file
done
Thanks!
See BAT file to create Java CLASSPATH
Use the forfiles command to loop over the file names.
forfiles /M .\libs\*.jar /C "cmd /c set CLASSPATH=%CLASSPATH%;#file"
Related
I have used iexpress to wrap a .bat file within an .EXE file.
The .bat file contains commands to install my project on Windows.
I followed all the steps and I got an .exe file, but when run it shows a finished msg but nothing is done. (no command inside the bat file is running).
#echo off
echo %DATE% >> "C:\Users\gaubansa\Desktop\my.txt"
echo %PATH% >> "C:\Users\gaubansa\Desktop\my.txt"
Cotnets of the .SED file:
[Version]
Class=IEXPRESS
SEDVersion=3
[Options]
PackagePurpose=InstallApp
ShowInstallProgramWindow=1
HideExtractAnimation=0
UseLongFileName=0
InsideCompressed=0
CAB_FixedSize=0
CAB_ResvCodeSigning=0
RebootMode=N
InstallPrompt=%InstallPrompt%
DisplayLicense=%DisplayLicense%
FinishMessage=%FinishMessage%
TargetName=%TargetName%
FriendlyName=%FriendlyName%
AppLaunched=%AppLaunched%
PostInstallCmd=%PostInstallCmd%
AdminQuietInstCmd=%AdminQuietInstCmd%
UserQuietInstCmd=%UserQuietInstCmd%
SourceFiles=SourceFiles
[Strings]
InstallPrompt=Write
DisplayLicense=
FinishMessage=ho gya
TargetName=C:\Users\gaubansa\Desktop\my.EXE
FriendlyName=Write
AppLaunched=cmd.exe /c my_personal.bat
PostInstallCmd=<None>
AdminQuietInstCmd=
UserQuietInstCmd=
FILE0="my_personal.bat"
[SourceFiles]
SourceFiles0=C:\Users\gaubansa\Desktop\
[SourceFiles0]
%FILE0%=
According to the Iexpress directive (.SED) file you posted, the problem is that you configured Iexpress to store file names in the package using short file names so your batch file my_personal.bat will be stored in the package using its short file name MY_PER~1.BAT but you have specified cmd /c my_personal.bat to run your batch file so cmd can not find my_personal.bat.
To resolve that choose the option Store files using Long File Name inside Package in Iexpress. Alternatively you can edit the SED file and change the directive UseLongFileName=0 to UseLongFileName=1 then in Iexpress GUI select Open existing Self Extraction Directive file
Some additional advise
Although your batch file name does not contain spaces or other special characters it is always a good practice to enclose the file name in quotes. So you should change AppLaunched=cmd.exe /c my_personal.bat to AppLaunched=cmd.exe /d /c "my_personal.bat"
The /d switch is optional, it is to prevent cmd from executing commands that may be present cmd's AutoRun registry settings. You can get more information about it by typing CMD /? at command prompt.
A safer option would be use AppLaunched=cmd.exe /d /s /c ""my_personal.bat"" so in future if you ever decide to repackage your batch file and pass some quoted parameter to it, you can do that without the risk of essential quotation marks being removed by cmd.
for example: cmd.exe /d /s /c ""my_personal.bat" "Quoted Param1" "Quoted Param2" UnquotedParam3"
I am very new to Jenkins and want it to build a complete .exe. I set the Repository to a personal URL, now Jenkins do read all the files and copies everything to the Jenkins Workspace. My question is what do I insert into the "Execute Windows Batch Command" block in Jenkins so that it would Compile a NSIS script and store the Setup file in a output file. I have done research into Windows Batch Scripting but nothing that could truly help me in this struggle. If I am doing it all wrong I would love some advice to get me on the right track. Here are my current Jenkins codes to read and safe the files from the repository:
1st "Execute Batch Command"
COPY "C:\Program Files (x86)\Jenkins\jobs\Job_name\Path\*.*" "C:\Program Files (x86)\Jenkins\jobs\Job_Name\workspace\Output\Installs" /Y
2nd "Execute Batch Command"
del c:\inetpub\wwwroot\downloads\%SVN_REVISION%\*.* /s /f /q
rmdir "C:\inetpub\wwwroot\downloads\%SVN_REVISION%"
exit 0
3rd "Execute Batch Command"
MKDIR "C:\inetpub\wwwroot\downloads\%SVN_REVISION%"
4th "Execute Batch Command"
COPY "C:\Program Files (x86)\Jenkins\jobs\Job_Name\workspace\Output\Installs"
"c:\inetpub\wwwroot\downloads\%SVN_REVISION%" /Y
Now all I want Jenkins to do is open my .nsi script, compile and create the Setup File which then saves in an output folder.
Create new batch command with following:
path_to_NSIS_folder>\makensis.exe path_to_your_nsi_file
makensis.exe is a NSIS compiler and all it needs is path to the script file (.nsi).
When run the script is compiled and (if no errors) reslting setup.exe is created (the output can se set in .nsi file).
I am using Windows 7 professional.
I have auto generated file shortcut for the program.
I need to delete one folder before starting the program every time.
Can I automatize it without creating .bat file? e.g. using this command del \directory\path\* /g "C:\Program Files (x86)\program.exe" in the shortcut properties.
Yes you can do this:
C:\Windows\System32\cmd.exe /C "del \directory\path\* /Q & "C:\Program Files (x86)\program.exe"
The & sign tells the shell to run several commands in sequence.
I am trying to run a .cmd file on a remote server with PowerShell.
In my .ps1 script I have tried this:
C:\MyDirectory\MyCommand.cmd
It results in this error:
C:\MyDirectory\MyCommand.cmd is not recognized as the name of a cmdlet,
function, script file, or operable program.
And this
Invoke-Command C:\MyDirectory\MyCommand.cmd
results in this error:
Invoke-Command : Parameter set cannot be resolved using the specified named
parameters.
I do not need to pass any parameters to the PowerShell script. What is the correct syntax that I am looking for?
Invoke-Item will look up the default handler for the file type and tell it to run it.
It's basically the same as double-clicking the file in Explorer, or using start.exe.
Go to C:\MyDirectory and try this:
.\MyCommand.cmd
Try invoking cmd /c C:\MyDirectory\MyCommand.cmd – that should work.
To run or convert batch files to PowerShell (particularly if you wish to sign all your scheduled task scripts with a certificate) I simply create a PowerShell script, for example, deletefolders.ps1.
Input the following into the script:
cmd.exe /c "rd /s /q C:\#TEMP\test1"
cmd.exe /c "rd /s /q C:\#TEMP\test2"
cmd.exe /c "rd /s /q C:\#TEMP\test3"
*Each command needs to be put on a new line, calling cmd.exe again.
This script can now be signed and run from PowerShell outputting the commands to command prompt / cmd directly.
It is a much safer way than running batch files!
First you can reach till that folder:
cd 'C:\MyDirectory'
and then use:
./MyCommand.cmd
I just need to write a simple batch file just to run a vbscript. Both the vbscript and the batch file are in the same folder and is in the SysWOW64 directory as the vbscript can only be execute in that directory. Currently my batch file is as follows:
#echo off
%WINDIR%\SysWOW64\cmd.exe
cscript necdaily.vbs
But the vbscript wasn't executed and just the command prompt is open. Can anyone tell me how can i execute the vbscript when i run this batch file?
You can use %~dp0 to get the path of the currently running batch file.
Edited to change directory to the VBS location before running
If you want the VBS to synchronously run in the same window, then
#echo off
pushd %~dp0
cscript necdaily.vbs
If you want the VBS to synchronously run in a new window, then
#echo off
pushd %~dp0
start /wait "" cmd /c cscript necdaily.vbs
If you want the VBS to asynchronously run in the same window, then
#echo off
pushd %~dp0
start /b "" cscript necdaily.vbs
If you want the VBS to asynchronously run in a new window, then
#echo off
pushd %~dp0
start "" cmd /c cscript necdaily.vbs
This is the command for the batch file and it can run the vbscript.
C:\Windows\SysWOW64\cmd.exe /c cscript C:\Windows\SysWOW64\...\necdaily.vbs
Just try this code:
start "" "C:\Users\DiPesh\Desktop\vbscript\welcome.vbs"
and save as .bat, it works for me
Batch files are processed row by row and terminate whenever you call an executable directly.
- To make the batch file wait for the process to terminate and continue, put call in front of it.
- To make the batch file continue without waiting, put start "" in front of it.
I recommend using this single line script to accomplish your goal:
#call cscript "%~dp0necdaily.vbs"
(because this is a single line, you can use # instead of #echo off)
If you believe your script can only be called from the SysWOW64 versions of cmd.exe, you might try:
#%WINDIR%\SysWOW64\cmd.exe /c call cscript "%~dp0necdaily.vbs"
If you need the window to remain, you can replace /c with /k
Well i am trying to open a .vbs within a batch file without having to click open but the answer to this question is ...
SET APPDATA=%CD%
start (your file here without the brackets with a .vbs if it is a vbd file)
You should put your .bat file in the same folder as your .vbs file and call the following code inside the .bat file.
start cscript C:\filePath\File.vbs