Auto start in standard account without UAC

akr16

New Member
Hi all,

I never use the admin account and always use the standard account for my day to day activities. Adding HWiNFO to my startup will always ask for admin password since it requires elevated privileges. I wanted to bypass the UAC prompt and spent some time on this topic. Its very difficult but I came across a program called "runasspc" which will store your admin password encyrpted and then during startup, can run HWiNFO during standard login. More research indicated that the program uses the Win32 API, CreateProcessWithLogonW(). Note: There is a slight element of risk since admin password is in clear text when this API will be called. Anyway, "runasspc" satisfied my needs but sometimes it would randomly pop a dialog about its free license. So I decided to write a simple program myself that would start HWiNFO using same API.

I looked at the MSDN example for CreateProcessWithLogonW() and after lots of trials and errors and research, I was able to run HWiNFO as an admin from standard account without password. The trick was to use cmd.exe to start the program. Here is the program I used:

// runasadmin.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <Windows.h>
#include <stdio.h>
#include <UserEnv.h>

void DisplayError(LPWSTR pszAPI)
{
LPVOID lpMsgBuf;

FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL,
GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPWSTR)&lpMsgBuf, 0, NULL);
wprintf(L"API = %s, Error code=%d, msg=%s\n", pszAPI, GetLastError(), (LPWSTR)lpMsgBuf);
LocalFree(lpMsgBuf);
ExitProcess(GetLastError());
}

int _tmain(int argc, _TCHAR* argv[])
{
PROCESS_INFORMATION pi = { 0 };
STARTUPINFO si = { 0 };
WCHAR szUser[256] = L"admin"; //account that has elevated privileges
WCHAR szDomain[256] = L"domain";
WCHAR szPass[256] = L"password";
WCHAR szApp[256] = L"cmd.exe /C start \"\" D:\\HWiNFO64\\HWiNFO64.exe";
WCHAR szDir[256] = L"D:\\HWiNFO64\\";

si.cb = sizeof(STARTUPINFO);

if (!CreateProcessWithLogonW(szUser, szDomain, szPass, LOGON_WITH_PROFILE,
NULL, szApp, CREATE_UNICODE_ENVIRONMENT, NULL,
szDir, &si, &pi)) {
DisplayError(L"CreateProcess");
}

CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
return 0;
}


Compile and put this in your startup path and you will be able to run HWiNFO from standard account without password. Make changes as necessary.

Note: As seen above, the password is in clear text. So use it at your own risk.

Thanks,
- Arun
 

Martin

HWiNFO Author
Staff member
Thanks for your suggestion.
However I don't understand why you don't use the "Auto Start" feature built in HWiNFO. That creates a new task in the Windows Task Scheduler, which allows to run HWiNFO with Administrator rights and bypassing the UAC prompt. You can also customize this task properties in the Task Scheduler (start conditions, timing, user account, etc).
 

akr16

New Member
Hi Martin,

The Task scheduler trick works only for Administrator accounts. If you log in to admin account, yes, there are no issues. It doesn't work for standard user logins. At least, it never worked for me and after much trial and error, I have done what I mentioned above.

Thanks,
- Arun

PS: If anyone was able to use a standard user account for starting up HWiNFO without password, and can share the steps, that would be great!
 

Martin

HWiNFO Author
Staff member
Have you tried to change the user of the task? If you enable Auto Start in HWiNFO, press OK and then go into Task Scheduler and try to "Change User or Group..." under Security options.
 

akr16

New Member
Yes, I had tried all that. Changing the user will start the HWiNFO task when you login with the following error:

"Cannot install HWiNFO driver! Check user rights and anti-virus filters"

This is the same error you get when you double-click HWiNFO in standard user account without "run as admin"
 

Martin

HWiNFO Author
Staff member
Hm, you might try to run as Admin the first time and use the Persistent Driver option.
 

wawans1975

Well-Known Member
akr16 said:
Adding HWiNFO to my startup will always ask for admin password since it requires elevated privileges.
Using Standard Account too..
With latest HWiNFO v. 5.07- 2670, adding HWiNFO to my Standard Account startup folder isn't asking for admin password anymore.. at least for me :p



Martin said:
.. use the "Auto Start" feature built in HWiNFO. That creates a new task in the Windows Task Scheduler, which allows to run HWiNFO with Administrator rights and bypassing the UAC prompt. You can also customize this task properties in the Task Scheduler (start conditions, timing, user account, etc).
use Auto Start feature, but HWiNFO  task only running for Administrator Account. Login to Standard Account  doesn't trigger running HWiNFO (not even on the list of Standar Account Task Scheduler).
I have to manually create second HWiNFO task for my Standard Acccount.
 

Martin

HWiNFO Author
Staff member
wawans1975 said:
use Auto Start feature, but HWiNFO  task only running for Administrator Account. Login to Standard Account  doesn't trigger running HWiNFO (not even on the list of Standar Account Task Scheduler).
I have to manually create second HWiNFO task for my Standard Acccount.
You might need to adjust the task in Task Scheduler, by default it's configured to require Administrative rights (Run with highest privileges).
 

wawans1975

Well-Known Member
Martin said:
wawans1975 said:
use Auto Start feature, but HWiNFO  task only running for Administrator Account. Login to Standard Account  doesn't trigger running HWiNFO (not even on the list of Standar Account Task Scheduler).
I have to manually create second HWiNFO task for my Standard Acccount.
You might need to adjust the task in Task Scheduler, by default it's configured to require Administrative rights (Run with highest privileges).
Work ok now, I've adjust HWiNFO task  that have been created by HWiNFO to use Users Account and leave Run Highest Privileges checked. A combination of those work for my system :D under Administrator Account and Standard Account that I have.
 
Top