Notifications
Clear all

[Closed] Dos commands freeze UI – even when using .NET Shell

Hi all

I have 3 Dos commands
Then I have a loop that runs X amount of times, based on the amount of contend in an array
In the loop I have another 14 Dos commands, with a progress bar updating between EACH dos command.
The Loop ends and I have another 3 Dos commands.

Doscommand freezes the UI untill the script is done. Any progress bars dont update during the freeze
HiddenDosCommand does the same thing. However if I use the switch

HiddenDosCommand ("bla bla bla") donotwait:true

…then the commands run nice and fast and the UI doesnt’t freeze, BUT I CAN NOT do this, since each Dos command is dependant on the previous Dos command to complete, before it can continue, otherwise I get errors.

For example I can’t create a folder with one command…
then copy files into it
then rename it
then copy more files
then delete the folder
…if the “create folder” part wasn’t complete. This is a simplification in my explanation, as the actual commands are complex and take between 1 and 4 seconds to complete each

For the same reason ShellLaunch can’t work, because each previous command should complete beforew the next one starts.

So I thought the answer was .NET

I have a function:

fn HiddenDotNetCommand Command=
(
	Process = DotNetObject "System.Diagnostics.Process"
	Process.StartInfo.FileName = "cmd.exe"
	Process.StartInfo.Arguments = "/C " + Command
	Process.StartInfo.UseShellExecute = false
	Process.StartInfo.CreateNoWindow = true
	Process.Start()
	Process.WaitForExit()

	--Process.StartInfo.UseShellExecute = false
	--Process.StartInfo.RedirectStandardOutput = false
	--string output = Process.StandardOutput.ReadToEnd()
)

The commented out bits is other things I tried

Then I call the Dos command with something like:

HiddenDotNetCommand ("bla bla bla")

Everything works beautifully if the array only has 1 object and the loop runs just once. If however there are 3 or 4 or more objects in the array, and then the loop runs 3 or 4 or more times, I AGAIN get the stuck UI until the script completes. It works fine, except the UI freezes.

Thoughts?

8 Replies

Hi Morne,
Have you tried using “windows.processPostedMessages()”. This gives time to allow for any windows messages to be processed, like updating the UI.

Cheers,
Daniel

1 Reply
(@morne)
Joined: 10 months ago

Posts: 0

Thanks Daniel, that did the trick. I was also feeding my progress bar integer values instead of float values. Finally working now. Thanks to everybody that looked and tried to help with private messages

 PEN

Interesting. I have never seen that command.

2 Replies
(@dgsantana)
Joined: 10 months ago

Posts: 0

It’s a hidden gem. Very useful for long tasks, just call it once every update, and UI won’t freeze.

Cheers,

(@denist)
Joined: 10 months ago

Posts: 0

I know you have a solution, but when I need to use DosCommand or HiddenDosCommand on a sequence of operations I use “&” between the commands.


someComand "file" & someOtherCommand "file" & thirdCommand "file"

for my needs i use DisableProcessWindowsGhosting as a global MAX setup

1 Reply
(@try2script)
Joined: 10 months ago

Posts: 0

you mean, only for your own usage or for your own tools that can use other users as well?

I have noticed that windows.processPostedMessages() is working great, but inside loops the process takes much longer unfortunately.