批处理文件的替代方案,因为我无法在其中包含java代码
我听说java代码不能在my previous question:上的注释中添加到批处理文件中
但是有没有其他的选择呢
是否可以将java代码添加到批处理文件中
我在批处理文件中尝试了以下操作,但无效:
vol231.exe -f m.walkin(new File(d.detectDrive())) imageinfo > Volatility.txt
这是cmdenv。我创建用于在java命令提示符下运行的bat:
E:
echo off
cls
... //This part is a long part for reducing footprint whereby the command prompt is switched to Helix
vol231.exe -f E:\KOHMOHOJOJO-PC-20140714-152414.raw imageinfo > Volatility.txt
vol231.exe -f E:\KOHMOHOJOJO-PC-20140714-152414.raw --profile=Win7SP0x86 pslist >> Volatility.txt
pause
exit
这允许我的volatility命令在一个封闭的命令提示符(Helix)中运行,从而减少了占用空间
但是,volatility命令都是硬编码的。E:\KOHMOHOJOJO-PC-20140714-152414.raw
和--profile=Win7SP0x86
各不相同。因为批处理文件允许java编码,所以有没有其他方法可以这样做
我不熟悉java和批处理文件
编辑1:
我尝试更改java_路径,但仍然有错误
编辑2: 我尝试了不同的途径,如:
C:\Program Files\Java\jdk1.8.0_05\bin
和C:\Program Files\Java\jre8\bin
我得到Error: Could not find or load main class TestRun1
C:\Users\User\workspace\Volatility\bin
和C:\Users\User\workspace\Volatility\src
(这是保存类的工作区)我得到C:\Users\User\workspace\Volatility\(bin or src)\java
未被识别为内部或外部命令、可操作程序或批处理文件。所以我添加了java。exe文件。然后错误返回到Error: Could not find or load main class TestRun1
此批处理文件似乎无法读取java。。我尝试在TestRun1
前面添加一个.
,但仍然有相同的错误。我还发现我在Control Panel\System and Security\System\Advance System Settings\Environment Variables
(Path)下有一个环境变量。我尝试删除C:\Program Files\Java\jdk1.8.0_05\bin
,然后运行它,但仍然有相同的错误
# 1 楼答案
让Java程序将文件名作为命令行选项传递给批处理文件。在批处理文件中,您可以将其作为变量
%1
访问。您可以传递多个命令行选项;其他的将以%2
、%3
等形式提供# 2 楼答案
下面介绍如何将java代码添加到批处理文件(尽管这并不是解决问题的完整解决方案):
不推荐使用的注释是我发现的唯一一个可以在类之外设置的注释。需要注释以避免有毒输出。它还创建了两个临时文件(.class和.java),您可以删除它们
# 3 楼答案
所以有可能将java代码添加到批处理文件中吗
否,无法将Java代码添加到批处理文件中
替代解决方案:
要在批处理文件中使用Java值,请在Java中打印该值,然后在批处理文件中使用该值
在爪哇
在批处理文件中: