[SOLVED] Run a batch or powershell script

Questions about WAPT Packaging / Requests and help regarding Wapt packages.
Forum Rules
Community Forum Rules
* English support on www.reddit.com/r/wapt
* French community support is available on this forum
* Please prefix the topic title with [RESOLVED] if it is resolved.
* Please do not edit a topic that is tagged [RESOLVED]. Open a new topic referencing the old one.
* Specify the installed WAPT version, full version, and build number (2.2.1.11957 / 2.2.2.12337 / etc.) as well as the Enterprise/Discovery edition.
* Versions 1.8.2 and earlier are no longer supported. The only questions accepted regarding version 1.8.2 are related to upgrading to a supported version (2.1, 2.2, etc.).
* Specify the server OS (Linux/Windows) and version (Debian Buster/Bullseye - CentOS 7 - Windows Server 2012/2016/2019).
* Specify the OS of the administration/package creation machine and the machine with the problematic agent, if applicable (Windows 7/10/11/Debian 11/etc.).
* Avoid asking multiple questions when opening a topic, otherwise it may be ignored. If there are multiple topics, open separate topics, preferably one after the other and not all at the same time (i.e., do not spam the forum).
* Include code snippets, screenshots, and other images directly in the post. Links to Pastebin, Bitly, and other third-party sites will be systematically removed.
* As with any community forum, support is provided voluntarily by members. If you require commercial support, you can contact Tranquil IT's sales department at 02.40.97.57.55
so37
Messages: 23
Registration: Apr 10, 2016 - 1:43 p.m.

May 19, 2016 - 10:32

Hello,

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

Thank you in advance.
User avatar
sfonteneau
WAPT Expert
Messages: 2318
Registered: July 10, 2014 - 11:52 PM
Contact :

May 19, 2016 - 8:17 PM

batch:

run("install.bat")
so37
Messages: 23
Registration: Apr 10, 2016 - 1:43 p.m.

May 25, 2016 - 1:07 PM

THANKS !
User avatar
Mathieu
Messages: 91
Registration: August 18, 2016 - 10:24

August 24, 2016 - 10:11

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.
- WAPT 2.2.3.12463 Enterprise
- Debian 9.9
- Windows 10 21H2 & Windows 11 22h2
User avatar
Challans Town Hall
Messages: 15
Registered: July 7, 2014 - 3:52 PM

September 23, 2016 - 11:11

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.
Chris
Messages: 7
Registration: Oct 19, 2017 - 5:04 p.m.

October 27, 2017 - 09:53

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.
User avatar
agauvrit
WAPT Expert
Messages: 238
Registration: Nov 17, 2016 - 10:25
Location: Nantes
Contact :

October 27, 2017 - 10:28

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
vandatt
Messages: 10
Registration: Nov 30, 2018 - 11:44

April 4, 2019 - 9:36 AM

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
Herzas
Messages: 10
Registration: Apr 02, 2019 - 11:44

April 4, 2019 - 11:45 AM

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
vandatt
Messages: 10
Registration: Nov 30, 2018 - 11:44

April 4, 2019 - 12:16

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');
Locked