locked
Win 7 won't allow to write the raw bytes into USB flash drive boot sector RRS feed

  • Question

  • I have a small program (Visual Basic) to create customerized USB flash drives.  It uses CreateFile() function to retrieve the device handler of the physical drive and uses WriteFile() function to dump raw bytes into the USB drive (boot sector).  The same code works very well in Windows XP but has problems in Windows 7.  The problems are either 1) CreateFile() funtion returns an error of "Invalid handler", Or 2) WriteFile() function returns an error of "Access denied".  Turning UAC off could make those two functions mentioned above to work in some intermittent ways.  Does anyone have similar experiences or share knowledge/solutions on this kind issues?  Thanks. 
    Tuesday, January 18, 2011 6:04 PM

Answers

  • Add an Manifest file to your applications which requiresAdmin rights:

    <requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>

    http://msdn.microsoft.com/en-us/library/bb756929.aspx

     


    "A programmer is just a tool which converts caffeine into code" CLIP- Stellvertreter http://www.winvistaside.de/
    • Proposed as answer by Andre.Ziegler Tuesday, January 18, 2011 9:04 PM
    • Marked as answer by Cloud_TS Friday, January 21, 2011 3:15 AM
    Tuesday, January 18, 2011 9:04 PM

All replies

  • Add an Manifest file to your applications which requiresAdmin rights:

    <requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>

    http://msdn.microsoft.com/en-us/library/bb756929.aspx

     


    "A programmer is just a tool which converts caffeine into code" CLIP- Stellvertreter http://www.winvistaside.de/
    • Proposed as answer by Andre.Ziegler Tuesday, January 18, 2011 9:04 PM
    • Marked as answer by Cloud_TS Friday, January 21, 2011 3:15 AM
    Tuesday, January 18, 2011 9:04 PM
  • The code runs with internal elevation points as local administrator when calling those functions.  This admin elevation is also needed in Windows XP.  Somehow, this feature does not seem working well in Windows 7.  I also run this program as an administrator user - still having those problems.  
    Tuesday, January 18, 2011 10:03 PM
  • Ask in the MSDN Forums:

    http://social.msdn.microsoft.com/Forums/en-us/categories

    and post some Code pieces.


    "A programmer is just a tool which converts caffeine into code" CLIP- Stellvertreter http://www.winvistaside.de/
    Tuesday, January 18, 2011 10:11 PM