October 30, 2012

Controlling Apps that Run as Admin

Filed under: Automation,Vista,Windows 7,Windows 8 — Marcus Tettmar @ 10:16 am

By now you are probably aware of UAC (User Account Control) that came along when Vista was released. And you probably know that to do anything like copy files to Windows\System32 or Program Files or do other administrative stuff you need to be running as Admin, or you’ll get the UAC prompt come up asking you for permission to continue. And when you continue the thing you launched is then running as admin.

For sensible reasons, Windows is designed so that an ordinary level process – i.e. an application that is running under a standard user account without administrative privileges (let’s call it an un-elevated application) is not allowed to manipulate, interact with or exchange information with an elevated process (one running with administrator privileges or “As Admin”).

Macro Scheduler runs “as invoker”. In other words it runs at the level of the user who starts it. In most cases, and by default, that means it is running without administrator privileges. Unless you have disabled UAC, or chosen to run Macro Scheduler as admin, or have set the Macro Scheduler shortcut properties to launch Macro Scheduler as admin, then Macro Scheduler will run as a standard user without administrative privileges.

Since a standard process is not allowed to manipulate an admin process, Macro Scheduler is not able, by default, to send keystrokes into windows belonging to processes running as admin.

Try it. Run Notepad as admin and then try the following simple macro in Macro Scheduler:

Setfocus>Untitled – Notepad
Send>Hello World

You’ll see nothing happen. The text “Hello world” will not arrive in Notepad.

Now close Notepad and run Notepad as normal and of course the script works.

So what do you do if you NEED to send keystrokes into an admin level window? Well, unless it is possible to run that process as an ordinary user you will need to also run Macro Scheduler as admin.

To run Macro Scheduler “elevated” as admin, right click on the Macro Scheduler shortcut and select “Run as Administrator”. If you have UAC enabled (the default) you’ll see the UAC confirmation box pop up to make sure you’re happy to continue. Ok that and now Macro Scheduler is running as admin.

Now try running Notepad as admin again and you’ll find our little macro works.

Some legacy applications written before Vista came along were developed assuming the user had administrative privileges, which was common in the days of XP. This was poor practice but widely done. A common transgression was that they would write their settings and files to the Program Folder. In order to run these applications under Vista or later they would therefore have to be run as Admin, unless there was any way to force them to write data to another more sensible location. Sadly there are still applications that do this, especially older ones that are no longer maintained. Since the only way to use such legacy apps on Vista/Win7/Win8 is to disable UAC or set them to run as admin and put up with the UAC prompt, if you need to automate them you’re going to have to also run Macro Scheduler (or your compiled macro) as admin.

Short version: If you wish to automate an elevated application (one that runs as admin), Macro Scheduler or your compiled macro, also needs to be running elevated.

March 25, 2009

IE8, Vista, UAC and WebRecorder/VBScript Web Macros

Filed under: General,Vista — Marcus Tettmar @ 11:50 am

I just upgraded to IE8 on a new Vista desktop with UAC enabled out of the box. Now, WebRecorder macros and VBScript macros which automate Internet Explorer fail to work unless Macro Scheduler is run as Admin. IE’s Protected Mode is turned off, and “Allow scripting of Internet Explorer webbrowser control” is enabled. But if you try to run a WebRecorder macro without elevating Macro Scheduler to run as admin you will see a delay followed by:

Error Calling DLL – Possible wrong number or type of parameters.

If you try and run a VBScript macro which creates an Internet Explorer instance using CreateObject you will get the following error after a delay:

Microsoft VBScript runtime error :429

ActiveX component can’t create object: ‘InternetExplorer.Application’

This problem did not occur with IE6 or IE7.

If you run Macro Scheduler as administrator, or disable UAC everything works fine. To run Macro Scheduler as admin right click on the Macro Scheduler icon and select “Run as administrator”.

I have emailed the IE team at Microsoft to find out if there is any better solution. I will let you know what they say.

Update: No news from Microsoft but after lots of experimentation we discovered some very surprising things which don’t really make any sense, but have enabled us to make some changes in order to solve the problem. The next Macro Scheduler update will therefore have the above issues fixed.

