how do you pause and at a later time resume a workflow from nodejs - google-workflows

Some of my workflows need to spawn new workflows, some depending on user interaction. How could I pause a workflow and later resume it when the user has provided the information it needs

use tool like iterm, you can spin new environment and let some process running in the background.

Related

Make a PowerShell script run on startup in the OOBE Sysprep environment

Thanks for stopping by, I've searched the corners of the internet but haven't gotten anywhere.
To provision devices for my organization, we must manually run PowerShell commands using SHIFT + F10 in the Windows 11 OOBE as we have multiple methods, one of which being legacy. I'm sure there are better methods but I'm unfortunately working within these limitations. So far, to automate the imaging process, I've created an autounattend.xml which makes WinPE completely silent and some pages of the OOBE also.
Recently, I combined all the PowerShell commands we had been running prior into a script that, after running repeated checks for a network connection, prompts users with a GUI and effectively automates everything we had been doing manually before:
Message box with radio buttons
I need to make this run when the OOBE Sysprep starts, but I really need some help.
The script contains GUI, so it cannot run silently and the user needs to interact with it.
The script must start with the OOBE Windows Welcome Screen, (i.e. select region screen). This is a limitation of the modules used and I therefore can't include it as a synchronous command in FirstLogonCommands or include it in SetupComplete.cmd, as those both execute after the OOBE is completed.
I've tried configuring the answer file to boot into audit mode and have the script run there, but the script requires several reboots and I get an installation failed message after any reboot (despite later making the script enable the Administrator account and call "sysprep /audit /reboot"). Additionally, the Audit Administrator account takes ~15 minutes to log in so it defeats the whole purpose of time saving.
I've tried using Task Scheduler, running both on System Start Up and User Log On, as defaultuser0, BUILTIN\Administrators and SYSTEM. Task scheduler seems to either queue tasks or not call them at all in the OOBE
I've tried placing the script, and then a shortcut of the script, in the common start up folder but that didn't work either.
To reiterate, I need a way to automatically run a script when the OOBE Sysprep starts. Furthermore, I need it to run every time the OOBE is launched as sometimes, we have to manually reboot if something glitches or goes wrong so the script will need to run again when the OOBE is resumed.
I know this is a tough one due to the limitations, but this will make the device rollout significantly easier.
Thanks,
Jake

How to launch a non-interactive process from an interactive session

The goal is to be able to test run a PowerShell script non-interactively with as little ceremony as possible.
It purposely runs differently on the CI server than it does when I run it interactively and I'd like to debug it. Ideally I could test this without having to set up a scheduled task. A command line utility would be fantastic.
What's different between the CI server (TFS build, non-interactive) and my machine (running interactively) is the value of [Environment]::UserInteractive. When I type powershell -c [Environment]::UserInteractive at the command line, I get True as expected. The goal is to be able to type someutility powershell -c [Environment]::UserInteractive and have it print False, just like it would print running under TFS build.
I'm willing to write the someutility in C++ if someone can outline how this works. I'm researching but an hour hasn't yielded anything. Everyone is already running non-interactive or wants to launch interactive, and I'm in the exact reverse scenario. It seems that there should be a way to do this from a non-administrator command line since the launched process should have the same user permissions but be restricted to non-interactive.
So far, I can get this desired [Environment]::UserInteractive = false behavior using a scheduled task and picking "Run whether user is logged on or not." But it's a pain, and I can't see the non-interactive stdout which I know is possible because TFS build shows it live. Also, the scheduled task doesn't end when run non-interactively so it's hard to tell when it's done.
The reference code for UserInteractive can be found here. It sets the property to false if and only if the window station for the process does not have the WSF_VISIBLE flag set. So your utility should create a new window station and desktop (see CreateWindowStation and CreateDesktop) and launch the child process there.
(Only the default window station for any given session is interactive, so presumably manually created window stations will not have WSF_VISIBLE set by default. If this does not turn out to be the case, you should be able to use SetUserObjectInformation to toggle the flag.)
To choose the window station and desktop for a child process, specify it in the lpDesktop member of the STARTUPINFO structure in the call to CreateProcess.

Task Scheduler WorkItem Not Running

