Need to execute a jar file using bat file - batch-file

Need to execute a runnable jar file in widows machine and dont know whether the system already installed java or not.In case if the java is not installed in the machine the bat file has to install the java and then execute the jar file.The possibility may be like below.
check the whether java installed in the machine or not
If not installed install in the machine install the java and execute the jar file
If already java installed in the machine run the jar file.
Help me to solve.

Rather than a batch file you could consider using a tool like launch4j to generate an .exe wrapper. An executable built by launch4j will prompt the user to download java if they don't already have a suitable version installed.

Related

'mongo' is still not working on PowerShell after doing all recommended things

I installed MongoDB and tried to run it on terminal. It just shows up 'mongo' is not recognized as an internal or external command, operable program or batch file.
I have set the path to bin folder inside Environment variables too. One thing I noticed is I might have a missing file inside bin folder and that is mongo. Because I have mongod and mongos file inside the bin folder. I tried to uninstall and reinstall the program and it was still not working.
I have no idea it's what that I'm missing. Please help out
Finally I have found the solution,
Mongo shell no longer ships with server binaries. We can download it from MongoDB Shell Download
Then we should extract the contents of the bin from the downloaded zip file to the bin file of the MongoDB folder and run mongosh instead of mongo on the terminal

How to make a batch file which installs Network Driver automatically

I am making an installer using the NSIS tool.
It's first time that I use NSIS and batch file script, so there are many difficulties.
The most important issue to solve is that the network driver must be installed automatically when the installation is completed.
So my idea is making a batch file to install network driver, and execute it by NSIS script.
The manual installation process is in below picture:
So my question is: Is it possible to make this process by using batch script?
And if it is: How could I get to last process in batch file? is it registry or something?
Depending on the driver, you might be able to perform a .inf install:
Section
InitPluginsDir
SetOutPath $PluginsDir
File "mydriver*.*"
System::Call 'SETUPAPI::InstallHinfSection(p0,p0,ts,i0)' 'DefaultInstall 132 $PluginsDir\mydriver.inf'
SetOutPath $InstDir
SectionEnd
If you want to install a 64-bit driver with a 32-bit installer you might have to ExecWait '"$sysdir\..\sysnative\rundll32.exe" SETUPAPI.DLL,InstallHinfSection DefaultInstall 132 $PluginsDir\mydriver.inf instead.

Running batch file from network share (vmware shared folder) in cygwin

I'm having some problems with cygwin and a mapped network drive. My setup is kind of convoluted to deal with some limitations with our corporate VPN. I'm running a Windows 10 VM under VMware Fusion with a shared folder from my Mac host which is mapped to a network drive in Windows. The reason is b/c I access a remote Git repo using a VPN connection that leverages a browser plugin that unfortunately is only working from Safari currently. I need to run git commands from the Mac host but the project's build/development environment is Windows. The VPN browser plugin fails to install in any of the browsers under Windows. Hopefully a temporary problem but one I must workaround for now.
From my cygwin environment the mapped drive does not show up under /cygdrive, possibly b/c it's a shared folder with hgfs file system type. I'm able to mount the shared folder but when I try to run a batch file from the cygwin environment I get the following error:
./OpenCommandPrompt.bat
'\\vmware-host\Shared Folders\grant\Projects\lts\Product'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported. Defaulting to Windows directory.
The system cannot find the path specified.
'setenv.bat' is not recognized as an internal or external command,
operable program or batch file.
'setclasspath.bat' is not recognized as an internal or external
command, operable program or batch file.
C:\Windows>
It doesn't like the UNC path. I'm able to run the command fine from a PowerShell using the mapped drive letter but no luck from cygwin. My desire is to run the VM headless and access the Windows environment over SSH from my host so I'd like to get this working from the cygwin environment if possible. Any suggestions?
I was able to fix my issue by creating a simple script that I execute from my .bash_profile. I basically check for existence of the /cygdrive/h folder and if it doesn't exist I execute the script.
#!/bin/bash
net use H: '\\vmware-host\Shared Folders\share'
I tried to map the drive from Windows but all attempts to do so failed to register the drive mapping under the /cygdrive folder in cygwin. That was the issue I was trying to overcome. Once I had the mapped drive under /cygdrive, I was able to execute all the batch scripts.
To be honest, I'm still not sure why mapping the drive from Windows does not register it cygwin. The reverse is also true: if I execute the net command from the terminal, it does not register in Explorer.

Creating a MSI package with batch file

we have a requirement to uninstall an application from windows machine.I have created a batch file to with uninstall commands,converted the batch file into a exe and by using MSI package installer created a package.
When i tried to install this other machine this was found as virus/Spyware.
Is this because of bat file in the exe?
I would assume this is due to the tool you used to create the EXE file with. Other than that you can take a look at various ways to uninstall MSI files.
I don't know what kind of network you are on, but normally an uninstall like this is best done via a deployment tool, WMI, PowerShell or similar. There are many ways.

Windows package installer for automatic setup

All,
I have a package that should be easily deployed on any client machine, say provided there is Windows as an OS.
Package contains icons, .dll, doc files, .xml templates, .py scripts...
I would like that the User unzip this folder anywhere, launch a .bat or any other script, and that package is copied pasted at the right place.
In a second phase, i could refine this installer deplacing some files at the right place.
Is it possible with a .bat file ? What would it look like ?
Thanks in advance.
Type in Start - Run
iexpress
and follow the prompts in the IExpress 2.0 Setup Wizard.

Resources