1
votes

I have an Inno Setup installation which successfully run a batch file when finished. The batch asks for admin rights, gets them and does things.

I've been asked to completely hide the prompt window, so I've added "Flags: runhidden" in Inno Setup and @echo off and >nul 2>nul in the batch. But the batch still flash a prompt window, because of this:

if not "%1"=="am_admin" (powershell start -verb runas '%0' am_admin & goto 
batch & exit /b)

EXIT /b

:batch
---MyCodeHere---

I have not written this code by myself and I'm not expert about batch programming, but I'm pretty sure that these lines open a new prompt with admin permissions, and that's the prompt flashing.

Does anyone know if there's a solution to this? Maybe some flag to add to "powershell start", or another completely different way to do this task.

Thank you all in advance

1
maybe rather just use vbs to hide it from view, including any flashes. Set MyScript = CreateObject("WScript.Shell") MyScript.Run "D:\SomeDir\scriptname.cmd", 0, False then launch the vbs script instead.Gerhard

1 Answers

0
votes

Don't make the batch file ask for Administrator permissions.

Run the batch file with Administrator permissions straight away:
Run process (net.exe or sc.exe) with Administrator privileges at the end of an installation in Inno Setup

[Run]
Filename: "{app}\my.bat"; Description: "Run my batch file"; \
    Flags: postinstall runascurrentuser runhidden