Reputation: 177
I am trying to execute a .exe file (created by VB6) on Windows 7. What the application will do is to simply create a text file, and then read the text for a text file. All the functions are being tested successfully on Windows XP. When I execute the .exe file on Win 7, the functions act as usual but the file I created doesn't exist on the specific path (C:\test.txt). The most weird thing is that I can still read the content from the text file (through the .exe file) despite being unable to find the text file on file explorer.
Then I discovered that I have to choose [run as Administrator] to execute the .exe file, so that the file (test.txt) will be created on the C: drive. I am very curious how the .exe file can still read the text file even it is not existed, and how can I force the .exe file to run as Administrator?
Here is the coding to write and read a file.
Open "C:\" & "test.txt" For Output As #1
Print #1, cDrive.Text
Close #1
Open "C:\" & "test.txt" For Input As #1
Input #1, msg
Close #1
cDrive.Text = msg
Exit Sub
Upvotes: 0
Views: 1739
Reputation: 11
To answer the third remark: Windows Vista and Windows 7 User Access Control (UAC) introduced a feature called the VirtualStore which is designed to add an extra layer of security protection for applications installed under the Program Files folder. If you search for the file on you hdd you might find a second instance of the file in /User/AppData/Local/VirtualStore So that's why it is still able to read text.txt allthough is doesn't excist in the location you mentioned.
Upvotes: 1
Reputation: 759
Good luck
Upvotes: 0
Reputation: 2213
Drive C is being protected by Win7, you can still write to it, but you really shouldn't.
If you want to run the app as admin:
Now every time you run the app, it will run as administrator
Upvotes: 0