0

I was using Matt's idea over here. The only changes I made was adding the two netstat commands at the bottom and removed cmd /k since that seemed to make the script freeze. This script is causing firefox to crash. Can I please get some ideas on how and why this is happening? How do I fix this?

How can I auto-elevate my batch file, so that it requests from UAC administrator rights if required?

:::::::::::::::::::::::::::::::::::::::::
:: Automatically check & get admin rights
:::::::::::::::::::::::::::::::::::::::::
@echo off
CLS
ECHO.
ECHO =============================
ECHO Running Admin shell
ECHO =============================

:checkPrivileges
NET FILE 1>NUL 2>NUL
if '%errorlevel%' == '0' ( goto gotPrivileges ) else ( goto getPrivileges )

:getPrivileges
if '%1'=='ELEV' (shift & goto gotPrivileges)
ECHO.
ECHO **************************************
ECHO Invoking UAC for Privilege Escalation
ECHO **************************************

setlocal DisableDelayedExpansion
set "batchPath=%~0"
setlocal EnableDelayedExpansion
ECHO Set UAC = CreateObject^("Shell.Application"^) > "%temp%\OEgetPrivileges.vbs"
ECHO UAC.ShellExecute "!batchPath!", "ELEV", "", "runas", 1 >> "%temp%\OEgetPrivileges.vbs"
"%temp%\OEgetPrivileges.vbs"
exit /B

:gotPrivileges
::::::::::::::::::::::::::::
::START
::::::::::::::::::::::::::::
setlocal & pushd .

REM Run shell as admin (example) - put here code as you like
net stop "Audiosrv"
net start "Audiosrv"
Community
  • 1
  • 1
cokedude
  • 379
  • 1
  • 11
  • 21
  • What does this script have to do with Firefox? – jpw Mar 28 '15 at 00:11
  • Is there anything else going on on your machine? I ran this script with Firefox open and Firefox stayed open the whole time. – SomethingDark Mar 28 '15 at 00:57
  • @jpw No idea. Thats why I'm so confused. I just know I use firefox ALL the time and whenever I run the script it crashes firefox. – cokedude Mar 28 '15 at 00:57
  • @SomethingDark I have several windows explorer windows open, matlab, notepad++, a cmd window, adobe reader, and regular microsoft notepad open. – cokedude Mar 28 '15 at 01:02

0 Answers0