In batch, I have trouble doing more advanced calculations with set /a
. Decimals won't work; for example set /a 5/2
only outputs 2
instead of 2.5
. Also batch can't handle large calculations. Is there a way to just make a temp file (like vbs) or call on another program (like calculator) to do the calculation and return it back to the batch file?
相关问题
- xcopy include folder
- Batch file if string starts by
- Jenkins - cmd is not recognized
- String Manipulation with case sensitivity
- Writing an EXE output to a batch file
相关文章
- Extracting columns from text file using Perl one-l
- How can one batch file get the exit code of anothe
- How to make jenkins fail at a failing windows batc
- Problems using start-process to call other powersh
- Python utilizing multiple processors
- Why do all Pre-build or Post-build events in Visua
- Windows batch file - how to loop through files in
- Azure Web App Temp file cleaning responsibility
You can use a VBS script using Windows Scripting Host in a batch file, or Powershell I guess if that has better math capability.
I adapted this from a usenet post and the batch file below shows some examples.
You can use it to do some maths.
The first command prints an ascii list of characters from 32 to 127.
The second prints the date 1 day ago
The other are as they say...
Native batch is limited to signed 32-bit integers. There are libraries available to extend its capabilities - Google is your friend. Not sure what you mean by 'large' calculations - please exemplify.
Regardless, batch is S-L-O-W.
The program below as an example of a Batch-JScript hybrid script that allows to evaluate any JScript expression:
Output:
You may review the available JScript arithmetic functions at: http://msdn.microsoft.com/en-us/library/b272f386(v=vs.84).aspx
This method allows to keep the JScript code in the same .BAT file and is simpler and faster than the VBScript code.