WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: evanhall on August 06, 2019, 06:29:42 AM

Title: Trouble with Run Command
Post by: evanhall on August 06, 2019, 06:29:42 AM
Good morning!

I am currently switching from version 2017a on Windows 7 to 2018b on Windows 10. One of the biggest problems I have run into is an issue with a simple run.

We currently have a run that does the following

run(strcat("X:\somearea\openfile.hta"),"")

It basically opens up a file that people can click, for some reason this won't work in 2018b on a Windows 10 Computer.  Anyone know if this is a bug or what the problem could be?

Thank you!
Title: Re: Trouble with Run Command
Post by: td on August 06, 2019, 07:08:06 AM
If by "bug" you mean a defect in Winbatch, it definitely is not a bug in WinBatch.  Your problem is related to the change in the execution environment.  You should also consider adding more relevant details to your post when describing a problem.  More details will greatly improve your chances of getting a quick and accurate solution.  It also saves potential responders time and effort because they do not have to go through a  long litany of possible causes and solutions or repeated "that didn't do anything" posts.   

While there isn't enough detail to determine the cause of your problem, the fact that your post shows an "X" drive letter may offer a possible cause.  That is because using an "X" suggests your path is to a mapped drive and because you switched from Windows 7 to Windows 10.   See the following article for an explanation as to why that might be the issue:

https://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/UAC+Mapped~Drives~Issue~with~UAC.txt (https://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/UAC+Mapped~Drives~Issue~with~UAC.txt)

Switching from Windows 7 to Windows 10 is relevant because MSFT changed how UAC settings operate between Windows 7 and Window 10.

But again this is but one of several possible explanations.
Title: Re: Trouble with Run Command
Post by: evanhall on August 06, 2019, 07:27:41 AM
Duly noted. First time poster, long time lurker. 

I appreciate your help and its already leading me down a path on trying to fix things with UAC.  The good news is that I know more about UAC!  The bad news it didn't seem to work, I changed the path to the c drive as well just to give that a go. 

I agree 100 percent that the problem is most likely the switch from Windows 7 to 10.  My hope was that it was something simple so I posted something simple. No ill will towards something I use daily!

I guess the synopsis of the question is I have a program that opens up an hta file after a click.  The code used is the code I posted above.  It really just is as simple as it seems the word run(filename, "") and the second quotation marks.  I guess any help would be appreciated,  even if there is a better way to open and display this HTA file. 

Thank you.

Title: Re: Trouble with Run Command
Post by: evanhall on August 06, 2019, 08:13:49 AM
Appreciate the help, I found a fix.  For anyone else with this problem, which I highly doubt.  The run command was too vague.  I found opening it in a internet browser and then the file worked much better and easier.
Title: Re: Trouble with Run Command
Post by: td on August 06, 2019, 02:03:40 PM
One "it didn't work"...

Your problem with the Run function is likely UAC related.  On most Windows systems the .hta extension is associated with the OS provided executable Mshta.exe in the registry file extension associations.  The problem is that MSFT has seen fit to prevent elevated processes from starting an elevated Mshta.exe with a .hta file as a command-line parameter.    The simple workaround for this is to use ShellExecute instead of Run to launch the .hta file.

You could always modify the registry somehow to allow .hta file to execute with elevated privileges but that could introduce a potential security risk.
Title: Re: Trouble with Run Command
Post by: td on August 06, 2019, 02:25:52 PM
Another approach that appears to work is simply making the .hta file a parameter of the Mshta.exe program using the run command.

Code (winbatch) Select
run('mshta.exe', 'c:\projects\batdll\test\about.hta')


This approach skirts the problem by bypassing the registry association that causes the elevation restriction.