locked
Application to run in elevated mode RRS feed

  • Question

  • I've developed an application in VS2005 to be run in XP and Vista. The application should get the hard disks serial number to be used in the application, however, it cannot get it in Vista unless it's run as administrator. Getting the hard disk serial is a crucial part of the application; i don't want users to be able to run the application in non-elevated mode. Whenever a user runs the application, I want it to be run as if the user right-clicked on the icon and selected "Run as administrator". How can I achieve this?

    Thank you in advance.

    Wednesday, August 22, 2007 6:42 PM

Answers

  • You can embed a manifest in your application specifying "requireAdministrator" as the requestedExecutionLevel.  This will cause the application to prompt to run as administrator every time it is launched on Vista.

     

    If all you need is the hard disk serial number, if seems like there should be a way to do this without admin privileges.

    Wednesday, August 22, 2007 9:00 PM
  • Standard Users can obtain the serial number of any hard disk via Windows Management Instrumentation. You do not need to require Administrator rights just for that.

    Wednesday, August 22, 2007 9:13 PM

All replies

  • You can embed a manifest in your application specifying "requireAdministrator" as the requestedExecutionLevel.  This will cause the application to prompt to run as administrator every time it is launched on Vista.

     

    If all you need is the hard disk serial number, if seems like there should be a way to do this without admin privileges.

    Wednesday, August 22, 2007 9:00 PM
  • Standard Users can obtain the serial number of any hard disk via Windows Management Instrumentation. You do not need to require Administrator rights just for that.

    Wednesday, August 22, 2007 9:13 PM
  • David,

    Thank you for the reply. I haven't dealt with manifests before; I googled some keywords from your message and found this page http://tinyurl.com/yuxps2. I'm posting the link here cause I find it handy for people unfamiliar with manifests.

     

    Andy,

    I am using a ready-to-use dll to get the serial number; I'm not familiar with WMI. I can manage to find the WMI code to get the serial, but my application also needs to write information to the registery. When not elevated, it writes to a virtual place in the registery (unless I give read and write permission, for example, to the Users group on that registery key). So the application behaves differently when run in elevated and non-eleveated mode. Is there a way that the application runs in non-elevated and writes to the normal registery (not virtual).

     

    thanks

    Thursday, August 23, 2007 12:08 PM
  • Sir
    I am developing an application in VS2005 to be run on xp. I dont want my client to make a copy of it and run it on other system or sell it. So we desided to get the hard dist number of the system and to generate a key which will be acceptable to that particular machine.  i am failing to read the hard disk serial number as i am unable to get the proper code.
    can  you please tell me how to get the this hard disk serial number.

    i be glad
    thanku.
    Monday, September 3, 2007 9:59 AM
  • AAmin,

     

    The best place to write to the registry is one of the per-user locations (i.e. under HKCU) that way individual users won't effect each other. lf you are trying to write some form of licensing info that can be read by all users then is probably best to write it during install or by using COM elevation to temporarily elevate. If it has to be shared read/write between all users then the only way is to ACL it accordingly.

     

    HPtaunk,

     

    It's a case of doing a WQL query against Win32_PhysicalDisk. How exactly you go about doing that is dependent upon what language you are orig. For .Net languages it's part of System.Management, for C++ you would use the native COM objects.

    Monday, September 3, 2007 3:12 PM

  • Hello,
    I'm having this problem when I'm getting the hard disk serial number by WMI. It says that I need admin rights. Please let me know if you know a way to do it without admin privileges.

    Thanks

    R
    Monday, October 8, 2007 3:31 PM
  • It shouldn't need admin rights (WMIC can query it as a standard user). What code are you using to do it?

    Monday, October 8, 2007 7:30 PM

  • I'm using this code:

                ManagementObjectSearcher searcher;
                try
                {
                    searcher = new ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive");
                    foreach(ManagementObject wmi_HD in searcher.Get())
                    {

        return wmi_HD["signature"].ToString();
                    }
                    return null;
                }

    if the user is not administrator it doesn't obtain de hard disk serial number.
    Please let me know if you know a way to do it without admin rights.

    Thanks.

    R
    Tuesday, October 9, 2007 8:45 AM
  • Elevated  Mode is required under Microsoft Windows [Version 10.0.14393]

    This is a (used) computer that was given to me, as a Home Warming Gift. How do I enable Administrator permissions?

    Patrick

    pwwhittle@rogers.com

    (226) 246-5734 -for texting!

    Thursday, April 27, 2017 5:32 PM