Write file from VB6 at Vista OS
My program will write to file where the program is located. It's working fine with VB6 & Windows XP but with Vista the file can't write into the same location with the program. There is no error but I still can't find the file that it should write.
Is there any special coding to write to file with Vista?
Please help.
Thanks
Re: Write file from VB6 at Vista OS
Quote:
Originally Posted by
the_magicien
My program will write to file where the program is located. It's working fine with VB6 & Windows XP but with Vista the file can't write into the same location with the program. There is no error but I still can't find the file that it should write.
Is there any special coding to write to file with Vista?
I assume that you are doing this in Program Files. That directory is write protected for user.
You could:
1) Run your program as administrator (either manually or by using manifest).
2) Manually set write rights for that directory.
3) Write a file where it should be written - e.g. Application Data.
Re: Write file from VB6 at Vista OS
Create a folder for your program in the User or Common Application Data folder. Vista does not allow writing to the Program Files. Files in that folder should be read only. Do all your read/writing in the Application Data folder you create.
Re: Write file from VB6 at Vista OS
tq jmedved.how I can use manifest?Can you give sample.
Thanks
Re: Write file from VB6 at Vista OS
You still won't be able to write to the PROGRAM FILES folder under Vista or later OS. For Vista, use the %ProgramData% folder to create a program file for your app. (You could do the same for XP if you wanted the same program to run)
Environmental Variables (Vista)
http://vistaonwindows.com/environment_variables.html
Re: Write file from VB6 at Vista OS
tq dglienna.Im not sure how to use this enviroment variables.it there any sample
coding that i can use as example?
Thanks
Re: Write file from VB6 at Vista OS
Another option is to disable that pesky UAC
Re: Write file from VB6 at Vista OS
Quote:
Originally Posted by
the_magicien
how I can use manifest?Can you give sample.
Add file named yourfilename.exe.manifest with following content:
Code:
<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
</asmv1:assembly>
Important part is requestedExecutionLevel (requireAdministrator). This will make your program ask for admin rights on startup and after that, you will get everything you have on XP (full admin credentials).
P.S. Proper way would be just to write where you are supposed to (Application Data).
Re: Write file from VB6 at Vista OS
That won't write to the program files folder...