hi
i am very new here
i doing a window app using vs2005 to download file using FTP to my c drive
it have no error when i run it in window xp
but when i test it in vista i facing a problem stating access to path "c:\program file\...." is deniel
any work around can be apply to it?
i know if i grant the folder security to everyone then this problem will be solve
but if do so i need to configure it 1 by 1 for every computer
appreciate for any help....

Dani AI

Generated

Vista (and later Windows) blocks non‑elevated programs from writing into Program Files. That is UAC behavior (you’ll see writes redirected into the per‑user VirtualStore when an older app tried to write there), which explains why the same code worked on XP but fails on Vista. ’s suggestion to run elevated or write to a different folder would work, but both have operational or security downsides. See the UAC overview for details: User Account Control (UAC) overview.

Two practical, supported patterns for automatic updates without asking every user for admin credentials:

  • Store writable data in the correct locations. For per‑machine shared data use ProgramData (CommonApplicationData); for per‑user data use LocalAppData/Roaming. Example to get the common folder in VB.NET:

    Dim commonData As String = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)

    Reference: Known Folders (ProgramData / CommonApplicationData).

  • If you must update files under Program Files, perform the update with elevated rights but only in a controlled way: install a small privileged updater/service at install time (requires one admin action), then let that service or scheduled elevated task perform unattended downloads and writes. A Windows Service running as LocalSystem is a common approach for this use case; see Introduction to Windows Service Applications. Alternatively, use a per‑user deployment (ClickOnce) so updates do not need elevation: .

Do not try to programmatically retrieve an administrator password — Windows will not expose that, and storing credentials or granting “Everyone” write rights is insecure. Create the privileged updater/ task once during an admin install, or rework the app to use per‑user or ProgramData locations for files it needs to modify. ’s link may help historically, but the modern, supported options above are safer and scalable.

Recommended Answers

All 9 Replies

Try running the program as an Administrator

Try running the program as an Administrator

i not sure is it will have any problem if i run as administrator
but for my project i want it to be run for any login user
because some user are restrict to the folder change
and what i want to do here is automatically update the patch everyday

try to change the path, in vista I dont think you can manipulate the program files folder without having administrative rights.

try to change the path, in vista I dont think you can manipulate the program files folder without having administrative rights.

yes, i know if i change the patch to other directory like D or F or put it in desktop will be ok, just wanna know is that any work around to do tis.
its seem like we have no other option to do if v really want to do it on c:\program file?

alonso you should to create another program, try this codes in it, it might work

Dim passy as As New Security.SecureString()
Dim password As String
For Each str As Char In password
passy.AppendChar(str)
Next

Process.Start("C:\Program Files\YOURPROGARM\PROGRAMNAME.exe", "username", passy, Nothing)

alonso you should to create another program, try this codes in it, it might work

Dim passy as As New Security.SecureString()
Dim password As String
For Each str As Char In password
passy.AppendChar(str)
Next

Process.Start("C:\Program Files\YOURPROGARM\PROGRAMNAME.exe", "username", passy, Nothing)

thanks for the reply
this seem like creating another program to call my current program
i will try it and let u know the result
what i trying to find out now is it possible i programingcally run the task as administrator but unfortunately i cant find it
i will try this and let u know the result

alonso you should to create another program, try this codes in it, it might work

Dim passy as As New Security.SecureString()
Dim password As String
For Each str As Char In password
passy.AppendChar(str)
Next

Process.Start("C:\Program Files\YOURPROGARM\PROGRAMNAME.exe", "username", passy, Nothing)

hi, i realise 1 thing
if i using this program to call another program means i need to know the username and password for every user who log in to the computer
if there any way for me to get it?

Process.Start("C:\Program Files\YOURPROGARM\PROGRAMNAME.exe", "username", passy, Nothing)
i think this can be done if i using administrator as username
but the problem is i not able to get the credential or password for administrator
is there any way to get it?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.