Click here to Skip to main content
15,893,487 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HI ALL,
How can I make exe(VS 6.0) file run as administrator in Windows 7?

I don't want the user to press right click on the file and run it as administartor, I want my exe file run as admin automaticly once he press double click on the file.


I tried to use manifest file, created .res and added to project.
Its not helped got warning project already have .res file.Newly added .res file was ignored.


Is there's some code I've to put in my submain or in the windows registry?
Or how to use manifest file in VS6.0??


<pre lang="vb"><pre lang="vb"></pre></pre>Thanks
Posted

First of all, let me express my regrets for you having to use VS 6.0.
Maybe, think about using modern Express Edition version — limited but free of charge, see:
http://en.wikipedia.org/wiki/Visual_Studio_Express[^].
http://www.microsoft.com/visualstudio/en-us/products/2010-editions/express[^].

As to run as administrator, just logging as administrator is not enough. You will find all the options here:
http://www.sevenforums.com/tutorials/11841-run-administrator.html[^].

—SA
 
Share this answer
 
Comments
deepa_ubdt 7-Feb-12 4:52am    
Thanks a lot for your reply.

I have legacy application in VB6.0.Do not want to upgrade to VS2008 or VS2010.

End user do not want to do set Run as admini in property,SHFT+CTRL+ENTER...so I have to give solution either through manifest file or providing admin privildege through the code.

Added .RES file to the project.But getting warning as
Minium.res : warning LNK4059: PRJ.res already specified; additional resource file ignored

And also Iam not sure how to embed the manifest file in Visual basic 6.0 for VC++ project.

Please help me in resolving this issue..
Sergey Alexandrovich Kryukov 7-Feb-12 12:13pm    
Sorry, I don't use any VB, cannot answer about embedding the manifest. The warning? Well, you already have resource under that name, so check your project: replace, edit existing resource or add another one. I have no idea what VB.6 can do, it has a number of most crazy limitations.

As to the elevated privileges, I think this article lists all options. Can be one more: your application may not be doing anything which requires elevated privileges; it can just access some illegal directories like C:/*/*... Work with directories which are legal with Windows 7 (under Users/*/...) or give access to those required directories.

--SA
Have a look at Michael Pietrofortes' article 7 ways how to elevate an application to run it with Administrator rights[^]

Best regards
Espen Harlinn
 
Share this answer
 
Comments
deepa_ubdt 7-Feb-12 4:52am    
Thanks a lot for your reply.

I have legacy application in VB6.0.Do not want to upgrade to VS2008 or VS2010.

End user do not want to do set Run as admini in property,SHFT+CTRL+ENTER...so I have to give solution either through manifest file or providing admin privildege through the code.

Added .RES file to the project.But getting warning as
Minium.res : warning LNK4059: PRJ.res already specified; additional resource file ignored

And also Iam not sure how to embed the manifest file in Visual basic 6.0 for VC++ project.

Please help me in resolving this issue..
Sergey Alexandrovich Kryukov 9-Feb-12 12:44pm    
Good link, my 5. The set of options looks comprehensive.
--SA
Espen Harlinn 9-Feb-12 15:31pm    
Thank you, Sergey!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900