Jan-12-2025, 10:53 PM
Hi
I have an application that allows me execute a bat file. I can't execute a python file.
I need to pass the arguments of the application to python script. So I do:
I have an application that allows me execute a bat file. I can't execute a python file.
I need to pass the arguments of the application to python script. So I do:
echo "%*" > c:\script\salida.txt python c:\script\envio.py %*In python I execute a simple python program to store arguments in a file, but I see don't works. If I execute in terminal works but with the application doesn't works. The argumentos file doesn't store the arguments.
import sys import os def main(): if len(sys.argv) < 2: print("Por favor, proporciona argumentos al script.") return argumentos = sys.argv[1:] ruta_directorio = r"C:\script" nombre_archivo = "argumentos.txt" ruta_completa = os.path.join(ruta_directorio, nombre_archivo) try: os.makedirs(ruta_directorio, exist_ok=True) with open(ruta_completa, "w") as archivo: for argumento in argumentos: archivo.write(argumento + "\n") print(f"Argumentos guardados en '{ruta_completa}'") except Exception as e: print(f"Error al escribir en el archivo: {e}") if __name__ == "__main__": main()Any help? Thanks