Comments (9)
What i want to do
is to add the jsonextractor.bat
in to a batch file but call it as a label and not a file
how can i do that?
from batch.scripts.
You mean by passing the string directly or as part of a bat file?
from batch.scripts.
i mean, being able to merge the json exectutor with my main batch script by calling it as a function
example:
@echo off
REM calling the function to parse the json value
call :JsonExtractor file.js "name"
pause >nul
exit /b
:JsonExtractor
REM The hybrid batch "Json Executor" function here.
REM Basically being able to call a label instead of calling a file
goto :EOF
from batch.scripts.
try like this:
@if (@CodeSection == @Batch) @then
@echo off
call :jsonextractor "c:\file.json" "something[0].something_else"
goto :eof
:jsonextractor
cscript /nologo /e:JScript "%~f0" %*
goto :EOF
@end // end batch
var htmlfile = WSH.CreateObject('htmlfile');
htmlfile.write('<meta http-equiv="x-ua-compatible" content="IE=9" />');
var JSON = htmlfile.parentWindow.JSON;
//needs file existence checks
var jsloc=WScript.Arguments.Item(0);
var jsonPath=WScript.Arguments.Item(1);
FSOObj = new ActiveXObject("Scripting.FileSystemObject");
var txtFile=FSOObj.OpenTextFile(jsloc,1);
var json=txtFile.ReadAll();
try {
var jParsed=JSON.parse(json);
}catch(err) {
WScript.Echo("Failed to parse the json content");
htmlfile.close();
txtFile.close();
WScript.Exit(1);
//WScript.Echo(err.message);
}
WScript.Echo(eval("JSON.stringify(jParsed."+jsonPath+")"));
htmlfile.close();
txtFile.close();
from batch.scripts.
I mean
As a complete function
So that i can add it at the very bottom of the script
from batch.scripts.
Because of the way the hack works - the jscript code allays should be at the end. Think for the @end // end batch
as the end of the batch code - now the jsonextractor function is at the end of it.
from batch.scripts.
i mean
the main normal batch script at the top
and for the very bottom a pure batch hybrid script
from batch.scripts.
Help?
from batch.scripts.
Additionally to already answered.
Long reading:
https://www.dostips.com/forum/viewtopic.php?f=3&t=5543
https://stackoverflow.com/questions/9074476/is-it-possible-to-embed-and-execute-vbscript-within-a-batch-file-without-using-a/9074483#9074483
JScript example:
@set @dummy=0 /*
@echo off
rem Your batch script is here...
cscript /nologo /e:jscript "%~f0" %*
exit /b
*/
// JScript code
WScript.Echo(123)
Or
0</* :
@echo off
rem Your batch script is here...
cscript /nologo /e:jscript "%~f0" %*
exit /b
*/
// JScript code
WScript.Echo(123)
VBScript example:
::'�@echo off
::'�rem You batch script is here...
::'�cscript /nologo /e:vbscript "%~f0" %*
::'�exit /b
' VBScript code
WScript.Echo 123
The �
is a SUB
character: dec=26
hex=0x1A
from batch.scripts.
Related Issues (20)
- Screen capture with specified window title capture the foreground window HOT 1
- How can I get the response HOT 3
- Post Fields by command line HOT 2
- Click does not work when cmd is not selected
- Trying to get response using winhttpjs.bat but there is something wrong I'm doing HOT 3
- sendKeys.bat does not work if the window is minimized
- Comments for screenCapture.bat ? HOT 2
- How to continue scripting in windows batch?
- .
- ( I'm a beginner ) I need help with a program I want to write HOT 2
- bat2exe.bat
- Why is the __COMPAT_LAYER variable defined? HOT 1
- Fix Suggestion
- "find" function in binaryTree.bat file doesn't work
- how do you replace multiple strings with replacer.bat ?
- Microsoft Defender Alert! HOT 2
- Change the extensions from .bat to .cmd
- exe2bat Reverse HOT 1
- Virus? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from batch.scripts.