BradleyCleveland
asked on
How to run regsvr32 as Administrator on Windows 7
I have the following line of code in a small vb6 app that works great on XP. On Windows 7, the regsvr32 will not work unless permissions are elevated to an Administrator. Is there any way in code to elevate to administrator and then run my code? Please give specific example. And I don't want my end users to have to launch the exe any special way other than double-clicking it. I am not opposed to hardcoding an administrator user name and password in the vb6 code.
Here's what works in XP
VBRegSvr32 ("c:\Netmanagerdd\MyFile.d ll")
Here's what works in XP
VBRegSvr32 ("c:\Netmanagerdd\MyFile.d
Hi again,
Or, you can wrap everything within a autoit script.
Here's an example of an Autoit 3 script.
/Dymer2
Or, you can wrap everything within a autoit script.
Here's an example of an Autoit 3 script.
/Dymer2
#include <process.au3>
#include <GUIConstants.au3> ; GUI
; Are we already admin?
If Not IsAdmin() Then
RunAs('administrator', 'HQdomain', 'secretpassword',0,@AutoItExe,@WorkingDir)
Exit
Else
$Width = 300
$Height = 140
GUICreate("Construction Service", $Width, $Height)
$editbox = GUICtrlCreateEdit("Registreraren laddad."& @CRLF,10,10,280,120)
GUISetState ()
GUICtrlSetData ($editbox, "Copy file to computer...",1)
FileCopy (@ScriptDir & "\FuncList.dll" , @SystemDir)
FileCopy (@ScriptDir & "\Construction.ini" , @AppDataDir)
If FileExists (@SystemDir & "\FuncList.dll") Then
GUICtrlSetData ($editbox, "...done, registering dll-file." & @CRLF,1)
RunWait('regsvr32 /s ' & '"' & @SystemDir & '\FuncList.dll"')
GUICtrlSetData ($editbox, "Registering done." & @CRLF,1)
$endmsg = "All done. You can now run the application."
Else
GUICtrlSetData ($editbox, "Error while installing." & @CRLF,1)
$endmsg = "Error while installing."
Sleep(300)
endif
EndIf
msgbox(0,"Information",$endmsg)
Most folks attempt to move those kinds of activities to the Install routine (that obvioulsy happens only once), rather than the application itself. It's kinda normal to have an administrator perform the install of a new piece of software, so that part is pretty much taken care of. Now, all you'd need to do is perform a custom step in your installer that registers the DLL.
ASKER
Some other issues have taken priorty and I haven't had a chance to test this solution. Was actually hoping for something simpler, but will try to test it this weekend. I had to submit this response so that the EE account would unlock
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
- maybe you can also look into Manifest to make your exe file run as Administrator:
http://msdn.microsoft.com/en-us/library/bb756929.aspx
http://www.bigresource.com/Tracker/Track-vb-bQQLOflX7x/ (scroll down to Jemand solutions)
http://msdn.microsoft.com/en-us/library/bb756929.aspx
http://www.bigresource.com/Tracker/Track-vb-bQQLOflX7x/ (scroll down to Jemand solutions)
ASKER
I must have hit something wrong by mistake. My intent was to accept Op Zaharin's response of creating a shortcut (or right-mouse clicking on the exe) to select the option of "Run as Administrator"
hi bradley, thank you and glad it works for you :)
I've not tried this for regsvr32 but I hope it helps.
I use the code for checking remote registry settings.
Good Luck!
/Dymer2
Open in new window