[SOLVED] Run bat files

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
Locked
HugoDams
Messages: 11
Registration: July 18, 2022 - 11:11
Location: Le Mans

August 22, 2022 - 1:42 PM

Good morning,
I am using WAPT 2.2.1, in a completely Windows environment.

I want to run a .bat file with a very simple command line:

Code: Select all

ipconfig /all > Y:\SimonP\MAC\%username%.txt



Here is the package I put in place (just as simple):

Code: Select all

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

def install():
    run("ipconfig.bat")
Here is the error I am getting:

Code: Select all

*** Remote Interpreter Reinitialized ***
Command Line : install "c:\waptdev\dams-ipconfig_0_PROD-wapt\WAPT\.."
Using config file: C:\Program Files (x86)\wapt\wapt-get.ini
Installing WAPT files c:\waptdev\dams-ipconfig_0_PROD-wapt
2022-08-22 11:47:00,203 CRITICAL Fatal error in install script: CalledProcessErrorOutput: Command 'ipconfig.bat' returned non-zero exit status 1.
Output:
c:\waptdev\dams-ipconfig_0_PROD-wapt>ipconfig /all  1>Y:\SimonP\MAC\h.veyrent.txt 
The system cannot find the path specified.
:
Traceback (most recent call last):
  File "C:\Program Files (x86)\wapt\common.py", line 4035, in install_wapt
    exitstatus = setup.install()
  File "c:\waptdev\dams-ipconfig_0_PROD-wapt\setup.py", line 5, in install
    run("ipconfig.bat")
  File "C:\Program Files (x86)\wapt\common.py", line 3817, in run
    return ensure_unicode(run(*arg, pidlist=self.pidlist,**args))
  File "C:\Program Files (x86)\wapt\waptutils.py", line 2126, in run
    raise CalledProcessErrorOutput(proc.returncode, cmd, ''.join(output))
waptutils.CalledProcessErrorOutput: Command 'ipconfig.bat' returned non-zero exit status 1.
Output:
c:\waptdev\dams-ipconfig_0_PROD-wapt>ipconfig /all  1>Y:\SimonP\MAC\h.veyrent.txt 
The system cannot find the path specified.


FATAL ERROR : CalledProcessErrorOutput: Command 'ipconfig.bat' returned non-zero exit status 1.
Output:
c:\waptdev\dams-ipconfig_0_PROD-wapt>ipconfig /all  1>Y:\SimonP\MAC\h.veyrent.txt 
The system cannot find the path specified.

Exit code:  3
>>> 
I can't find anything concrete with "Exit code: 3"...
What did I do wrong, or what did I forget?
I correctly placed the .bat file in the package (as with an .msi or .exe installation), the .bat file launched manually works and correctly sends the result to the shared directory.

THANKS
Good day,
Hugo
Last edited by HugoDams on August 22, 2022 - 3:39 PM, edited 1 time.
User avatar
dcardon
WAPT Expert
Messages: 1932
Registration: June 18, 2014 - 09:58
Location: Saint Sébastien sur Loire
Contact :

August 22, 2022 - 3:00 PM

Code: Select all

c:\waptdev\dams-ipconfig_0_PROD-wapt>ipconfig /all  1>Y:\SimonP\MAC\h.veyrent.txt 
The system cannot find the path specified.
As the message indicates, Y:\ probably does not exist in the execution context.

Sincerely,

Denis
Denis Cardon - Tranquil IT
Share your experiences on WAPT! Send us your blog and article URLs in the "Your Opinion of the forum, and we'll feature them on the WAPT
HugoDams
Messages: 11
Registration: July 18, 2022 - 11:11
Location: Le Mans

August 22, 2022 - 3:33 PM

Hi Denis,
Y: is a network drive; it does exist, but the script needs to create the text file based on the user log (h.veyrent.txt in my case).
This drive is accessible to everyone without restriction (it's our daysharing).

Hugo
HugoDams
Messages: 11
Registration: July 18, 2022 - 11:11
Location: Le Mans

August 22, 2022 - 3:38 PM

My mistake, it works with my C:\ drive...
Are the packets unable to write to the network?
If you have another solution for obtaining the MAC addresses of PCs using the user log via WAPT, I'd appreciate it, because the console displays all the MAC addresses, but we only want the active one.
Thanks,
Hugo
User avatar
dcardon
WAPT Expert
Messages: 1932
Registration: June 18, 2014 - 09:58
Location: Saint Sébastien sur Loire
Contact :

August 22, 2022 - 3:56 PM

HugoDams wrote: August 22, 2022 - 3:38 PM My bad, it works with my C:\ drive...
The packets can't write to the network?
The SYSTEM account context is not the same as the user's; it has no knowledge of Y:\

You can mount a reader in SYSTEM context, but it's not specific to WAPT (and I would say it's not very pretty).
If you have another solution to obtain the MAC address of PCs using the user log via WAPT, I'm all ears, because from the console we have all the MAC addresses but we would only like the active one.
In the Enterprise version you can use the audit function to regularly retrieve data, such as an ipconfig for example.

In the Discovery version, if it is a one-off need you can create a package with a def install() which launches the function, retrieve the result and then uninstall the package.

Sincerely,

Denis
Denis Cardon - Tranquil IT
Share your experiences on WAPT! Send us your blog and article URLs in the "Your Opinion of the forum, and we'll feature them on the WAPT
Locked