添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

Conversation

Executing batch file as admin

(overview of excerpts from articles in conversation)

Newsgroup: jrsoftware.innosetup I need to execute a batch file inside PrepareToInstall(). This batch file must be "Run as Administrator". My code (that is no good): Exec(ExpandConstant('{win}\bcd_set.bat'),'', '', SW_HIDE, ewWaitUntilTerminated, ResultCode); Any suggestions? I set PrivilegesRequired=admin but Exec() still fails.     As for "runas" - AFAIR it requires username & password.     Deanna Earley wrote: (snip)

Those are the pre vista complications I mentioned,       The "runas" verb (not the RunAs.exe program) asks for elevation on       vista/7/8 if running as an unelevated admin, or prompts for the admin       details if runnign as a non admin. The best thing to do is to convert your batch file into [Code]. You can   handle errors and things better that way anyway.   However, Exec should work. The most likely problem is that the batch   file hasn't actually been installed yet. (PrepareToInstall runs before I went into some more debugging and found out that the problem is even     more strange (BTW: The machine is a W7 x64):     In order to experiment with the environment I ran the batch file under     'cmd /k'     and this is what I get: I'll try to be clearer:         I'd love to replace the batch file that is called by Exec inside the         [Code] section with a proper code. However, re-writing BCDEDIT.exe is a         complicated task involving WMI.         You gave me a clue. Apparently, Exec() opens a 32 environment on x64 You should only use that if your actual application is also 64-bit. It             has quite wide consequences.             Have a look at EnableFsRedirection instead. (snip)

You can call BCDEDIT directly from Inno, if need be; you don't need a ArchitecturesInstallIn64BitMode=x64 is a must since my installer installs               a x64 device driver (Kernel mode).               Calling BcdEdit directly - You are absolutely right. I now do it.               Thank you Gavin               Gavin Lambert wrote: Actually, even if you are installing a 64-bit driver, if the app itself                 is 32-bit you should *NOT* be using that setting. Use the appropriate                 flags or APIs to tell Inno you're installing a 64-bit file instead.