Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 13 additions & 24 deletions java/src/main/java/com/genexus/GXutil.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
package com.genexus;

import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.io.*;
import java.math.BigDecimal;
import java.nio.file.Paths;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.Random;
import java.util.TimeZone;
import java.util.Vector;
import java.util.*;

import com.genexus.common.interfaces.SpecificImplementation;
import com.genexus.internet.HttpContext;
Expand Down Expand Up @@ -1103,31 +1096,27 @@ public static byte openPrintDocument(String document)
return (byte) NativeFunctions.getInstance().shellExecute(document, "print");
}

/** Hace un Shell modal. Ejecuta en la misma 'consola' que su parent
* @param command Comando a ejecutar
* @return true si el comando se pudo ejecutar
*/
public static boolean shellModal(String command)
{
return NativeFunctions.getInstance().executeModal(command, true);
}

public static byte shell(String cmd, int modal)
{
if (modal == 1)
return shellModal(cmd)? 0 : (byte) 1;

try
{
Runtime.getRuntime().exec(cmd);
List<String> al = Arrays.asList(cmd.split(" "));
ProcessBuilder pb = new ProcessBuilder(al);
pb.redirectOutput(ProcessBuilder.Redirect.INHERIT);
pb.redirectError(ProcessBuilder.Redirect.INHERIT);
pb.redirectInput(ProcessBuilder.Redirect.INHERIT);
Process p = pb.start();

byte exitCode = (byte)p.waitFor();

p.destroy();
return exitCode;
}
catch (Exception e)
{
System.err.println("e " + e);
return 1;
}

return 0;
}

public static byte shell(String cmd)
Expand Down