I have a very specific problem that I need fixing. The major issue is that I don't exactly know how to properly search the remnants of my problem on google. Therefore I am coming to StackOverflow for advice in hopes that someone will assist me.
Summary
So I am writing an application which is to be PCI-compliant for the company which I am starting. The application involves IPC (Inter-process communication) and two "watch-dog" apps which monitor the status of the main application. One of these "watch-dog" applications is an updater (sends an HTTP Request to the server looking for updates of the application).
So! This method which I am using to check the server if the application is up-to-date is using the WinInet library and InternetOpen() to send the request. Then read the response of the page and use GetCookie() to store the response in a buffer. It shall then parse the response accordingly.
If the response says that the current version of my application is less than the version located on the server. It will then tell the customer (user) that their application is out of date, and ask them whether or not they want to update the software. If they choose to update the software, it will perform a Download And Execute from the internet and launch the update-installer on the user's PC.
The Problem
Unfortunately, windows is very "secure" when it comes to having an "unauthorized" application send an HTTP Request to an outgoing url, let alone download something from the server then execute it on the users PC.
My conclusion to this issue was to add the watch-dog programs to the Task Scheduler. That way after the main application is run, it will spawn the watch-dog programs and check if they are running with NTAUTHORITY privileges (which are granted by the Task Scheduler).
After implementing the code to create the task and point it to the location of the watch-dog programs, naming it, writing a description and everything. I executed the program. It ran without errors though here the REAL PROBLEM:
1) Programs executes
2) Spawns watch-dog programs
3) Watchdog program checks for new version
4) Version is found
5) Installer is downloaded, execute ... but
6) The installer does not appear on the screen!
When I run my 'Process Hacker' application to monitor all process actions. I can see that the new installer is download & executed. It is running as NTAUTHORITY/SYSTEM just like the watch-dog programs but it doesn't appear on the system.
I made sure that in my code the status of the window is set to SW_SHOWNORMAL not SW_HIDE. I also made sure that all flags are set accordingly. Though it doesn't appear on the screen!
When I run the application without adding it to the Task Scheduler as my user without NTAUTHORITY/SYSTEM status and just regular user status. It executes (obviously since I am already running as administrator) -- everything works fine. But after adding it to Task Scheduler and having it run with SYSTEM level privileges. The window doesn't appear on the screen visually. Why's that?
I would greatly appreciate anyone that is able to assist me with this problem. Thank-you!
edit 1
Can anyone help me understand how this user applied his fix in the registry? By reading the problem I can somewhat interpret that he had the same issue as me.
App is invisible if started from Task Scheduler without any user logged in
In any case, I am trying to use the advice that Gisley gave me to run the application in Interactive Mode. Possibly going to try to give that a try. Still looking for more answers but I am going to be working no this none-the-less in the meantime.
edit 2
I tried setting the INTERACTIVE FLAG and it had no effect unfortunately.
Allow me to just emphasize my problem:
For example I write a program which has message boxes and put it in a loop.
for
message box
get current pid
make process in the task scheduler
spawn new process as the task scheduler proc with NTAUTHORITY/SYSTEM
kill last proc pid
end for
Then when I execute it:
I get the message box. Then after new process opens with NTAUTHORITY/SYSTEM the message box does not appear anymore.
Same for if I open a calculator for example.
System("cmd.exe start /c calc.exe")
Program runs... opens calculator
Program gets NTAUTHORITY/SYSTEM status
ON the next loop it executes the calc.exe
I see it in my task manager but it doesnt appear on the screen
I hope the above helped emphasize the core of my issue. I dont see the processes opened by the task scheduler process id with NTAUTHORITY/SYSTEM rights... I dont see the procs executed by it on my screen, though I see them in the task manager | process hacker and they are running with NTAUTHORITY/SYSTEM privileges too.
A shot in the dark - try running the task in interactive mode, but you'll need to have a user logged on.
https://superuser.com/questions/616206/run-interactive-task-even-if-user-is-not-logged-on-windows
Alternatively, or additionally, pass parameters to the installer so that it installs silently.
Silent installation of a MSI package

unix script triggered from putty

I have triggered a Unix script which is basically put details from DB and create a xml for many id's(approximately 1000 items). After generating all XML it will post it to a queue. Right now I have doubt. My Script is running in a script. I am just monitoring it using PUTTY. will my script continuing executing if I shut down my system?
As Barmar's comment suggests, you should first start a screen session by typing screen in the shell.
Next, you should start your script.
Finally, you should disconnect your screen session and log out, with Control-a, d.
Whenever you login again, if you want to see the progress, you can do screen -a to reattach the screen.
If you executed your script in the foreground (or forked it to the background with &), it will terminate once your session closes.
To avoid this, you have a few alternatives:
Use nohup with & to force the program to ignore the SIGHUP signal.
Use a scheduler like cron, at, or your init system to schedule the process to run at/for a certain amount of time.
Use a virtual terminal multiplexer like GNU screen or tmux to run the program in the "background" on a resumable terminal.
Using a scheduler is probably the most versatile of the three, but a multiplexer can be useful if you'd like to see the script's output in real time.

wshshell.run(InstallPath, 0, true) not waiting to finish the installation and continues the script

Good afternoon,
I'm working on a project for my company to run an update on the employees workstations. The file is located on a webserver on our domain. The user will click on a link and start up the script.
I made two functions one to download the file to the C:\ and another to run the installer. The file is a .exe (I wish it was a .msi).
'' //executes the file at the location: installPath
Function launchUpdate(installPath)
dim wshShell
Set wshShell = WScript.CreateObject ("WSCript.shell")
errReturn = wshshell.run(installPath, 6, true)
End function
I'm using wshshell.run(installPath, 0, true) to execute the file. From what I understand, this should hide the install window and wait until the execution is complete.
It will start it up but it will not wait to complete the install because there are two steps in the .exe. Once the "preparing to install" is done, the script goes on with its job.
I could place Wscript.sleep. However, not all the machine have the same processing speed. So, I will not know how long to wait.
Do you have any suggestion what I could do?
Thank you,
Brian
Installation procedures usually spawn multiple processes (e.g. setup.exe, msiexec.exe, install.exe, idriver.exe etc), and it looks like your setup.exe exits after the first step ("Prepare to install") having launched another process that completes the installation. In this case WshShell.Run won't help wait for the installation to finish.
You should be able to do this using WMI, though. Namely, you can subscribe to the process creation and process deletion WMI events and this way monitor the creation of processes and wait for them to end. Here's a couple of the Hey, Scripting Guy! articles on the subject:
How Can I Monitor for the Creation of Different Processes?
How Can I Start a Process and Then Wait For the Process to End Before Terminating the Script?
It sounds like your setup file is spawning another process, and then exiting. If that's the case there's nothing you can do except maybe write a "wrapper" executable that waits for both processes to terminate, and invoking that instead.

Resources