Reboot and wait

Good morning,

I need your help creating a task on BigFix.
Here is my script:

waithidden cmd.exe /C “C:\Program Files (x86)\Siem\syn\Setup\Remove_RTC.vbs”

???

dos rmdir /s /q /f “C:\Program Files (x86)\Siem”

waithidden \***\packages\S\DeploymentClient\PreReq\DotNetFx\NDP48-x86-x64-AllOS-enu.exe /quiet /AcceptEULA /norestart

wait c:\windows\system32\msiexec /i “\\packages\S\DeploymentClientVB60S_HF01\PreReq\Teamviewer\TeamViewer.msi" /qn
wait c:\windows\system32\msiexec /i "\
\packages\S\DeploymentClientVB60S_HF01\PreReq\Teamviewer\TeamViewer TeamConnector.msi” /qn

waithidden \\packages\S\DeploymentClientVB60S_HF01\PreReq\vc12redist\vcredist_x64.exe /install /quiet /norestart
waithidden \
\packages\S\DeploymentClientVB60S_HF01\PreReq\vc14redist\VC_redist.x64.exe /install /quiet /norestart

wait c:\windows\system32\msiexec /i “\\packages\S\DeploymentClientVB60S_HF01\PreReq\s.Client.DeviceGuard.CatalogFiles.msi" /qn
wait c:\windows\system32\msiexec /I "\
\packages\S\DeploymentClientVB60S_HF01\PreReq\s.Flight.msi” /lv c:\sfr.log TARGET="c:\program files\siem\syn\bin" /qn
wait c:\windows\system32\msiexec /i "\
***\packages\S\DeploymentClientVB60S_HF01\PreReq\VNC Viewer.msi" /qn

if {(exists true whose (if true then (exists (computer name) whose (it as string as lowercase starts with “h-” as lowercase)) else false))}

wait c:\windows\system32\msiexec /i “\***.msi” /qn

endif

if {(exists true whose (if true then (exists (computer name) whose (it as string as lowercase starts with “d-” as lowercase)) else false))}

wait c:\windows\system32\msiexec /i “\***.msi” /qn

endif

if {(exists true whose (if true then (exists (computer name) whose (it as string as lowercase starts with “s-” as lowercase)) else false))}

wait c:\windows\system32\msiexec /i “\***.msi” /qn

endif

wait c:\windows\system32\msiexec /i “\****\packages\S\DeploymentClientVB60S_HF01\synclient.msi” /qn

I only need the “?” line. it reboots the machine and waits for it to be restarted before continuing. But impossible to achieve it. Could anyone help me?

Many thanks in advance to everyone and have a nice day

Welcome @gbernard !

Are you trying to add Reboot command and wait by swapping out “???”? Or perhaps you want to wait until the restart is not finished and your Remove_RTC.vbs will be restarting?

You can accomplish the following if you wish to add reboot with wait:

Your script command…

waithidden restart 60
pause while {pending restart}

Rest of your script command…

if your vbs file is doing reboot job, you can simply apply my second recommendation, which is pause while

I just tried making a shorter script but it didn’t work.

Completed dos xcopy “\\packages\test\1.txt" “c:\windows\test” /y
Failed waithidden restart 60
pause while {pending restart}
dos xcopy "\
\packages\test\2.txt” “c:\windows\test” /y

My bad, try these !

action requires restart
waithidden shutdown.exe /R /T 60
pause while {pending restart}

My test results:

   Relevant - Custom Action (fixlet:40)
At 05:46:33 -0700 - 
   ActionLogMessage: (action:40) Action signature verified for Execution
   ActionLogMessage: (action:40) starting action
