Page 1 of 2

[SOLVED] Run a batch or powershell script

Published: May 19, 2016 - 10:32
by so37
Hello,

is it possible to run a batch or PowerShell file from within WAPT?

Thank you in advance.

Re: Run a batch or powershell script

Published: May 19, 2016 - 8:17 PM
by sfonteneau
batch:

run("install.bat")

Re: Run a batch or powershell script

Published: May 25, 2016 - 1:07 PM
by so37
THANKS !

Re: Run a batch or powershell script

Published: August 24, 2016 - 10:11
by Mathieu
Hello,

I'm a beginner in Python and I'm currently learning.

I've managed to run my batch file, but I'd like to know if it's possible to display the batch file window on the computer to follow its progress?

Thank you.

Re: Run a batch or powershell script

Published: September 23, 2016 - 11:11
by the Challans Town Hall
Hello,

the only way to see the progress is to open a command prompt as administrator and type `wapt-get install`.

Alternatively, put as many print statements as possible in the Python file and see the result of an installation in the WAPT console.

Re: Run a batch or powershell script

Published: October 27, 2017 - 09:53
by Chris
sfonteneau wrote: May 19, 2016 - 8:17 PM batch:

run("install.bat")
Good morning,

Can you provide more details on how to launch a Batch script via WAPT?

I have my script but I don't know how to insert it into the console to apply it to certain workstations.

THANKS.

Re: Run a batch or powershell script

Published: October 27, 2017 - 10:28 AM
by agauvrit
Hi Chris,

Batch files are not MSI files and run differently. You can't drag and drop a batch file to turn it into a WAPT package. To create a package that runs a *.bat script, see the documentation on creating a package for portable software: https://www.wapt.fr/fr/doc/CreationPaqu ... -avec-wapt

Regards,

Alexandre

Re: Run a batch or powershell script

Published: April 4, 2019 - 9:36 AM
by vandatt
Hello,

sorry to revive this old thread, but despite the explanations on the site and in this conversation, I can't seem to deploy a .bat script. Can anyone help me?

Regards

Re: Run a batch or powershell script

Published: April 4, 2019 - 11:45 AM
by Herzas
I see I'm not the only one stuck on this. Originally, I wanted to simply copy and paste the contents of a directory onto my users' desktops. I ended up creating a .bat file, converting it to .exe, which was then converted to .wapt (a real mess). The result is an error message, even though the package itself seems to work correctly.
Is there a simple method to just deploy a .bat file?

setup.py

Code: Select all

# -*- coding: utf-8 -*-
from setuphelpers import *

uninstallkey = []

def install():
    print('installing 974-mo_raccourci')
    install_exe_if_needed("MO_raccourci.exe",'/VERYSILENT',key='',min_version='0.0.0')
status error code:

Code: Select all

installing 974-mo_raccourciTraceback (most recent call last):
  File "C:\Program Files (x86)\wapt\common.py", line 3683, in install_wapt
    exitstatus = setup.install()
  File "c:\windows\temp\wapt2qcibk\setup.py", line 8, in install
  File "C:\Program Files (x86)\wapt\common.py", line 3642, in new_func
    return func(*args,**kwargs)
  File "C:\Program Files (x86)\wapt\setuphelpers.py", line 4192, in install_exe_if_needed
    run(r'"%s" %s' % (exe,silentflags),accept_returncodes=accept_returncodes,timeout=timeout,pidlist=pidlist)
  File "C:\Program Files (x86)\wapt\setuphelpers.py", line 1058, in run
    raise CalledProcessErrorOutput(proc.returncode,cmd,''.join(output))
CalledProcessErrorOutput: Command '"MO_raccourci.exe" /VERYSILENT' returned non-zero exit status 2.
Output:
c:\windows\temp\wapt2qcibk>robocopy "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Bureautique" "C:\Users\Public\Desktop" 

-------------------------------------------------------------------------------
   ROBOCOPY   ::   Copie de fichiers robuste pour Windows     
-------------------------------------------------------------------------------

  Début : Thu Apr 04 09:02:01 2019

   Source : C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Bureautique\
     Dest : C:\Users\Public\Desktop\

    Fichiers : *.*
	    
  Options : *.* /COPY:DAT /R:1000000 /W:30

Re: Run a batch or powershell script

Published: April 4, 2019 - 12:16 PM
by vandatt
Good morning,

I'm in the same boat as you. I can deploy my .bat file via Wapt. It deploys successfully on my client machines, but Wapt still returns an error...

My script is as follows:

Code: Select all

def session_setup():

                 run(r'script.bat');