My requirement is to restart the windows vm after the software gets installed, I am automating the entire process using chef. Is there any method for doing that?
Can we do through power shell ?
Is there any method for chef to that ?
The windows cookbook offers a reboot resource.
As mentioned above check out the links windows cookbook & windows reboot. All my info is gathered from the previous links.
Include the WindowsRebootHandler in the recipe
include_recipe 'windows::reboot_handler'
Create a reboot block
windows_reboot 30 do
timeout 30
reason 'Restarting computer in 30 seconds!'
action :nothing
end
timeout: timeout delay in seconds before rebooting. default is 60 seconds
reason: reason for the reboot. default is 'Opscode Chef initiated reboot'
Notify the reboot block to trigger the reboot
notifies :request, 'windows_reboot[30]', :delayed
:delayed - notification is queued up and executed at the very end of a chef-client run
:immediately - notification is ran immediately
Related
an Hyper-V Server 2019 attempts to run a network powershell script at computer startup, through the Task Scheduler, however this script will not run at startup, nothing happens.
Once the Hyper-V server has booted, if the script is manually launched through the Task Scheduler, it will run.
Could it be possible that the script will fail to run because the network is not available at that time?
As suggested by #Hazrelle, delaying the script start for 5 minutes did the trick. I have followed instructions in this article:
https://www.maketecheasier.com/start-scheduled-tasks-with-delay-windows/
I have a process in windows which i am running in startup. Now i need to make it if somehow that process get killed or stopped i need to restart it again in Windows 10?
Is there any way. Process is a HTTP server which if somehow stopped in windows i need to restart it. I have tried of writing a power-shell in which I'll check task-list status of process and then if not found I'll restart but that is not a good way. Please suggest some good way to do it.
I have a golang exe; under a particular scenario my process got killed or stopped i need to start it up again automatically. This has to be done imediately after the exe got killed. What is the best way to achieve this?
I will give you a brief rundown. You can enable Audit Process Termination in local group policy of the machine as shown below. In your case, success audits would be enough. Please note that the pic is for Windows 7. It may change with OS.
Now every time a process gets terminated, a success event will be generated and written to the security eventlog.
This will allow you to create a task scheduler that triggers on the generation of this event that calls a script that would run the process again. Simple right?
Well, you might have some trouble setting that task up especially when you want to pass details about the generating event to the script. This should help you get through that.
You can user Task scheduler for this purpose. There is a option of "restart on failure" which can be selected and whenever your process get failed it will restart again.
Reference :- https://social.technet.microsoft.com/Forums/windowsserver/en-US/4545361c-cc1f-4505-a0a1-c2dcc094109a/restarting-scheduled-task-that-has-failed?forum=winserverManagement
If I run the following command in my session...
(Get-Process -Id $pid).CloseMainWindow()
I am able to gracefully shut down a process (no modal windows or other popups arise).
If, however, the pid is in another user's session on the same machine (running RDS), the process does not close, and CloseMainWindow() returns FALSE (it returns TRUE if it's running in my own session). It also works if I run the powershell from the other user's session.
I specifically need a way to gracefully shut down the program as the program has a few important cleanup actions required to keep its database in order. So stop-process or process.kill() will not work.
After lengthy research, it does not seem possible to do this. There is, however, a solution which met at least some of my requirements.
You can create a Windows Scheduled Task which is triggered on session disconnect. This allows you to run a cleanup job as the user, rather than as the administrator, which allows programs to exit gracefully.
It has two major drawbacks....
It is called even if the user just has a minor network interruption (so you have to build a wait() function in the script to sleep for a bit and then check if it is still disconnected - not a clean solution.
It isn't called during a log-off event. For that you need to use a logoff script triggered by GPO.
Hope this helps someone in the future.
Is it possible to increase the time when calling stop or restart on a generated linux/unix service launcher, before the call fails saying that the call timed-out? I found that on windows you have to edit the registry since its implemented as a Windows Service, but couldn't find any information on changing the timeout on linux/unix.
By default, the timeout is 120 seconds. For Linux/Unix service launchers, you can set the VM parameter
-Dinstall4j.daemonTimeout=600
to increase it to 600 seconds.
I am running my installer in silent mode (-q option).
After starting, the installer quits. The error.log shows the entry:
"The application is running. Please close instances and run this installer again".
However, there is no other instance of the installer running.
Note - The installer is launched in the Windows local system account.
I encountered the exact same issue with an updater installer being run in unattended (silent) mode and launched from a Windows service. I discovered that there were two reasons for the updater failing to complete:
The unattended mode installer was being invoked with arguments -q -wait 20 (these are the defaults when generating an updater application using the install4j UI). The -wait argument causes the installer to wait for running applications to close before progressing to the stage where the Welcome screen would normally be shown in an interactive install. It does not attempt to close them itself. If the applications don't disappear within 20 seconds, the installer exits at this early stage with the error.log message "The application is running. Please close instances and run this installer again". (In interactive mode the user would be shown a screen at this stage asking them to close the running applications.)
(Note: -wait only seems to check for the presence of application processes (user launched apps, UIs etc). Installed services that are running are not considered a blocker, probably because they are automatically stopped as part of the Install files action.)
I had already added actions later in my installer to close down the application processes before installing the update, but the -wait argument was not allowing it to progress that far. I removed the argument from the "Set installer arguments" action in the updater app and this allowed the installer to progress beyond the welcome phase.
The 'Check for running processes' action, using a Close strategy of 'Soft close immediately', failed to close any user-launched applications running (UI applications in my case) when the installer was launched from the Windows service. This in turn caused the unattended update to fail due to locking issues overwriting the installed files.
However using the Close strategy of 'Terminate immediately' did allow the service account to successfully kill the running applications and allowed the installation to complete.
I ended up using a sequence of "Stop a service", "Check for running processes (soft close)" (which works when the installer is run in interactive mode by a user), then "Check for running processes (Terminate immediately)" at the start of the Installation section to cover all bases.