At 05:46:33 -0700 - actionsite (http://MY TEST:52311/cgi-bin/bfgather.exe/actionsite)
   Command succeeded run cmd.exe (action:40)
   Command succeeded action requires restart  (action:40)
   Command started - waithidden shutdown.exe /R /T 60 (action:40)
At 05:46:35 -0700 - 
   Report posted successfully
At 05:46:35 -0700 - actionsite (http://MY TEST:52311/cgi-bin/bfgather.exe/actionsite)
   Command succeeded (Exit Code=0) waithidden shutdown.exe /R /T 60 (action:40)
   Paused pause while True (action:40)
   At 05:47:37 -0700 - 
   Report posted successfully
At 05:47:47 -0700 - 
   Client shutdown (Service manager shutdown request)
   At 05:50:04 -0700 - 
   ActionLogMessage: (action:40) ending action (client restarted)
At 05:50:04 -0700 - mailboxsite (http://MY TEST:52311/cgi-bin/bfgather.exe/mailboxsite538043272)
   Not Relevant - Custom Action (fixlet:40)
1 Like

I think you may want try ‘restart’ without the ‘waithidden’.

If we use the OS ‘shutdown.exe’ command to reboot, the action will be marked as Failed because the computer rebooted while the action was running. Using the ActionScript command ‘restart’ allows the client to anticipate the reboot.

I’m not sure this can be done in one action, usually I’ve split things like these into three separate tasks and put them into a baseline, but you could try

dos xcopy "\\packages\test\1.txt" "c:\windows\test" /y
restart 60
pause while {pending restart}
dos xcopy "\\packages\test\2.txt" "c:\windows\test" /y
1 Like

I just tested it and it doesn’t work. Could you tell me more about your method for dividing things like this into three separate tasks and placing them in a baseline.

Anyone have another idea? Because I still can’t do it

To test I created three Tasks with the following ActionScripts:

  • TaskSequenceTest1:
delete __appendfile
appendfile I did thing one at {now}
appendfile Boot time was {boot time of operating system}
appendfile System uptime is {uptime of operating system}

delete c:\temp\thing1.txt
move __appendfile c:\temp\thing1.txt
  • TaskSequenceRebootAndWait:
// when using the 'restart' actionscript command, *must* specify a time 
//   or it will wait until the user acknowledges a reboot message.
restart 60
  • TaskSequenceTest2:
delete __appendfile
appendfile I did thing two at {now}
appendfile Boot time was {boot time of operating system}
appendfile System uptime is {uptime of operating system}

delete c:\temp\thing2.txt
move __appendfile c:\temp\thing2.txt

Add all three tasks to a Baseline and configure the order, so the reboot task comes between the other two…

Action the Baseline to the client.

Before Reboot on client:

After reboot on client:

We can see from the text files on the client that both Tasks were executed and there was a reboot between them:

PS C:\temp> type thing1.txt
I did thing one at Wed, 03 Apr 2024 06:39:46 -0700
Boot time was Mon, 26 Feb 2024 08:32:09 -0700
System uptime is 34 days, 18:38:40.625
PS C:\temp>
PS C:\temp> type thing2.txt
I did thing two at Wed, 03 Apr 2024 06:43:31 -0700
Boot time was Wed, 03 Apr 2024 06:41:15 -0700
System uptime is 00:02:15.250

While client was rebooting, after Task 1:

After client rebooted, after running Task 2:

Hope this helps!

2 Likes

Following Jason’s recommendation does work. Break your script up into three parts. Part 1 is up to and including restart 60. Part 2 is the pause while line. Part 3 is the remaining script. Add them to a baseline.

1 Like

Also I did try and run a test of both commands in one task, with a ‘restart’ command between them. That does not work, the entire action runs while the ‘restart’ countdown is on the screen, it does not wait for the reboot to occur before running the rest of the action script. It does need to be three separate tasks.

Thank you very much, I’m moving forward :-). I can now reboot and continue. However, I now have another problem. The first task of my baseline is the following: waithidden cmd.exe /c cscript “C:\Program Files (x86)\Siemens\syngo.via\Setup\Remove_RTC.vbs”

Which allows me to delete software before moving on to the second task which is my reboot. But it doesn’t wait for the uninstallation to finish. It executes the .vbs and goes straight to reboot. Is there a way to tell it to wait for the .vbs to finish executing?

It’s good I found :-). Many thanks to everyone for your help. Great atmosphere on this forum :wink:

1 Like

You could try to add this after you call your .vbs

pause while {exists running application "Remove_RTC.vbs"}

I have done this with .exe, I have not tried with .vbs

Glad to hear you have it solved based on your next post.

If the VBScript was immediately returning to the shell instead of waiting for completion, you could probably work around it by modifying the script itself to wait on whatever process the script is spawning. You might also be able to use the ‘override’ options on the ‘wait’ command, we have a couple of different ways of determining whether the child processes have completed.

I’d check the different ‘completion’ options at https://developer.bigfix.com/action-script/reference/execution/override.html

Is the script actionscript command of any use here? Possile that will spawn the vbs script and wait for it to exit. I used to use this method for executing vbs scripts but haven’t used it in years with vbs being less common that it once was. Not really sure if it can be used with the newer override features.