Overclock.net banner

1 - 3 of 3 Posts

·
Registered
Joined
·
2,093 Posts
Discussion Starter #1
Im running a batch program to open up speedfan from my desktop, of which it starts to, but then a window pops up for the user account control to ask me do i want this app to make changes to my PC, with a yes or no, how can i write this in my batch file, this is what i have so far

@echo off
start "title" "C:\Program Files (x86)\SpeedFan\speedfan.exe"

thanks for all help in advance.
 

·
Overclock Failed...
Joined
·
13,565 Posts
This should do it.

REM --> Run Batch file as Admin
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
echo Requesting administrative privileges...
goto UACPrompt
) else ( goto gotAdmin )

:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
set params = %*:"=""
echo UAC.ShellExecute "cmd.exe", "/c %~s0 %params%", "", "runas", 1 >> "%temp%\getadmin.vbs"

"%temp%\getadmin.vbs"
del "%temp%\getadmin.vbs"
exit /B

:gotAdmin
pushd "%CD%"
CD /D "%~dp0"
REM Run Batch File here
 

·
Registered
Joined
·
2,093 Posts
Discussion Starter #3
Quote:
Originally Posted by billbartuska View Post

This should do it.

REM --> Run Batch file as Admin
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
echo Requesting administrative privileges...
goto UACPrompt
) else ( goto gotAdmin )

:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
set params = %*:"=""
echo UAC.ShellExecute "cmd.exe", "/c %~s0 %params%", "", "runas", 1 >> "%temp%\getadmin.vbs"

"%temp%\getadmin.vbs"
del "%temp%\getadmin.vbs"
exit /B

:gotAdmin
pushd "%CD%"
CD /D "%~dp0"
REM Run Batch File here
Thanks for the help but it does not work.
frown.gif
 
1 - 3 of 3 Posts
Top