none
Windows Task Scheduler couldn't get variable values

    Question

  • I want to get return value into variable. I can run normally with command line but when do in task scheduler. It couldn't work.

    Here is commands for bat file:

    @echo off
    SetLocal EnableDelayedExpansion
    set JAVA_HOME="C:\Program Files\Java\jdk1.8.0_181"
    set PATH="%JAVA_HOME%\bin"
    For /F %%A IN ('java -jar E:\BLTZ\AMLETL\batch\DecryptAML.jar') do set token2=%%A
    set pwd=%token2%
    NET USE \\FICO-DB\IPC$  %pwd% /user:blitz02>> E:\BLTZ\AMLETL\batch\log.txt
    NET USE \\FICO-DB\IPC$ /D

    Any suggesstion for this issues.

    Thursday, November 29, 2018 6:46 AM

All replies

  • What is the purpose of the script? It doesn't do anything except for establish a connection to a machine and then remove it.

    In any case, such an action is not secure because you are exposing the password in plain-text. It's better to run the script using an account that has credentials already.


    -- Bill Stewart [Bill_Stewart]

    Thursday, November 29, 2018 3:10 PM
    Moderator
  • There will be other actions like checking exist, copying, etc.. after establishing connection. 
    By the way, password is already encrypted and put in a properties file. That's why i need to call Decrypt.jar
    Friday, November 30, 2018 2:11 AM
  • Yes but your script tells everyone how to get the password.  It isn't even protected by your account.  At least Windows encryption protects the password with the account.  Someone needs your account password to decrypt a Windows secure string.

    First get rid of Java and batch files and use standard Windows to run your code.

    This can all be done in three lines with PowerShell.

    help New-PsDrive -online

    It looks like you are trying to hack a password. The code does nothing but attempt to connect a drive. Why?


    \_(ツ)_/

    Friday, November 30, 2018 2:18 AM
  • It doesn't show password with echo off at begining. I just want to check exist file at folder in another machine. That folder couldn't share with everyone hence we use these script.
    Tuesday, December 4, 2018 7:47 AM
  • Your Java program exposes you to credential theft.

    To connect to a remote share using alternate credentials interactively, you can use the net use command, which can prompt for the password safely.

    If you want to connect in a scheduled task, run the task using the credentials of the user that has access already. No password exposure in that case.


    -- Bill Stewart [Bill_Stewart]

    Tuesday, December 4, 2018 3:00 PM
    Moderator