替代批处理文件,因为我无法在其中包括java代码 [英] alternatives to batch file since i am unable to include java code in it

查看:289
本文介绍了替代批处理文件,因为我无法在其中包括java代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我听说,在对我的注释中的注释中,无法将java代码添加到批处理文件中上一个问题:



但是有什么替代方法吗?

是否可以将java代码添加到批处理文件? p>

我在批处理文件中尝试了以下操作,但无法正常工作:


vol231 .exe -f m.walkin(new File(d.detectDrive()))imageinfo> Volatility.txt


这是cmdenv。我创建的在命令提示符下运行从java:

  E:
echo off
cls

... //这部分是减少足迹的长部分,命令提示符切换到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
暂停
退出

这允许我的波动命令运行一个附加的命令提示符(Helix),可减少占用空间。



但是,波动率命令都是硬编码的。 E:\KOHMOHOJOJO-PC-20140714-152414.raw - profile = Win7SP0x86 有所不同。是否有任何替代方法,因为批处理文件允许java编码?



我是新的java和批处理文件。



Edit1:



我尝试更改java_path但它仍然有错误。



Edit2:
我尝试了不同的路径:


  1. C:\Program Files\Java\jdk1.8.0_05\bin C:\Program Files \Java\jre8\bin
    我得到错误:找不到或加载主类TestRun1


  2. C:\Users\User\workspace\Volatility\bin C:\Users\User\workspace\Volatility\src (这是保存类的工作空间)我得到 C:\Users\User\workspace\Volatility\(bin或src)\java 不能识别为内部或外部命令,可操作的程序或批处理文件。所以我添加了java.exe到文件。并且错误返回错误:找不到或加载主类TestRun1


这个批处理文件似乎不能读取java ..我试图在 > TestRun1 但仍然有相同的错误。我还发现我有环境变量在控制面板\系统和安全\系统\Advance系统设置\环境变量(路径)。我尝试删除 C:\Program Files\Java\jdk1.8.0_05\bin 然后运行它,但它仍然有相同的错误。

解决方案

因此可以将java代码添加到批处理文件中



> 在批处理文件中使用Java值,在Java中打印值,在批处理文件中使用该值。

在Java中,

  public class TestRun1 
{
public static void main(String args [])
{
System.out.println .walkin(new File(d.detectDrive())));
}
}

在批处理文件中:

  set tmp_file =%TEMP%\%〜n0.tmp 

rem ----根据您的java目录设置 - ------
set java_path = C:\Program Files\Java\jdk1.6.0_43\bin

%java_path%\javaTestRun1> %tmp_file%
set / P p =<%tmp_file%
echo%p%

rem -----现在p有值,使用它在命令中--------

vol231.exe -f%p%imageinfo> Volatility.txt
vol231.exe -f%p%--profile = Win7SP0x86 pslist>> Volatility.txt
vol231.exe -f%p%--profile = Win7SP0x86 dlllist> Volatility.txt
vol231.exe -f%p%--profile = Win7SP0x86 iehistory>> Volatility.txt
vol231.exe -f%p%--profile = Win7SP0x86 svcscan>> Volatility.txt
vol231.exe -f%p%--profile = Win7SP0x86 hivelist>> Volatility.txt
vol231.exe -f%p%--profile = Win7SP0x86 filescan>> Volatility.txt
vol231.exe -f%p%--profile = Win7SP0x86 netscan>> Volatility.txt
pause
del / F%tmp_file%


I heard that java code cannot be to add into batch file in a comment on my previous question:

But is there any alternatives to it?
Is it possible to add java code into batch file?

I tried the following in the batch file but it does not work:

vol231.exe -f m.walkin(new File(d.detectDrive())) imageinfo > Volatility.txt

This is cmdenv.bat that i created to run in command prompt from java:

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

This allows my volatility commands to run in a enclosed command prompt (Helix) which reduces footprint.

However, the volatility commands are all hardcoded. The E:\KOHMOHOJOJO-PC-20140714-152414.raw and --profile=Win7SP0x86 varies. Is there any alternative to do it since batch file does allow java coding?

I am new to java and batch file.

Edit1:

I tried changing the java_path but it still have errors.

Edit2: I tried different paths like:

  1. C:\Program Files\Java\jdk1.8.0_05\bin and C:\Program Files\Java\jre8\bin I get Error: Could not find or load main class TestRun1.

  2. C:\Users\User\workspace\Volatility\bin and C:\Users\User\workspace\Volatility\src (this is the workspace where the class is saved) I get C:\Users\User\workspace\Volatility\(bin or src)\java is not recognised as an internal or external command, operable program or batch file. So I added java.exe into the file. And the error gets back to Error: Could not find or load main class TestRun1.

This batch file doesn't seem to be able to read the java.. I tried adding a . in front of the TestRun1 but still it has the same error. I also found out that I have the environment variable under Control Panel\System and Security\System\Advance System Settings\Environment Variables (Path). I tried deleting C:\Program Files\Java\jdk1.8.0_05\bin and then running it but it still has the same error.

解决方案

So it is possible to add java code into batch file?

No, you cannot add Java code to batch file.

Alternative Workaround:

To use Java value in batch file, print the value in Java, Use that value in batch file.

In Java,

public class TestRun1
{
    public static void main(String args[])
    {
       System.out.println(m.walkin(new File(d.detectDrive())));
    }
}

In batch file:

set tmp_file=%TEMP%\%~n0.tmp

rem ----set as per your java directory-------
set java_path=C:\Program Files\Java\jdk1.6.0_43\bin

"%java_path%\java" TestRun1> "%tmp_file%"
set /P p=<"%tmp_file%"
echo %p%

rem -----now p has the value, use it in the command--------

vol231.exe -f %p% imageinfo > Volatility.txt
vol231.exe -f %p% --profile=Win7SP0x86 pslist >> Volatility.txt
vol231.exe -f %p% --profile=Win7SP0x86 dlllist > Volatility.txt
vol231.exe -f %p% --profile=Win7SP0x86 iehistory >> Volatility.txt
vol231.exe -f %p% --profile=Win7SP0x86 svcscan >> Volatility.txt
vol231.exe -f %p% --profile=Win7SP0x86 hivelist >> Volatility.txt
vol231.exe -f %p% --profile=Win7SP0x86 filescan >> Volatility.txt
vol231.exe -f %p% --profile=Win7SP0x86 netscan >> Volatility.txt
pause
del /F "%tmp_file%" 

这篇关于替代批处理文件,因为我无法在其中包括java代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