C++ WinApi project access issue - installation

I have a C++ WinApi project which works fine in VS (Debug and Release) , the application writes some data in a text file start.txt and copies some images to a directory "bitmaps" , both the text file and the directory are located in the Application's main Directory, but when I install the application with a setup program in C:\Program Files (x86)\ or in C:\Program Files\ , both the text file start.txt and the folder "bitmaps" become read only , not accessible for the application to store data in them, so the application does not function correctly and some error show like:
((cimg::fopen(): failed to open file 'C:\Program Files\application Name\bitmaps\user1.bmp with mode 'wb'))
this is understood because there are no images in the directory, I checked also the text file start.txt also empty
I have read somewhere that Windows System does not allow writing data in the "Program Files" and "Program Files (x86)" directories and data should be written in AppData or somewhere else by applications
by the way , the application does run correctly if I run it as administrator
is there a way to set permission to the directory and the text file to make them accessible (writable) for the application to store data into without running the application as administrator after installing it?

The best solution to this is to store data where they should be for example in the AppData , the problem then will be solved
to get the path of AppData folder :
Appdatapath= getenv("appdata"); // geting AppData path
Appdatapath +=("\\yourappData"); // adding a new directory for your
// application where data are written

Related

How do I save the installer metadata in the folder with the installed application?

I have an app for Windows. I build the installer for this application using InstallForge.
Task: transfer metadata from the installer file (1 specific parameter) to the folder with the installed application.
For example: InstallerMyApp.exe contains in its metadata the parameter "Modification date" with value "01.02.2023". During the installation I specify the path C:\Program Files\my app.
As a result, I want the installer to create in the folder C:\Program Files\my app the file "Modification date.txt" which will have the value "01.02.2023".
To paraphrase, I need to automatically save the installer metadata in the folder where the application is installed.
How is it possible to do this?
I would be grateful for even the slightest hint.
Frankly, I have no idea what to do.Perhaps I should give up InstallForge.

MacOS .app files display and behave like folder in windows explorer

I have a spring boot server hosting a product's file distribution and the product has .exe and .app versions. The .exe file is stored and transmitted without issue but the .app file (created from MacOS and transferred into windows via TeamViewer) is displayed as a folder. The server does not recognize it as a file as well and throws
java.io.FileNotFoundException: source\MyApp.app (Access is denied)
When I create a sample text file and save it as test.app it is treated as a file and not a folder. There is no option to change the folder to a file or method to change it's default opening with explorer. I think it does not care about the .app extension and it treats the .app as file name. I tried to zip it and send to windows but it still doesn't work. See the screenshot for what I mean.
My question is is there any way to change the way windows treats the .app file as a folder? I want it to treat it like a unopenable or raw file.
I solved it by removing the extension and treating it as a normal folder (because .app will not allow Java to read from it and I don't know why). Then I read the contents of the file and made it into a zip archive with the extension 'app' and it works correctly.
I am accepting this as a temporary solution but need to find the cause of this problem.

System cannot find path even though it exists in paths

Working on a batch file that calls another batch file.
K:\Market Risk>call "K:\Market Risk\activate.bat"
The system cannot find the path specified.
So I set the path at the beginning of my batch file and made sure it was there:
SET PATH=%PATH%;K:\Market Risk\
K:\Market Risk>echo %PATH%
C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;
C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;
C:\WINDOWS\System32\OpenSSH\;C:\Program Files (x86)\Shoreline Communications\
ShoreWare Client\;C:\Program Files\dotnet\;C:\Program Files (x86)\Microsoft SQL Server
\150\DTS\Binn\;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;
C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\
WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files (x86)\
Shoreline Communications\ShoreWare Client\;C:\Program Files (x86)\Common Files\Oracle\
Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;
C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;
C:\Program Files (x86)\Shoreline Communications\ShoreWare Client\;
C:\Users\Kyle.Dixon\AppData\Local\Microsoft\WindowsApps;C:\Users\Kyle.Dixon\AppData\Local\
Programs\Git\cmd;C:\Users\Kyle.Dixon\AppData\Local\atom\bin;C:\Users\Kyle.Dixon\Documents\
R\R-3.5.2\bin\R.exe;C:\Users\Kyle.Dixon\Documents\R\R-3.5.2\bin;C:\Users\Kyle.Dixon\
AppData\Roaming\MarketView\MarketView ExcelTools\;K:\Market Risk\
However, I'm still getting the same error:
K:\Market Risk>call "K:\Market Risk\activate.bat"
The system cannot find the path specified.
Has anyone had this issue before?
I recommend reading What is the reason for "X is not recognized as an internal or external command, operable program or batch file"? It should help to understand how the environment variable PATH is managed by Windows. It is unfortunately not really good managed by Windows which cause lots of problems because of no command is available to safely add/remove a folder path to system or user PATH. The results of missing such a command or executable written by Microsoft to safely update PATH with applying all necessary error checks are lots of not good coded scripts which quite often corrupt system and user PATH stored in Windows registry on trying to update them.
My recommendation is opening Windows Control Panel - System and Security (on View by: Category selected) - System - Advanced System Settings - Environment Variables as administrator and cleaning up both Path environment variables, the user Path (upper pane) and the system Path (lower pane). The window Environment Variables can be opened also by clicking on Windows Start button, typing on keyboard environment and Windows suggests in the menu Edit environment variables for your account and Edit the system environment variables in the language of Windows. Click on one of the two suggested items and if necessary depending on Windows version next on button Environment Variables.
The system Path should start always with following default Windows folder paths:
%SystemRoot%\System32
%SystemRoot%
%SystemRoot%\System32\Wbem
%SystemRoot%\System32\WindowsPowerShell\v1.0\
%SystemRoot%\System32\OpenSSH\
The system Path was badly updated once in the past if it does not start anymore with these folder paths exactly as written here. (The last folder path is available only on Windows 10 since version 1809 and of course Windows 11.) C:\WINDOWS stored in Windows registry and displayed on editing the system Path instead of %SystemRoot% is an indication that an installer executable or script has not good updated system Path because of replacing original folder paths with referencing environment variable SystemRoot by the expanded version. This does not really matter for these folder paths, but could have been harmful for other folder paths.
No folder path should exist more than once in one of the two Path environment variables.
Remove all duplicates in user Path as well as in system Path.
Your two Path environment variables contain three times:
C:\Program Files (x86)\Common Files\Oracle\Java\javapath
C:\Program Files (x86)\Shoreline Communications\ShoreWare Client\
C:\WINDOWS
C:\WINDOWS\system32
C:\WINDOWS\System32\OpenSSH\
C:\WINDOWS\System32\Wbem
C:\WINDOWS\System32\WindowsPowerShell\v1.0\
A folder path existing already in system Path should not exist a second time in user Path and of course also not once more in system Path.
A folder path can be listed without or with a backlash in Path. I prefer folder paths without backslash at end in Path as this causes less troubles on updating Path in future on using command reg by a batch script.
Environment variable Path should contain only folder paths and not fully qualified file names.
So C:\Users\Kyle.Dixon\Documents\R\R-3.5.2\bin\R.exe is completely nonsense in Path.
After cleanup of both Path environment variables the folder paths in system Path should be something like:
%SystemRoot%\system32
%SystemRoot%
%SystemRoot%\System32\Wbem
%SystemRoot%\System32\WindowsPowerShell\v1.0\
%SystemRoot%\System32\OpenSSH\
%CommonProgramFiles(x86)%\Oracle\Java\javapath
%ProgramFiles(x86)%\Microsoft SQL Server\150\DTS\Binn
%ProgramFiles(x86)%\Shoreline Communications\ShoreWare Client
C:\Program Files\dotnet
For the last path it is better to keep C:\Program Files and do not use %ProgramFiles%, except there is C:\Program Files\dotnet and C:\Program Files (x86)\dotnet which I don't know as I don't have such a directory on my Windows computer. For the reason see the Microsoft documentation page WOW64 Implementation Details.
The user Path should be finally something like:
%LocalAppData%\atom\bin
%LocalAppData%\Microsoft\WindowsApps
%LocalAppData%\Programs\Git\cmd
%AppData%\MarketView\MarketView ExcelTools
%UserProfile%\Documents\R\R-3.5.2\bin
There is not much written about environment in which the two batch files are executed. So most written below is pure speculative.
I suppose that drive K: is not a drive on a local hard disk, but a network drive. So it is possible that the network resource mapped to drive K: is currently not available either because of network resource not mapped to drive letter K: or there is network connection issue or a network resource permission issue.
Windows remaps a network resource to a drive letter as once done by the user only on logon of the user because of network drive mappings are user account related stored by Windows in Windows registry. So if the batch file is executed as scheduled task with using a different account or also on user not logged in, the drive K: does indeed not exist. The scheduled task executing the batch file must be configured to use the account which has the necessary permissions to access all network resources and local directories/files which are accessed by the batch file. And it is additionally necessary to access files and folders on a network resource with their UNC paths instead of using drive letter K: of network drive not existing on execution of the batch file in this environment.
See also: What must be taken into account on executing a batch file as scheduled task?
But possible is also that the error message
The system cannot find the path specified.
is not output by cmd.exe on processing the batch file containing the command line
call "K:\Market Risk\activate.bat"
but on a command line executed on processing the batch file K:\Market Risk\activate.bat.
Therefore I suggest to remove from both batch files #echo off at top or change it to #echo on and run the main batch file from within a command prompt window, see debugging a batch file. Then it should be 100% clear which command line in which batch file is responsible for this error message.

How to export ftp list from phpdesigner 8?

I've got ftp connections list in phpDesigner.
How to export or to save it?
you can find the ftp xml file in:
C:\Users\your user dir\AppData\Roaming\phpDesigner
phpdesigner_ftp.xml
For Windows XP users (and I assume they still exist in numbers!)... the Path is:
C:\Documents and Settings\[Windows-User]\Application Data\phpDesigner
For example, I've Windows User account with the name "Ruturaaj". So, my path looks like:
C:\Documents and Settings\Ruturaaj\Application Data\phpDesigner
It's quite handy to know this folder because it contains some other useful XML files as well. For example, look for "autocomplete.xml". This is the file that contains all Auto-Complete code snippets you've added to phpDesigner over a period of time. Now that you know this folder path, I'd suggest to backup this folder and simply overwrite the files with new installation to setup same environment over and over again.

error when i want to save java file in jdk/bin

when i save java file error is you dont have permission to save in this location contact the administrator to obtain permission on window7
Don't store application data in the "Program Files" directory.
It is very bad design and regular users don't have write access to that directory (for a very good reason).
So even if you changed your settings locally to open up the door for viruses your application won't run on other computers.
Besides: storing a Java file in the JDK directory serves no purpose at all.
Btw: your uppercase letters are broken, as well as the dot or the comma...
That's normal - jdk/bin is the installation directory of the JDK, regular users cannot (and should not) write files there. You'll have the same problem on Linux/Unix and on Mac OS X, where installation directories are off-limits to regular users.
Write your files to the users home directory (System property "user.home", works across platforms), or let the user choose where you save stuff.
Bin directory do not allow directly to save program in it.
it is so simple, just save your .java file on desktop and then copy paste it in Bin. done ;)
If the file can't save directly to c:\program files\java\jdk1.8.0\bin\
Solution:-
Click start Menu type Notepad command in run run as administrator
Right click the Notepad run as Administrator, then type the program file can save directly to c:\program files\java\jdk1.8.0\bin\
Just try it......

Resources