Windows Vista/7 elevation and cm_OpenAsUser

English support forum

Moderators: white, Hacker, petermad, Stefan2

User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48028
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Do you use a replacment for notepad.exe, e.g. a multiple document editor?

I ask because error 31 is a DDE error (dynamic data exchange). It happens when the editor is already running in the background with normal user rights, and you try to launch it with other user rights, and the editor tries to activate its already running instance. This is prevented by Windows account control.
Author of Total Commander
https://www.ghisler.com
User avatar
DrShark
Power Member
Power Member
Posts: 1872
Joined: 2006-11-03, 22:26 UTC
Location: Kyiv, 68/262
Contact:

Post by *DrShark »

ghisler(Author) wrote:Do you use a replacment for notepad.exe, e.g. a multiple document editor?
No, it's a pure Vista's notepad.exe.
ghisler(Author) wrote:I ask because error 31 is a DDE error (dynamic data exchange). It happens when the editor is already running in the background with normal user rights, and you try to launch it with other user rights, and the editor tries to activate its already running instance. This is prevented by Windows account control.
The error 31 appears even when there is no notepad.exe instances already launched. If it matters I have UAC disabled on Vista.
Donate for Ukraine to help stop Russian invasion!
Ukraine's National Bank special bank account:
UA843000010000000047330992708
User avatar
DrShark
Power Member
Power Member
Posts: 1872
Joined: 2006-11-03, 22:26 UTC
Location: Kyiv, 68/262
Contact:

Post by *DrShark »

In the email Christian corrected the meaning of Error 31: it is SE_ERR_NOASSOC, which means: "There is no application associated with the given file-name extension."
Christian Ghisler wrote:It probably means that the target user account does not allow to run
EXE files. What type user account do you try to use for launching the
app? Can you login as that user to your system?
Unfortunately this error 31 appears immediately after I press the button with 2 asterisks, so I can't even enter a username and password. (however that input dialogs with username and password requests appear for me if I use cm_OpenAsUser command.)
Donate for Ukraine to help stop Russian invasion!
Ukraine's National Bank special bank account:
UA843000010000000047330992708
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48028
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

I have checked that now: Vista is missing the subkey "runasuser" below the key:
HKEY_CLASSES_ROOT\exefile\shell

I have tried to add it manually from what Windows 7 uses, but it doesn't work.

The only solution would be to change the command to:
runas /user:username c:\windows\notepad.exe

You will then just be asked for the password.
Author of Total Commander
https://www.ghisler.com
User avatar
DrShark
Power Member
Power Member
Posts: 1872
Joined: 2006-11-03, 22:26 UTC
Location: Kyiv, 68/262
Contact:

Post by *DrShark »

ghisler(Author) wrote:I have checked that now: Vista is missing the subkey "runasuser" below the key:
HKEY_CLASSES_ROOT\exefile\shell
I have tried to add it manually from what Windows 7 uses, but it doesn't work.
According to information from this TechNet forum topic it seems that this Windows feature has been removed in Vista and added again in Windows 7
The only solution would be to change the command to:
runas /user:username c:\windows\notepad.exe

You will then just be asked for the password.
It works, thanks. Since the asterisks are more universal (no need to write the username in the command field of the button), maybe you can consider for Vista to use for asterisks the same own username/password input dialogs as it currently uses for cm_OpenAsUser command instead of showing that Error 31?

And on other issue that I have with cm_OpenAsUser: when it used on .exe with "As Administrator" property enabled and after entering a username and password nothing is started. I checked how the runas command will start such app. I copied notepad.exe to notepadadmin.exe, enabled the start as adminitrator file property for notepadadmin.exe and got this:

Code: Select all

>runas /user:Myusername notepadadmin.exe
Введите пароль для Myusername:
Попытка запуска notepadadmin.exe от имени пользователя "MYPCNAME\Myusername" ...
ОШИБКА RUNAS: Не удается запустить - notepadadmin.exe
740: Запрошенная операция требует повышения.
which says that elevation is required for this operation. It does show this error even form elevated cmd.exe!
Donate for Ukraine to help stop Russian invasion!
Ukraine's National Bank special bank account:
UA843000010000000047330992708
User avatar
DrShark
Power Member
Power Member
Posts: 1872
Joined: 2006-11-03, 22:26 UTC
Location: Kyiv, 68/262
Contact:

Post by *DrShark »

DrShark wrote:... on other issue that I have with cm_OpenAsUser: when it used on .exe with "As Administrator" property enabled and after entering a username and password nothing is started. I checked how the runas command will start such app. I copied notepad.exe to notepadadmin.exe, enabled the start as adminitrator file property for notepadadmin.exe and got this:

Code: Select all

>runas /user:Myusername notepadadmin.exe
Введите пароль для Myusername:
Попытка запуска notepadadmin.exe от имени пользователя "MYPCNAME\Myusername" ...
ОШИБКА RUNAS: Не удается запустить - notepadadmin.exe
740: Запрошенная операция требует повышения.
which says that elevation is required for this operation. It does show this error even form elevated cmd.exe!
I have exactly the same behavior also on Windows 7 32-bit. There are many discussions on the Web about runas error 740, but I couldn't fine one regarding the case described above, so I don't even know whether it's a by design runas limitation, or it's possible to change runas behavior for above case with some registry or policy tweak.
Donate for Ukraine to help stop Russian invasion!
Ukraine's National Bank special bank account:
UA843000010000000047330992708
Post Reply