January 11, 2009

Keyboard Shortcuts in Windows Vista

Filed under: Automation,Vista — Marcus Tettmar @ 9:02 am

Here’s a handy list of keyboard shortcuts in Windows Vista. No doubt valid for Windows 7 too.

Did you know you could focus the taskbar with Windows Key + T:

Press LWinKey
Release LWinKey

I didn’t!

January 11, 2007

Restart Aero Glass

Filed under: Vista — Marcus Tettmar @ 2:56 pm

Sometimes Vista appears to lose Aero Glass. Aero Glass is the fancy effect that gives windows a semi-transparent border and adds a certain gloss to the desktop. Purely aesthetic but very pleasing. But very occasionally my screen flickers and then Aero Glass gets disabled. I’m not sure why – my best guess is the memory somehow gets maxed out so Vista downgrades the display. Trouble is it doesn’t come back again automatically. I’ve always had to reboot the machine, which is annoying. But I’ve just discovered this little trick to get it back: Stop and restart the “Desktop Window Manager Session Manager” service using these commands in an elevated DOS prompt:

net stop uxsms
net start uxsms

And back comes the lovely shine! 🙂

December 11, 2006

Works with Vista – Official

Filed under: Vista — Marcus Tettmar @ 2:17 pm

Works with Windows Vista We’ve recently entered the Microsoft Windows Logo Program and just obtained the Works with Vista logo for Macro Scheduler 9.0 🙂

December 5, 2006

Web Automation in Vista

Filed under: Announcements,Automation,Scripting,Vista — Marcus Tettmar @ 1:51 pm

To run WebRecorder, or VBScript macros which automate Internet Explorer in Vista (IE7), you will first need to disable “Protected Mode”. Consider this simple VBScript code:

Dim IE
Set IE = CreateObject(“InternetExplorer.Application”)
IE.Navigate “http://www.mjtnet.com”

In IE6 and in IE7 under XP this code would create a new IE instance and then navigate it to mjtnet.com. But Vista adds something to IE called “Protected Mode” and for some reason Protected Mode causes the Navigate method to open up a new IE window. This is most annoying because it means any subsequent code in a script like the one above would fail because IE object refers to the instance created with the CreateObject call, but the page is now in the second instance.

You can disable “Protected Mode” in IE under Tools/Internet Options/Security. This puts things back to normal and means code like the above will continue to work.

One known issue with WebRecorder’s IEAuto.DLL is that the WaitNewIE function hangs when using IE7. We’re working on this now. This function is only used when an action in IE causes a new window/tab to appear. Apart from that, once you have disabled “Protected Mode” WebRecorder/IEAuto works fine with IE7/Vista.

Update: Version 1.78 is now available, fixing the issue with WaitNewIE on IE7.

December 4, 2006

Running Legacy Apps Under Vista

Filed under: Vista — Marcus Tettmar @ 3:31 pm

If you’re thinking about upgrading to Vista and want to know if your favourite apps will run, here’s a very simple test to try first. In XP create a standard, restricted user account. Now try and run your apps. If they fail to run, or pop up access denied errors when trying to save data or settings, then they will very likely have similar issues when running under a default Vista install.

With previous versions of Windows the default account was always an administrator. If you’ve installed XP out of the box you are probably running as admin. And every application you start has administrator privileges. This means it can do things like write to the Program Files directory, or HKLM, etc. Because this is default, software developers have got into a bad habit of assuming that the user is an administrator. Believe it or not there are developers out there who don’t even realise there’s a different kind of user, and have never tested their software under a restricted user account. Until now this hasn’t been much of an issue because the vast majority of users are administrators anyway.

But with Vista things have changed, for the better. Now, while the default user account is still the Administrator account, all applications run at least user privileges. Applications that require administrator privileges to run, e.g. system configuration tools, can be marked as such and when started will prompt the user to ask permission to continue. This means that the user now knows when an app is about to do something that requires admin rights. If the user is not an administrator she can ask the admin to come and enter his/her password and allow the administrative function to proceed. Or not. This new approach will cut down on malicious programs, trojans and viruses etc, because a process that needs to make a system change cannot do so invisibly. If the process is not marked as requiring Admin privileges, it will not be able to perform administrative tasks. If it is marked, it will pop up a confirmation box.

