I am trying to compile and build my test program. however, I am getting the following error.
Making help file...
'".\makehelp.bat"' is not recognized as an internal or external command,
operable program or batch file.
Error executing c:\windows\system32\cmd.exe.
hpled6_2565.exe - 1 error(s), 0 warning(s)
Do you know how I can solve it? I am using Visual C++ 6.0 Standard Edition.
'".\makehelp.bat"' is not recognized as an internal or external command,
operable program or batch file.
Error executing c:\windows\system32\cmd.exe.
The above seems to indicate that your test program is missing the makehelp.bat file.
That in itself is easy to fix, just replace XYZ with your project name in the template auto-generated by VC6 (copied below) and save it as makehelp.bat in the project directory.
#echo off
REM -- First make map file from Microsoft Visual C++ generated resource.h
echo // MAKEHELP.BAT generated Help Map file. Used by XYZ.HPJ. >"hlp\XYZ.hm"
echo. >>"hlp\XYZ.hm"
echo // Commands (ID_* and IDM_*) >>"hlp\XYZ.hm"
makehm ID_,HID_,0x10000 IDM_,HIDM_,0x10000 resource.h >>"hlp\XYZ.hm"
echo. >>"hlp\XYZ.hm"
echo // Prompts (IDP_*) >>"hlp\XYZ.hm"
makehm IDP_,HIDP_,0x30000 resource.h >>"hlp\XYZ.hm"
echo. >>"hlp\XYZ.hm"
echo // Resources (IDR_*) >>"hlp\XYZ.hm"
makehm IDR_,HIDR_,0x20000 resource.h >>"hlp\XYZ.hm"
echo. >>"hlp\XYZ.hm"
echo // Dialogs (IDD_*) >>"hlp\XYZ.hm"
makehm IDD_,HIDD_,0x20000 resource.h >>"hlp\XYZ.hm"
echo. >>"hlp\XYZ.hm"
echo // Frame Controls (IDW_*) >>"hlp\XYZ.hm"
makehm IDW_,HIDW_,0x50000 resource.h >>"hlp\XYZ.hm"
REM -- Make help for Project XYZ
echo Building Win32 Help files
start /wait hcw /C /E /M "hlp\XYZ.hpj"
if errorlevel 1 goto :Error
if not exist "hlp\XYZ.hlp" goto :Error
if not exist "hlp\XYZ.cnt" goto :Error
echo.
if exist Debug\nul copy "hlp\XYZ.hlp" Debug
if exist Debug\nul copy "hlp\XYZ.cnt" Debug
if exist Release\nul copy "hlp\XYZ.hlp" Release
if exist Release\nul copy "hlp\XYZ.cnt" Release
echo.
goto :done
:Error
echo hlp\XYZ.hpj(1) : error: Problem encountered creating help file
:done
echo.
However, for this to work, you also need a resource.h following the VC6 resource IDs conventions, plus the respective .hpj and .cnt files.
Also, you should be aware that even if you get it to work, the end result will be a HLP file that's been deprecated since Vista, and requires a separate WinHlp32 install to be viewable at all (https://support.microsoft.com/en-us/kb/917607).
Related
In Inno Setup, my sign tool is defined as:
cmd /k "C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64\signtool.exe" sign /t http://timestamp.comodoca.com /n "My Company" $f
Prepending cmd /k (as suggested at Inno Setup - Signing fails with "Sign Tool failed with exit code 0x1") reveals that there is not actually a problem with the sign tool itself, but rather how Inno Setup is calling it, generating the following message:
'C:\Program' is not recognized as an internal or external command, operable program or batch file.
Clearly, it's chopping off the path to signtool at the first space, even though I put it in quotes. I even tried replacing the quotes with $q to see if that made any difference. (It didn't.) I would think this is improper behavior for the parser to dishonor the quotes, since the instructions clearly say to paste the exact text you'd use on the command line, and the example itself includes quotation marks (https://revolution.screenstepslive.com/s/revolution/m/10695/l/563371-signing-installers-you-create-with-inno-setup).
Everything works beautifully from the command line. For some reason, Inno Setup just isn't properly calling signtool.
ADDED 2020-07-14:
Inno Setup's example, copied from their website:
"C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Bin\signtool.exe" sign /f "C:\MY_CODE_SIGNING.PFX" /t http://timestamp.comodoca.com/authenticode /p MY_PASSWORD $f
My version, used without the cmd /k:
"C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64\signtool.exe" sign /t http://timestamp.comodoca.com /n "My Company" $f
As you can see, we use quotes in the same manner. I will check for updates - I probably should have done that first. When I get some time, I'll revert the signtool definition and see if maybe the update fixes it.
Also, I should have been more clear. I am new to Inno Setup and it didn't occur to me to clarify this. I am compiling via Inno Script Studio. It occurs to me that there's some possibility this has to do with a behavior in a specific version of Script Studio and not the compiler itself, but I don't know enough about the inner workings to do any more than speculate.
Having done a bit more tinkering, I'm now fairly certain this must be a bug with Inno Setup. I implemented a work-around as follows:
Open a command window with elevated privileges
Change to a directory I created with no space in the name: cd \bin
Create a 'spaceless' symbolic link to the directory where signtool.exe is located: mklink /d "Windows10SDK" "C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64"
Enter new sign tool definition that uses the symbolic link:
C:\bin\Windows10SDK\signtool.exe sign /t http://timestamp.comodoca.com /n "My Company" $f
And that's it! Because there is no longer a space character in the path to signtool.exe, Inno Setup now performs the signing correctly and everything works beautifully.
I'll report this as a bug and update if needed.
I use:
#define SignedDesc "$q" + MSA + "$q"
#define SignedPfx "$qd:\My Certificate\2018\My Certificate.pfx$q"
#define SignedTimeStamp "$qhttp://timestamp.verisign.com/scripts/timestamp.dll$q"
#define SignedPw "$q~~~~~~~$q"
SignTool=SignTool /d {#SignedDesc} /du $q{#AppURL}$q /f {#SignedPfx} /p {#SignedPw} /t {#SignedTimeStamp} /v $f
My sign tool is configured as:
$qC:\Program Files (x86)\Windows Kits\10\bin\10.0.16299.0\x86\Signtool.exe$q sign $p
You have to use $q which is a quote mark.
Question Summary:
Can I start Excel file Installer.xlsm from Windows batch script in safemode, without providing EXCEL.EXE installation path?
Details
I have a windows batch script which downloads the latest versions of a family of Excel Add-ins from a remote server, places them in a directory (C:\appname\AddIns) and calls the Excel file Installer.xlsm.
Upon loading, Installer.xlsm executes a VBA macro, which uninstalls older versions of the add-ins and installs their newer version.
Currently I start Installer.xlsm using the command:
start "Launching installer file" /wait "<Path to file>\Installer.xlsm"
What's great about it is that it uses Windows' file association to open Excel, and I don't have to provide the EXCEL.EXE installation path (multiple users with different machine images and MS Office versions).
Now I'd like to load Installer.xlsm in safemode, to make sure that no add-ins are loaded and no other code is run while Installer.xlsm tries to work with the add-ins.
I know I can use "<PathToExcel>excel" /safemode "<PathToXls>Installer.xlsm" as described in this answer, but this method doesn't use Windows' file association and requires that I provide a path.
We have users with various machine images, using different versions of MS Office, so I do not want to get into hardcoding all possible Excel installation locations.
Can I do something of the following form:
start "Launching installer file" /wait "<Path to file>\Installer.xlsm /safemode"
I tried different possible combinations without success. How would you do it?
First I suggest to read the Microsoft documentation page Application Registration. It explains how the installer of an application or an application suite like Microsoft Office should register the installed application(s) so that the executable(s) of the application(s) can be found by other applications.
Recommended is creating under registry key
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths
a subkey with name of the executable file like excel.exe with default string value being name of the executable with full path and optionally adding one more string value with name Path containing just the path to the executable. The Path string can but most not exist and it can but must not end with a backslash.
The command START uses also this key to find an application as explained in answer on Where is “START” searching for executables?
The installers of the various versions of Microsoft Office register excel.exe key under this key too.
So the easiest method on Windows Vista and later Windows versions to get installation location of Microsoft Excel is:
#echo off
for /F "skip=1 tokens=2*" %%A in ('%SystemRoot%\System32\reg.exe QUERY "HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths\excel.exe" /ve 2^>nul') do set "ExcelApp=%%~B"
echo ExcelApp=%ExcelApp%
pause
But on Windows XP the output of reg.exe is different and requires for that reason this batch code:
#echo off
for /F "skip=3 tokens=3*" %%A in ('%SystemRoot%\System32\reg.exe QUERY "HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths\excel.exe" /ve 2^>nul') do set "ExcelApp=%%~B"
echo ExcelApp=%ExcelApp%
pause
The different outputs are explained in answer on Read words separated by space & string value also contains space in a batch script in batch code written to get string value of a default string of a registry key containing spaces.
And it is good coding practice to add extra code which handles an error case like registry key does not exist at all because Microsoft Excel is not installed at all.
But is it possible with batch code to do what command START respectively the Windows shell function ShellExecuteEx does on using in a command prompt window the command line?
start "Launching installer file" "C:\Path to file\Installer.xlsm"
Yes, it is possible as the commented batch code below demonstrates.
#echo off
setlocal EnableExtensions DisableDelayedExpansion
rem First query default string value of HKEY_CLASSES_ROOT\.xlsm from registry.
call :GetDefaultRegValue "HKCR\.xlsm"
rem Is there no key HKEY_CLASSES_ROOT\.xlsm or was the default string empty?
if not defined RegValue goto GetFromAppPaths
SET RegValue
rem Get the shell command line used for opening a *.xlsm file.
call :GetDefaultRegValue "HKCR\%RegValue%\shell\open\command"
rem Could the command line not read successfully from Windows registry?
if not defined RegValue goto GetFromAppPaths
SET RegValue
rem The command line contains as first string usually enclosed in double
rem quotes EXCEL.EXE with full path enclosed in double quotes. And there
rem can be even more arguments on the command line which are not needed
rem here. The command line below is used to get just first string of
rem the command line which should be EXCEL.EXE with full path.
for %%I in (%RegValue%) do set "RegValue=%%~I" & goto CheckExcelExistence
rem It is not good when both registry queries above fail. This means
rem either Microsoft Excel is not installed at all or a version of
rem Excel is installed which does not support *.xlsm files like Excel
rem of MS Office 2003, MS Office 2000 or MS Office 97.
rem However, perhaps just *.xlsm is not correct registered and therefore
rem get full path to excel.exe from application registration key.
:GetFromAppPaths
call :GetDefaultRegValue "HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths\excel.exe"
if defined RegValue goto CheckExcelExistence
echo Failed to determine installation location of Microsoft Excel.
echo/
endlocal
pause
goto :EOF
:CheckExcelExistence
SET RegValue
rem Remove surrounding double quotes if the Excel executable file name
rem read from Windows registry is still enclosed in double quotes.
set "RegValue=%RegValue:"=%"
if exist "%RegValue%" goto :RunInstall
echo Registered "%RegValue%" does not exist.
echo/
endlocal
pause
goto :EOF
:RunInstall
SET RegValue
ECHO start "Launching installer file" /wait "%RegValue%" "%~dp0Installer.xlsm" /safemode
endlocal
goto :EOF
rem This subroutine queries from Windows registry the default string value of
rem the key passed to the subroutine as first and only parameter and assigns
rem this value to environment variable RegValue. Environment variable RegValue
rem is deleted and therefore is not defined after subroutine exits on failure
rem to get the registry value or when the default value is an empty string.
rem This subroutine works for Windows XP and all later versions of Windows.
:GetDefaultRegValue
set "TypeToken=2"
:Reg3Run
for /F "skip=1 tokens=%TypeToken%*" %%A in ('%SystemRoot%\System32\reg.exe QUERY "%~1" /ve 2^>nul') do (
if "%%A" == "REG_SZ" (
if not "%%~B" == "" (
set "RegValue=%%B"
goto :EOF
)
) else if "%%A" == "NAME>" (
set "TypeToken=3"
goto Reg3Run
)
)
set "RegValue="
goto :EOF
This batch code is just a demonstration. It does not start Excel when really found. Instead it just outputs the command line which would start Excel because of ECHO left of start ... in block below label RunInstall.
Further this batch code contains 4 lines with just SET RegValue. Those 4 lines output just the string value queried successfully from Windows registry and stored in environment variable RegValue. Those 4 commands help to understand what happens on execution of the batch file. Those four command lines should be deleted finally from batch file and also the single ECHO written in upper case.
Note: It is quite easy to test what happens if an expected registry key does not exist or its default value is an empty string. Just insert a single character like # before last double quote on a line starting with call :GetDefaultRegValue and the modified registry key is not found anymore.
For understanding the used commands and how they work, open a command prompt window, execute there the following commands, and read entirely all help pages displayed for each command very carefully.
call /?
echo /?
endlocal /?
for /?
goto /?
if /?
pause /?
reg /?
reg query /?
rem /?
setlocal /?
start /?
Read also the Microsoft article about Using Command Redirection Operators for an explanation of 2>nul. The redirection operator > must be escaped with caret character ^ on FOR command line to be interpreted as literal character when Windows command interpreter processes this command line before executing command FOR which executes the embedded reg.exe command line with using a separate command process started in background.
I want to search text in a log file.
If found show Error and Text.
Else show Not Found and Text.
set str2=Testing Failed in env
findstr "%str2%" SystemOut.log >nul
if not errorlevel 1 ( echo ERROR: Testing Failed in env)
if errorlevel 1 ( echo Not Found Testing Failed in env!)
Whenever in the log file it encounters Testing it says ERROR but it should not do that.
When I try to make changes by adding quotes or something Positive condition gets passed but it fails for negative condition.
Please help me with the script.
Thanks,
Machpatel
You need the /c: switch to include spaces in literal mode.
#echo off
set str2=Testing Failed in env
findstr /c:"%str2%" SystemOut.log >nul
if errorlevel 1 ( echo Not Found "%str2%")
if not errorlevel 1 ( echo found "%str2%")
The problem
I have a batch file the is being called from a Pre-Build event.
When the solution is being built by Jenkins it fails.
When the solution is being built from MSBuild or visual studio in command line It works fine.
My question is, what could cause such a behaviour?
Details
In my solution (.Net 4.5 and C++ projects), I have a batch file that is called from one of the project's Pre-Build events.
It works fine, except when I am trying to build the solution via Jenkins (CI Server).
The error is :
The command ""C:\Jenkins\apps\jenkins\jenkins_home\jobs\Builld_SMW2\workspace\Autosync\CopySymAlignFiles.bat" "C:\Jenkins\apps\jenkins\jenkins_home\jobs\Builld_SMW2\workspace\" "C:\Jenkins\apps\jenkins\jenkins_home\jobs\Builld_SMW2\workspace\Autosync\" "Debug"" exited with code 1.
from the error report, I copied the command that was used for attempting to build the solution:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /p:Platform=x86 /p:configuration=Debug /t:Rebuild /verbosity:quiet /p:WarningLevel=0 /p:Platform=x86 /p:configuration=Debug /t:Rebuild /verbosity:quiet /p:WarningLevel=0 ..\SMW2_Analysis.sln
(I am aware that the arguments are being passed twice, I have no Idea why jenkins does that, but this is not the issue...)
If I run this command from command line, the batch file works fine once the build event is triggered.
The content of CopySymAlignFiles.bat is:
Echo off
set solutionDir=%1
set projectDir=%2
set configuration=%3
REM Removing quotes
set solutionDir=%solutionDir:"=%
set projectDir=%projectDir:"=%
set configuration=%configuration:"=%
REM Does strings have a trailing slash? if so remove it
IF %solutionDir:~-1%==\ SET solutionDir=%solutionDir:~0,-1%
IF %projectDir:~-1%==\ SET projectDir=%projectDir:~0,-1%
IF %configuration:~-1%==\ SET configuration=%configuration:~0,-1%
REM This is just for easier debugging
Echo Solution Directory is: "%solutionDir%"
Echo Project Directory is: "%projectDir%"
Echo Configuration directory is: "%configuration%"
Echo Current Directory is: "%CD%"
Echo The batch file is executed at "%~dp0"
REM Copying sym_align files
copy /Y "%solutionDir%\SymAlignGlue\sym_align.dll" "%projectDir%"
copy /Y "%solutionDir%\SymAlignGlue\sym_align.ctf" "%projectDir%"
set isPV=%configuration%=="PV Release"
IF %isPV% copy /Y "%solutionDir%\SymAlignGlue\Release\SymAlignGlue.dll" "%projectDir%"
IF NOT %isPV% copy /Y "%solutionDir%\SymAlignGlue\%configuration%\SymAlignGlue.dll" "%projectDir%"
REM The result...
IF %ERRORLEVEL% EQU 0 (
REM Success
Echo Copied SymAlign files.
exit /b 0
)
IF NOT %ERRORLEVEL% EQU 0 (
REM Error
Echo An error was found while Copied SymAlign files. Error level was %ERRORLEVEL%
exit /b %ERRORLEVEL%
)
Some additional Information:
I am running Jenkins as a service and I have the service logon as An Administrator.
Does Anyone have an Idea how can this happen?
At the end, it seems that the issue was that there was a duplicate workspace folder.
1 was updated, and the other 1 was built, resulting the tested workspace did not get latest updates.
according to this link this was due to the way jenkins behaves with multiple configurations.
I am trying to setup android projects. This is a quick and easy way to do it, so all I have to do is import the final code into eclipse and export it. I use a base source code for all my projects and all I have to do is just change the app title and package name and new drawables and I have another app, However my .bat script looks like this.
#echo off
rmdir /s /q "%~dp0out"
mkdir out
xcopy "%~dp0other\backup" "%~dp0out" /E > nul
java -version
if errorlevel 1 goto errjava
cls
echo.
PAUSE
echo.
echo packagae name
echo whats your packagename after cube3d.packagename
echo.
set /P INPUT=Enter: %=%
echo.
echo App Name
echo whats your App name before Live Wallpaper
echo.
set /P INPUT2=Enter: %=%
echo.
echo Airpush App ID
echo What is the 6 digit airpush app id
echo.
set /P INPUT3=Enter: %=%
copy "%~dp0placeimages" "%~dp0out\res\drawable"
rename out\src\cube3d\aaaaapnzme %INPUT%
call run2.bat
call run3.bat
call run4.bat
It will run and go to run2.bat and stop after. it doesn't do run3.bat afterwards it fails to go to the 3rd and then the 4th. This is what the other bats look like.
run2.bat looks like this and this one works perfectly.
rep "aaaaapnzme" "%INPUT%" out\src\cube3d\%INPUT%\*.java out\AndroidManifest.xml out\src\cube3d\%INPUT%\objects\*.java
that's as far as the script will go and it fails to go to run3.bat and then to run4.bat
run3.bat looks like this
rep "zapsname" "%INPUT2%" out\res\values\strings.xml
run4.bat looks like this
rep "aeropush" "%INPUT3%" out\AndroidManifest.xml
I am using Windows 8 Pro if that helps any.
What is rep ?
perhaps CALL rep... would fix the problem.