Prevent Elevated Privileges in Vista using VB6 or VS2005

I have a simple program written in VB6 that copies folders/files from a network location to the users profile.  The program works great in XP, but under Vista, it requires elevation.  The common user does not have admin rights to execute the program and group policy forces that UAC be turned on.  Is there a way around this using either VB6 or VS2005?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


to embed a run-as admin in a script
gismofoAuthor Commented:
This program is used on an enterprise IT system where admin user names/password are different from organization to organization.  An admin username/password used in one organization cannot be used in another organization.  Using the RUNAS by embedding the username/password in the program will not work in this case.
Managing Security Policy in a Changing Environment

The enterprise network environment is evolving rapidly as companies extend their physical data centers to embrace cloud computing and software-defined networking. This new reality means that the challenge of managing the security policy is much more dynamic and complex.

so imho it will need to be installed by the local admins
Where in a user's profile do they not have permission to write? In other words, why, specifically, is elevation required? Bill.
gismofoAuthor Commented:
I have no idea why elevation is required.  Probably because my company's computer security is set to the highest level possible.  Here is the simple code:

Option Explicit
Dim WshShell
Dim WScript
Dim strUser
Dim strName

Public Sub Main()
  Set WshShell = CreateObject("WScript.Shell")
  strUser = WshShell.ExpandEnvironmentStrings("%USERPROFILE%")
  strName = WshShell.ExpandEnvironmentStrings("%USERNAME%")
  Set FSO = CreateObject("Scripting.FileSystemObject")
  If FSO.FolderExists(strUser & "\AppData\Roaming\ESRI") Then
    FSO.DeleteFolder strUser & "\AppData\Roaming\ESRI"
  End If
  FSO.CopyFolder "\\server1-gis\Desktop\ESRI", strUser & "\AppData\Roaming\ESRI", True
  FSO.CopyFile "\\server1-gis\Desktop\", strUser & "\AppData\Roaming\ESRI\ArcMap\" & strName & ".style", True
  Set FSO = Nothing
End Sub

Hi, that code fragment doesn't suggest anything to me off the top of my head as to why it seems to require elevation. Here is how I would test this scenario: Use a VBScript script (.vbs file) containing the above code, and try running it 1) using a limited user account, and 2) under an administrator account (not elevated). For each of these trials, take note where (which line) the error occurs. (To adapt the code as a VBScript script, remove the word 'Public' and at the end of the script use the line 'Main'.) Bill.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gismofoAuthor Commented:
Removing the 'public' was the key.  I changed the Public Sub Main () to Private Sub Main () and it worked without elevation.  Simple, but effective.  Thanks!!!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.