2

I have a .bat script which instals 3 pieces of software. When i open an elevated Command promt , browse to the file and run it everything works fine. When i run the .cmd directly ( using the 'run as administrator' from Windows 7 nothing happens. any ideas why this is?

script is below :

rem ECHO OFF

ECHO Installing Bonjour , please wait!

msiexec.exe /i reqs\Bonjour64.msi /quiet

ECHO Installing DirectX 9.0C Redist , please wait

reqs\dxsetup.exe /silent

ECHO Installing Airserver , please wait.

msiexec.exe /i reqs\AirServer-1.9.1.msi /qn TRANSFORMS=PIDKEY.mst

Any help would be greatly appreciated.

1
  • Just tried the script with UAC turned completely off and it worked, so why is UAC blocking the install even when i am running the script as an admin?
    – NickDa
    Oct 4, 2013 at 9:14

1 Answer 1

5

My guess would be that the script is started in a different working directory when started through "run as administrator". Therefore your relative paths would be wrong. If you start a cmd normally you should be in your user profile. If you start cmd as Administrator through "Run As" you usually end up in "C:\Windows\System32".

Try this:

rem ECHO OFF

ECHO Installing Bonjour , please wait!

msiexec.exe /i "%~dp0reqs\Bonjour64.msi" /quiet

ECHO Installing DirectX 9.0C Redist , please wait

"%~dp0reqs\dxsetup.exe" /silent

ECHO Installing Airserver , please wait.

msiexec.exe /i "%~dp0reqs\AirServer-1.9.1.msi" /qn TRANSFORMS="%~dp0PIDKEY.mst"

The %~dp0 gets resolved to the directory the script resides in (plus trailing backslash).

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .