# Run command as administrator (to disable WIndows Defender for good)

**URL:** <https://travis-ci.community/t/run-command-as-administrator-to-disable-windows-defender-for-good/4145>\
**Category:** Windows\
**Created:** [July 10, 2019, 9:08am UTC](https://travis-ci.community/t/run-command-as-administrator-to-disable-windows-defender-for-good/4145 "2019-07-10T09:08:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![DanySK](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/danysk/32/1399_2.png) [@DanySK](https://travis-ci.community/u/DanySK)\
**Post date:** [July 10, 2019, 9:08am UTC](https://travis-ci.community/t/run-command-as-administrator-to-disable-windows-defender-for-good/4145/1 "2019-07-10T09:08:21Z")

</div>

Hi, is there any way on travis Windows images to run a command as administrator?  
In particular, I’d like to run:

`powershell Set-MpPreference -DisableRealTimeMonitoring $true`

with elevated privileges

---

<div class="post-metadata">

**Author:** ![DanySK](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/danysk/32/1399_2.png) [@DanySK](https://travis-ci.community/u/DanySK)\
**Post date:** [July 10, 2019, 10:53am UTC](https://travis-ci.community/t/run-command-as-administrator-to-disable-windows-defender-for-good/4145/2 "2019-07-10T10:53:19Z")

</div>

[This](https://github.com/DanySK/Gravis-CI/blob/master/.disable-windows-defender.sh) does not seem to work. Usable by:

```auto
env:
  global:
    - GRAVIS="https://raw.githubusercontent.com/DanySK/Gravis-CI/master/"

before_install:
  - curl "${GRAVIS}.disable-windows-defender.sh" --output .disable-windows-defender.sh
  - source .disable-windows-defender.sh

```

Works on a normal Windows installation (prompts about privilege escalation).

---

<div class="post-metadata">

**Author:** ![native-api](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/native-api/32/430_2.png) [@native-api](https://travis-ci.community/u/native-api)\
**Post date:** [July 10, 2019, 3:00pm UTC](https://travis-ci.community/t/run-command-as-administrator-to-disable-windows-defender-for-good/4145/3 "2019-07-10T15:00:05Z")

</div>

Related:

> [@Yarn network troubles](https://travis-ci.community/t/yarn-network-troubles/333/7):
>
> Disabling Windows Defender Realtime Monitoring boosts my yarn install from 900s to 180s. And I don’t get any network related issues. export NODEPATH=$(where.exe node.exe) export PROJECTDIR=$(pwd) export YARNCACHE=$(yarn cache dir) export TEMPDIR=$LOCALAPPDATA\\Temp powershell Add-MpPreference -ExclusionProcess ${NODEPATH} powershell Add-MpPreference -ExclusionPath ${YARNCACHE} powershell Add-MpPreference -ExclusionPath ${PROJECTDIR} powershell Add-MpPreference -ExclusionPath ${TEMPDIR} echo "…

[It looks like you always run elevated](https://travis-ci.community/t/able-to-access-system32/3777)

---

<div class="post-metadata">

**Author:** ![DanySK](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/danysk/32/1399_2.png) [@DanySK](https://travis-ci.community/u/DanySK)\
**Post date:** [July 11, 2019, 11:28am UTC](https://travis-ci.community/t/run-command-as-administrator-to-disable-windows-defender-for-good/4145/4 "2019-07-11T11:28:54Z")

</div>

Thanks! I worked a lot for nothing, you actually always run elevated.
