Jump to content
Sign in to follow this  
Adrianvdh

Registry Permissions

Recommended Posts

Hello everyone I am running this batch file and it was working great (I am admin on my pc) and then it throws me an error saying access denied when I trying to write to a text file on my Desktop?

 

 

echo My program started!>>%userprofile%\Desktop\textfile.txt

 

Here are my permissions:

post-46927-0-71135300-1364240982_thumb.png

 

P.S is ther like a .reg file out there that can help me with my problem? :)

Share this post


Link to post
Share on other sites

You may be the admin but you need to run the .bat as admin.

 

Put this in the batch at the top to get admin privs

 

:: Get ADMIN Privs
:-------------------------------------
mkdir "%windir%\BatchGotAdmin"
if '%errorlevel%' == '0' (
  rmdir "%windir%\BatchGotAdmin" & goto gotAdmin
) else ( goto UACPrompt )


:UACPrompt
    echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
    echo UAC.ShellExecute %0, "", "", "runas", 1 >> "%temp%\getadmin.vbs"


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


:gotAdmin
    if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
    pushd "%CD%"     
    CD /D "%~dp0"
:-------------------------------------
:: End Get ADMIN Privs

Share this post


Link to post
Share on other sites

Ya that doesnt work or mine...

 

 

@echo off

set tempdir=%windir%\fixUAC
if not exist %tempdir% md %tempdir%

REG QUERY "HKU\S-1-5-19" >NUL 2>&1 && (
goto ADMIN
) || (
echo.RUN ME AS ADMINISTRATOR
ping localhost -n 3 >nul
exit )

:ADMIN
echo [My program started]>>%userprofile%\program.log|findstr /i "Access Denied.">nul>nul
IF %ERRORLEVEL% EQU 0 goto mainmenu
) else (
cls
color c
echo ACCESS DENIED - Writting to log file...
ping localhost -n 2 >nul
echo Fixing you UAC settings
ping localhost -n 3 >nul
color b
goto fixUAC
cls )


:fixUAC
cd %tempdir%
echo Set UAC = CreateObject^("Shell.Application"^) >>%tempdir%\fixUAC.vbs|findstr /i "Access Denied.">nul>nul
IF %ERRORLEVEL% EQU 0 (
goto next
) else (
goto error1 )

:next
echo UAC.ShellExecute %0, "", "", "runas", 1 >>%tempdir%\fixUAC.vbs|findstr /i "Access Denied.">nul>nul
IF %ERRORLEVEL% EQU 0 (

    "%tempdir%\fixUAC.vbs"
goto mainmenu
) else (
goto error2 )


:error1
cls
color c
echo ACCESS DENIED - Writting to vbs file...
echo with part...1
ping localhost -n 2 >nul
echo Can not fix UAC settings
ping localhost -n 4 >nul
exit
:error2
cls
color c
echo ACCESS DENIED - Writting to vbs file...
echo. with part...2
ping localhost -n 2 >nul
echo Can not fix UAC settings
ping localhost -n 4 >nul
exit


:mainmenu
cls
echo Welldone this program has success!
ping localhost -n 3 >nul
echo Now this part is for the rest of you script...
echo.
pause
exit

I can md a folder but can write to it at all. My script throws the "ACCESS DENIED - Writting to vbs file..." error

 

Or this .vbs script..

 

 

Set UAC = CreateObject^("Shell.Application"^)
UAC.ShellExecute %0, "", "", "runas", 1
Edited by Adrianvdh

Share this post


Link to post
Share on other sites

Sorry, I can't help more. I know nothing about script.

 

I just found that on the net and use it for simple tasks to elevate a cmd.

 

It does what I need. Don't know more.

Share this post


Link to post
Share on other sites

Me Adrianvdh the

 

 

REG QUERY "HKU\S-1-5-19" >NUL 2>&1 && (
goto ADMIN
) || (
echo.RUN ME AS ADMINISTRATOR
ping localhost -n 3 >nul
exit )

Share this post


Link to post
Share on other sites
Sign in to follow this  

×

Important Information

By using this site, you agree to our Terms of Use.