• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 620
  • Last Modified:

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?
0
gismofo
Asked:
gismofo
  • 3
  • 3
  • 2
1 Solution
 
IanThCommented:
see http://www.tek-tips.com/faqs.cfm?fid=2760

to embed a run-as admin in a script
0
 
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.
0
Managing Security & Risk at the Speed of Business

Gartner Research VP, Neil McDonald & AlgoSec CTO, Prof. Avishai Wool, discuss the business-driven approach to automated security policy management, its benefits and how to align security policy management with business processes to address today's security challenges.

 
IanThCommented:
so imho it will need to be installed by the local admins
0
 
AbqBillCommented:
Where in a user's profile do they not have permission to write? In other words, why, specifically, is elevation required? Bill.
0
 
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 FSO
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\user.style", strUser & "\AppData\Roaming\ESRI\ArcMap\" & strName & ".style", True
 
  Set FSO = Nothing
End Sub

0
 
AbqBillCommented:
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.
0
 
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!!!
0

Featured Post

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.

  • 3
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now