dcsimg
Results 1 to 4 of 4
  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2018
    Location
    Bandung
    Posts
    15

    Resolved [RESOLVED] How To Make To OPEN (Open Device)

    Hi There,
    I wish to open my 'open device', I use these method :

    Code:
    Private Sub OpenDeviceManager_Click()
    Dim oPValue As Long
    oPValue = Shell("C:\WINDOWS\system32\mmc.exe C:\WINDOWS\system32\devmgmt.msc")
    End Sub
    Above code working fine, but it will working when I open my program under 'Administrator' -> Right Click -> Run as administrator, but if the program I do open just -> Right Click -> Open, then when I clicked my 'OpenDeviceManager_Click()' Button I get a failed or something an errors page.

    My question, how to write the code more better, so if I open without used Run as administrator is not getting failed or errors page.

    I need your help.

    Thank you,
    Rukmana Badjuri.

  2. #2
    Member
    Join Date
    Mar 2018
    Posts
    56

    Re: How To Make To OPEN (Open Device)

    This may not be a code issue. If you can't run the file manually because of permissions, there is no code that you can run to bypass it. You will need to assign the appropriate permissions as the admin and then you code will work. this link may help: https://blogs.technet.microsoft.com/...o-a-non-admin/

  3. #3

  4. #4

    Thread Starter
    New Member
    Join Date
    Mar 2018
    Location
    Bandung
    Posts
    15

    Re: How To Make To OPEN (Open Device)

    Hello,

    DllHell :
    Thank you for an answer,
    If I am not find it the option I just do :
    1). Run the program with as administrator.
    2). Run VSPE Virtual Simulator or
    3). The exe file make it compatible to windows 7.

    Fafalone :
    As well as your suggestion, I found these code :
    Code:
    Option Explicit
     
    Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _
    ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
     
    Private Const SW_SHOWNORMAL As Long = 1
     
    Private Sub Cmd1_Click()
        ShellExecute Me.hwnd, "OPEN", "c:\windows\system32\devmgmt.msc", vbNullString, "C:\", SW_SHOWNORMAL
    End Sub
    Above code I testing working great, no more errors.

    My problem has solved.

    Thank you.
    Rukmana Badjuri.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width


×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.