B4J Question cmd shell on windows

Discussion in 'B4J Questions' started by klingon467, Jul 13, 2015.

  1. klingon467

    klingon467 Member Licensed User

    hi!
    i want to pass this command:
    Code:
    jar uvf dwn.jar Files/settings.txt

    my code:
    Code:
    Sub btnADD_Action
    Try
        sh.Initialize(
    "sh""jar uvf dwn.jar Files/settings.txt"Null)
        sh.WorkingDirectory = 
    File.DirApp
        sh.Run(-
    1)
                    
    Catch
        
    Log(LastException.Message)
       
        
    End Try
    End Sub
    Sub sh_ProcessCompleted (Success As Boolean, ExitCode As Int, StdOut As String, StdErr As String)
    If Success AND ExitCode = 0 Then
         
    Log("Success")
         
    Log(StdOut)
       
    Else
         
    Log("Error: " & StdErr)
       
    End If
       
    ExitApplication

    End Sub
    not work exception:
    ????
    thanks
     
  2. Roycefer

    Roycefer Well-Known Member Licensed User

    Does this code execute from within dwn.jar? If you are trying to modify a currently running .jar file, you might run into problems with Windows forbidding write access to the .jar file.
     
  3. rwblinn

    rwblinn Well-Known Member Licensed User

    Hi,

    suggest to use parameter list for the call jar uvf dwn.jar Files/settings.txt

    Code:
    Dim args As List
    args.Initialize
    args.Add(
    "-uvf")
    args.Add(
    "dwn.jar")
    args.Add(
    "Files/settings.txt")
    sh.Initialize(
    "sh""jar", args)
    Ensure the path to jar.exe is set, else init with some like below:
    Code:
    sh.Initialize("sh""""c:\Program Files (x86)\Java\jdk8\bin\jar.exe""", args)
     
    klingon467 likes this.
  4. klingon467

    klingon467 Member Licensed User

    thank you very much
    work perfectly! :D
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice