Batch file script lost in translation to exe? - batch-file

I have this command in my batch script
REG ADD "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /V "My App" /t REG_SZ /F /D "C:\MyAppPath\MyApp.bat"
and it works as a bat file in windows7 however when convert it to exe file using the command below,
REG ADD "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /V "My App" /t REG_SZ /F /D "C:\MyAppPath\MyApp.exe"
Using bat to exe converter,iexpress or advanced converter the program does not start at start up? Somehow the function of the bat command is not translated into the exe file?

Thanks guys got it to work by disabling UAC

Related

How to add string value to Windows registry?

I want to add this new registry entry via cmd/batch file to run CMD always as administrator. I know I can add it by navigating to the mentioned path in the command. But I want to add it in one of my batch files. And I think to add string value I need to modify my cmd. I am missing something here :-
reg.exe ADD \HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers /t REG_SZ "C:\\WINDOWS\\system32\\cmd.exe"="RUNASADMIN" /f
Can anyone help me with this please?
The command line to use in a batch file executed by 64-bit cmd.exe on Windows x64 or 32-bit cmd.exe executed on Windows x86 running under elevated environment of a local administrator is:
%SystemRoot%\System32\reg.exe ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /f /t REG_SZ /v "C:\WINDOWS\system32\cmd.exe" /d "RUNASADMIN"
Open a command prompt window and run reg /? and next reg add /? for help on used command REG for adding a string value to Windows registry.

Delete files in context menu with bat file windows 8

my bat file:
#echo off
set targetfolder=%1
cd /d %1
del .
pause
my delete.reg file
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\Background\shell\Run Batch script]
#="Delete all"
[HKEY_CLASSES_ROOT\Directory\Background\shell\Run Batch script\command]
#=C:\delete.bat \"%V\"
The option is in the context menu but if I click Im getting this error:
This file does not have a program associated with it for performing this action. Please install a program or, if one is already installed, create an association in the Default Programs control panel.
[OK]
You don't really need a batch file, you should be able to run a command directly from the registry key.
Example:
#ECHO OFF
SETLOCAL
SET "SKEY=HKCU\Software\Classes\"
SET "EKEY=\shell\DeleteAll"
REG ADD %SKEY%Folder%EKEY% /VE /D "Delete &All Files" /F>NUL
REG ADD %SKEY%Folder%EKEY%\command /VE /T REG_EXPAND_SZ /D^
"%%COMSPEC%% /C PUSHD %%L && DEL *.*" /F>NUL
Right-click on a folder and select 'Delete All Files' to delete all normal files within that folder. (Be careful this will be catastrophic if you select the wrong folder)

Add registry from bat file

I am trying to add registry entry from bat file. I have a reg file that contains
[HKEY_CURRENT_USER\Software\Policies\Microsoft\Internet Explorer\Control Panel]
"HomePage"=dword:00000001
It works if you double click the reg file. However, I need to make the same registry edit from bat file. I have tried this
reg add HKCU\Software\Policies\Microsoft\Internet Explorer\Control Panel /v HomePage /t REG_DWORD /d 0 /f
But doesnt work. What is the correct way to do that ? (except running .reg file from bat file)
Put quotes around the key name.
reg add "HKCU\Software\Policies\Microsoft\Internet Explorer\Control Panel" /v HomePage /t REG_DWORD /d 0 /f
Because "Internet Explorer" and "Control Panel" contain spaces, you need quotes so it is all treated as one parameter.

How to run any program with batch file from any specific location

I wrote a batch file for open a specific program but it is not working.I wrote this :
#echo off
C:\Windows\System32\cmd.exe /K "cd /d C:\Program Files (x86)\HTC\HTC Sync Manager\"
start HTCSyncManager.exe
When I run the batch file only this window come, program do not start. How to fix this
#echo off
For /r c: %%f in (path goes here /HTCsyncmanager.exe) do (
start "%%f"
"%%f"
)
Remove the invoking of cmd.exe. All that's doing is starting a new instance of the command processor, which is not what you need at all. (You probably don't need the start, either.)
#echo off
cd /d "C:\Program Files (x86)\HTC\HTC Sync Manager\"
HTCSyncManager.exe
#echo off
start "HTCSyncManager" "C:\Program Files\(x86)\HTC\HTC Sync Manager\HTCSyncManager.exe"
This will open HTCSyncManager.

Windows task scheduler can run batch file but not fire command inside for winzip

I have task schedule for backup directory list of wwwroot. For that I have written batch file.
for /F "tokens=1-3 delims=: " %%i in ('time /t') do set Hma=%%i%%j%%k
set yyyymmdd=%date:~10,4%%date:~4,2%%date:~7,2%_%Hma%
set FolderPath=D:\SystemBackup\DirListFiles\
dir c:\inetpub\wwwroot /s /o-d > %FolderPath%\DirList_%yyyymmdd%.txt
batch file will do correct at this point but after this
echo "Upload To FTP Start"
cd /d c:\Program Files (x86)\WinZip\
winzip32.exe /autorunjobfile d:\BackupScript\DirList.wjf
echo "Upload FTP Complete !"
cd /d %FolderPath%
del DirList_%yyyymmdd%.txt
Not working well. It does not winzip well and also not send to ftp server.
From forum of Winzip, I found that if you want to run winzip job in batch mode than first time should run manually and winzip open one dialog box. Tick to do not ask again checkbox. so that task scheduler do not wait for prompt.
for the first part, winzip not working, you need to review your winzip job file and post here the failing part.
EDIT Ooops I was wrong.... you don't need to enclose the path in quotes. Sorry.
CD needs you to enclose the path in quotes, instead of
cd /d c:\Program Files (x86)\WinZip\
try
pushd "c:\Program Files (x86)\WinZip\"
for the second part, ftp not working, again you need to review your winzip job file and post here the failing part.

Resources