Page 1 of 1

[SOLVED] Run bat files

Published: August 22, 2022 - 1:42 PM
by HugoDams
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

Re: Run bat files

Published: August 22, 2022 - 3:00 PM
by dcardon

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

Re: Run bat files

Published: August 22, 2022 - 3:33 PM
by HugoDams
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

Re: Run bat files

Published: August 22, 2022 - 3:38 PM
by HugoDams
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

Re: Run bat files

Published: August 22, 2022 - 3:56 PM
by dcardon
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