如何在javascript代码中将参数传递给批处理文件

时间:2017-09-14 10:05:20

标签: javascript shell batch-file

我在使用javascript代码将参数传递到批处理文件时遇到问题。

js文件如下:

var url1 = $scope.data.url;
var user1 = $scope.data.user;
var password1 = $scope.data.password;

MyObject = new ActiveXObject("WScript.Shell")
MyObject.Run("C:/Users/AAA/Desktop/cmd.bat [url1] [user1] [password1]");

和bat文件:

@echo off

:: Fetch param1
set "param1=%~1"
goto :param1Check
:param1Prompt
set /p "param1=Enter parameter 1: "
:param1Check
if "%param1%"=="" goto :param1Prompt

:: Fetch param2    
set "param2=%~2"
goto :param2Check
:param2Prompt
set /p "param2=Enter parameter 2: "
:param2Check
if "%param2%"=="" goto :param2Prompt

:: Fetch param3    
set "param3=%~3"
goto :param2Check
:param3Prompt
set /p "param3=Enter parameter 3: "
:param2Check
if "%param3%"=="" goto :param3Prompt
C:\Users\AAA\Desktop\dirb18_win\wordlists\diran.txt -o C:\Users\AAA\Desktop\AutomateTool\filewindows.txt -url "%param1% -u "%param2%:%param3%"  -w -i

它正在接受参数,因为它意味着[url1] [user1] [password1]

请帮帮我

0 个答案:

没有答案