So lots of applications you have been using happily on XP may be assuming that you are an Administrator. And you may find when you try to run them on Vista that they fail to work. Perhaps because they try to store settings in HKLM or Program Files. If the application lets you change the folder it uses to store settings and output files, change it to a folder in your personal Documents folder.

If you can’t change the fact that it needs to write to a privileged location, and assuming you are logged in as Administrator, one workaround is to run the app with Admin privs. Right click on the application and select “Run as administrator”. Or modify the shortcut. Right click on your shortcut, select Properties then Compatibility and check the “Run this program as administrator” option. But please only do this for applications you trust! Don’t go and give any old application administrative privileges, or you defeat the purpose of this new security feature. Likewise, please don’t disable UAC (User Account Control) altogether.

I’m running a small number of tools that I have to do this for. For now I’m running them as Admin. But I hope the developers will issue updates soon so that I can run them more cleanly under Vista. Reading through various developer groups that I’m a member of I’m constantly amazed at how many developers only just seem to be thinking about Vista, and seem to be confused about these simple changes. Yet Vista has already been released to businesses and has been in beta for the best part of a year.

November 28, 2006

Free Copies of Vista and Office 2007!

Filed under: Vista — Marcus Tettmar @ 9:52 pm

But only if you’re in the USA. If you are, you might want to check this out: http://www.powertogether.com/. According to this you just have to watch three webcasts on each product within 30 days of registering and Microsoft will send you Vista Business and Office 2007 Pro, for free!

November 25, 2006

Running Vista

Filed under: General,Vista — Marcus Tettmar @ 10:51 pm

So I downloaded the final version of Vista last week and I’m now running Vista as my main environment. Am I mad? Let’s see how it goes. Lots of my favourite apps need to be run as admin because they write to the programs folder, or HKLM. For years, developers have made the bad habit of assuming the user is admin due to the way previous versions of Windows install by default. But with Vista defaulting to run apps at least user privileges, all that will have to change. But until these legacy apps get updated or replaced, there will be lots of workarounds. And I wouldn’t be surprised if many people switch off the new security features of Vista in order to run their old apps, and in so doing defeat the purpose of the main focus of this new operating system! Time will tell. Of course, Macro Scheduler is already Vista compliant and v9.0 has been built with Vista in mind, so no problems there.

I’ve already found what appears to be a bug in the final release. Vista wouldn’t let me attach to a network printer, shared by an XP machine. It kept saying access denied. Yet I was able to add the printer driver manually under LPT1 and then change the port to the network name of the shared printer. Then everything worked. Go figure.

Since RC1 I’ve been baffled by the shutdown options. And it seems I’m not alone. Why are there so many ways to switch off Vista, and what does the off button do that’s different to the six shutdown menu options? Do I want to lock/log off/switch user/switch off/restart or sleep!? Maybe I’ll just leave it running and not touch anything! Seems this is a result of design by committee and corporate bureaucracy.

October 20, 2006

Get Back Vista Run Command!

Filed under: Vista — Marcus Tettmar @ 3:47 pm

The biggest annoyance for me with Vista is that, by default, the “Run..” option is no longer on the Start menu. If you’re like me it’s probably one of the most used items on your computer! Now, you can use the search box in Vista in the same kind of way. But there’s no drop down bringing up the last typed entries. Apparently, Microsoft removed the Run box from the Start menu because they seem to think most people won’t need it any longer. Hmph. I’m obviously not most people!

Luckily you can get good old “Run command” back by right clicking on the Start menu and selecting “Properties”, then “Start Menu”, then “Customize” and checking the “Run command” option.

But the simplest solution is one I missed completely! Just press the Windows key and R together. Win+R is the shortcut for the Run command. Simple!

Older Posts »