Win10 Tweaks and ShellExecute Wait?

Started by JTaylor, August 09, 2016, 09:10:34 AM

Previous topic - Next topic

JTaylor

I felt compelled to upgrade to Win10 on my development machine as some users have migrated and I want to make sure my applications work properly in that environment.   I am currently trying to make this move less ANNOYING!!! and am hoping someone might have some tips.    I have changed the default "open" of scripts to Winbatch_IF so I no longer have to click for every script to run.   When I launch an unsigned app from within a script it still prompts...is there a way to stop that from happening?

I have a number of instances where one can launch an editor and it waits for you to close the editor before proceeding.  I now get security errors and the only thing that works is ShellExecute but don't see a WAIT option.  Suggestions?

Any way to get shortcuts on a toolbar to not prompt every time you use one?   I think it is because they have an "Unknown Publisher".

Thanks.

Jim

td

You are describing UAC related  behaviors and since UAC has been around for almost 10 years, WinBatch support documentation has managed to accumulate quit a bit of information on the subject.  You might what to consider re-reading the UAC User's Guide articles in the Consolidated WIL Help file as a starting point.   There are also many articles in the Tech Database that more or less cover the same ground with some additional info on specific issues like mapped drives, the unknown publisher prompt,  the Task Scheduler kludge, and the like.

ShellExecute dose not have a 'wait' option because of the way the underlying shell API works but it many cases you can use either AppWaitClose or WinWaitClose to get the desired effect.



"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

JTaylor

I am familiar with UAC.   I adjusted and things have worked fine since Vista and Win7 (didn't bother much with Win8) but seems Win10, and probably 8, has carried things further so thought I would ask.

Was hoping there was a wait to generate a wait from the Run/Execute options.   Users can define what editor they use so those two options aren't very useful since it is entirely possible they may have those open in a different context, in addition to having no idea what "Window" I would be waiting to close, at the same time and, if I remember correctly, that would lock my app if they were.

It is so wonderful being so safe and secure these days....just wish functional came with the package but as someone once said...you can have "security" or "liberty" but not both.

Jim

td

Quote from: JTaylor on August 09, 2016, 11:13:00 AM
I am familiar with UAC.   I adjusted and things have worked fine since Vista and Win7 (didn't bother much with Win8) but seems Win10, and probably 8, has carried things further so thought I would ask.
There are only two significant differences between UAC on Vista/Windows 7 and Windows 8/Windows 10 that I am aware of.  One is that on 8 and 10 applications that do not require administrator level privileges start with restricted admin privileges when UAC prompting is turned off.  On Vista and 7 they started with full privileges when UAC prompting was turned off.  The other is that on 8 and 10 you can't modify some system settings or run Windows RT applications, if you completely turn of UAC  via group policy or directly modifying the registry.  On Vista and 7 the system settings restriction did not apply when UAC was completely off.

As a practical matter, I develop in both environments and haven't found Windows 10  to be much different than 7 with respect to UAC related issues.  On Windows 10 I did have to add a app compatibility setting to the registry for one application I need to run with full admin privileges that was not manifest to do so right after the OS came out.  But the author subsequently added the manifest to the exe so even that is not an issue now.
   
Quote
Was hoping there was a wait to generate a wait from the Run/Execute options.   Users can define what editor they use so those two options aren't very useful since it is entirely possible they may have those open in a different context, in addition to having no idea what "Window" I would be waiting to close, at the same time and, if I remember correctly, that would lock my app if they were.

It is so wonderful being so safe and secure these days....just wish functional came with the package but as someone once said...you can have "security" or "liberty" but not both.

AppWaitClose takes a process ID so with a good bit of fiddling it is possible to target a specific instance of an application.   
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

td

A personal favorite:
Code (winbatch) Select

ObjectClrOption("use","System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
objProcess   = ObjectClrNew("System.Diagnostics.Process")

; Use ShellExecute to start the app instead of one of the 
; create process functions.
objProcess.StartInfo.UseShellExecute = ObjectType("BOOL", 1)
objProcess.StartInfo.FileName = "Notepad.exe"
objProcess.Start()

; Wait for the process to terminate.
objProcess.WaitForExit()
objProcess.Dispose()

Message("Test","Notepad is gone.")
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

JTaylor

Did want to say thanks.  Still working on tweaking things but appreciate the code.    Finally dawned on me "I" could sign the one app I use and that solved one VERY BIG annoyance.   Still haven't found a way to make lnk files on a toolbar not prompt every time I use them.   Have seen postings about using Group Policy Editor but that is not available on Home and wasn't sure about running a "solution" that has been posted around.

I think I finally decided that most people wouldn't be running old apps that needed the elevation so may leave things alone that were hollering about Elevation issues when using RunWait() after discovering apps like Notepad work okay.  I will keep that code you posted though as I am sure the day is coming when it will be needed.

Thanks again.

Jim

td

 I don't see the "Unknown Publisher" prompt very often and I do use several unsigned applications regularly.   It may be because I have 'Smart Screen' turned off or because the applications are launched from a 'secure' location. Not sure how much either effects the prompt, however.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

JTaylor

Not sure.  Have seen posts indicating I am not the only person with the problem.   Sometimes I am a complete idiot though as the other thread demonstrates.   I think I have sorted the WinBatch part of my problem so won't bother everyone with the other stuff.   Thanks again.

Jim

td

Creating a new ShellExecuteWait function has been on the todo list for a long time.  Who knows, if we will get to it...
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

JTaylor

Might be useful but my oft repeated requests would be much higher on my list :)

td

Adding some kind of wait to ShellExecute is an oft repeated request since the arrival of UAC in terms of the number users requesting it.  Since there are several ways to more or less mimic the functionality, it has remained subordinate to implementing other functionality.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade