Jump to content

Check that folder can be created. If not ask for administrator


 Share

Recommended Posts

Hi i want to create a folder in c:\Program Files and my code does this. But i am an administrator. If the person running my application is a user then they wouldnt be able to intall and it needs to ask for a administrator to intall.

I've added the if statement but not sure if this will work or not. Any ideas would be appriciated.

I also need to check if the dir is already created so it doesnt install over the top. Here is the code...

if DirCreate ( @ProgramFilesDir&"\FFT" ) then
    FileCopy (@ScriptDir & "\FFT\school_FFT_DB_SCH.mdb", @ProgramFilesDir&"\FFT", 0 )

; Sets a shortcut with ctrl+alt+t hotkey
    FileCreateShortcut(@WindowsDir & "\Explorer.exe",@DesktopDir & "\FFT Database.lnk",@WindowsDir,"/e,"& @ProgramFilesDir & "\FFT\school_FFT_DB_SCH.mdb", "FFT Database", @SystemDir & "\shell32.dll", "^!t", "43", @SW_MINIMIZE)

    MsgBox(4160,"Database Installation Complete"," The Database has been successfully installed to C:\Program Files\FFT." & @CRLF & "" & @CRLF & " A shortcut to this file has been placed on your desktop." & @CRLF & "" & @CRLF & "")
else

    MsgBox(48,"Install Unsuccessful","Please contact your administrator to install the database")

endif
Link to comment
Share on other sites

Hi i want to create a folder in c:\Program Files and my code does this. But i am an administrator. If the person running my application is a user then they wouldnt be able to intall and it needs to ask for a administrator to intall.

I've added the if statement but not sure if this will work or not. Any ideas would be appriciated.

well, run it as a regular user without admin privileges and you will know if it works!

Cheers

Kurt

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

well, run it as a regular user without admin privileges and you will know if it works!

Cheers

Kurt

I was going to do that but was feeling lazy and a little :) . It's monday morning and i thought one of you coding gods :whistle: could help ease the pain :)

Link to comment
Share on other sites

You could run this code 1st.

If Not IsAdmin() Then
    MsgBox(0x30, "", "Please contact your administrator to install the database")
    Exit
EndIf

:)

NICE ONE!!! You are the man! Didnt know about the IsAdmin function. Thankyou so much!

Is there a function similar to that that will check if a folder is already in exsistance?

Many thanks again. Tested as a basic user and it works. :whistle:

Link to comment
Share on other sites

NICE ONE!!! You are the man! Didnt know about the IsAdmin function. Thankyou so much!

Is there a function similar to that that will check if a folder is already in exsistance?

Many thanks again. Tested as a basic user and it works. :)

I've found it it's FileExists()

Cheers

:whistle:

Link to comment
Share on other sites

Whats the benefit of this? You know the users can't install the database so you must do it.

Why don't you use 'RunAsSet()' and all users are able to install? Then you have time enough to ....

EDIT: missing question marks :">

Edited by Briegel
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...