The PC shuts down before the scripts finish

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
User avatar
Root
Messages: 10
Registration: August 2, 2017 - 2:05 PM

August 2, 2017 - 2:23 PM

Good morning,
I use a Python script to launch other scripts (often batch or ps1 files).
In my package, setup.py ends with the instruction:

Code: Select all

os.system("cd C:\dossier0\dossier1 && start setup.bat")
In my bat I launch commands wmic (uninstall) and I use other functions which may take some time to complete.

My question is: How can I prevent Wapt from shutting down the computer before the batch process is complete? How can I make Wapt understand that the job isn't finished and that it needs to wait before shutting down?

I thought about using `time.sleep(10)`... but well, it's not very... clean :ugeek: Furthermore, the script does not take the same amount of time on each machine.

By the way:
I discovered WAPT during my studies while looking for deployment software; I use it on my personal computer and, since this year, in the company where I work! It's an excellent product.
I would also like to know where I can report problems related to my packages or my usage.

EDIT: Oops, wrong forum
User avatar
agauvrit
WAPT Expert
Messages: 238
Registration: Nov 17, 2016 - 10:25
Location: Nantes
Contact :

August 2, 2017 - 5:20 PM

Topic moved.

Regarding your question: https://www.wapt.fr/fr/doc/Frequent-pro ... tput-600-0

For your function, you could write it like this:

Code: Select all

os.chdir(r"C:\dossier0\dossier1")
run("setup.bat",timeout=1200)
Good package development!
User avatar
Root
Messages: 10
Registration: August 2, 2017 - 2:05 PM

August 3, 2017 - 09:13

agauvrit wrote: August 2, 2017 - 5:20 PM Topic moved.

Regarding your question: https://www.wapt.fr/fr/doc/Frequent-pro ... tput-600-0

For your function, you could write it like this:

Code: Select all

os.chdir(r"C:\dossier0\dossier1")
run("setup.bat",timeout=1200)
Good package development!
Good morning,
Thanks for the reply. I'll try your solution in the next update of my package.

I'm considering abandoning batch processing and rewriting my script in Python, but I'm afraid I'll encounter the same problem if I end my Python script with:
os.popen('wmic product where name="SoftwareName" call uninstall')
Good day
swbsf
Messages: 8
Registration: July 27, 2017 - 09:50

August 4, 2017 - 10:25

Hi,
I use it successfully:

Code: Select all

        cmd="c:\\Windows\\System32\\WindowsPowershell\\v1.0\\powershell.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass -File c:\\tmp\\Win10.ps1"
        proc = subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE)
        proc.wait()
The `proc.wait()` function works well in my case, as it also reboots the machine at the end of the process. You must, of course, import `subprocess`. And replace `cmd` with your command, whatever it may be.
The timeout=xxx solution is flawed; it's ideal for.. race condition.
User avatar
Root
Messages: 10
Registration: August 2, 2017 - 2:05 PM

August 10, 2017 - 11:43

swbsf wrote: August 4, 2017 - 10:25 Hi,
I use it successfully:

Code: Select all

        cmd="c:\\Windows\\System32\\WindowsPowershell\\v1.0\\powershell.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass -File c:\\tmp\\Win10.ps1"
        proc = subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE)
        proc.wait()
The `proc.wait()` function works well in my case, as it also reboots the machine at the end of the process. You must, of course, import `subprocess`. And replace `cmd` with your command, whatever it may be.
The timeout=xxx solution is flawed; it's ideal for.. race condition.
Thanks, I tried it with proc.wait() and it works fine
Locked