|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Dear All,
I need to be able to run cmd.exe as the domain administrator and so far have failed to achieve this. We have some code (highlights shown delow) that does work well for running the taskmanager (disabled for normal users) but when we substitute cmd.exe for taskmgr.exe the resulting shell doesn't have admin rights - does anyone know if this is possible and if so where am I going wrong? Many thanks in advance - here's the code for taskmanager... Private Sub TaskMgr() doLogon "administrator", "xxxxx", "xyz" Shell "taskmgr.exe", vbNormalFocus doLogoff End Sub Code bits... Public Function doLogon(ByVal strAdminUser As String, ByVal strAdminPassword As String, ByVal strAdminDomain As String) As Boolean On Error GoTo DamnErr Dim lngTokenHandle As Long Dim lngLogonType As Long Dim lngLogonProvider As Long Dim blnResult As Boolean lngLogonType = LOGON32_LOGON_INTERACTIVE lngLogonProvider = LOGON32_PROVIDER_DEFAULT blnResult = RevertToSelf() blnResult = LogonUser(strAdminUser, strAdminDomain, strAdminPassword, _ lngLogonType, lngLogonProvider, _ lngTokenHandle) blnResult = ImpersonateLoggedOnUser(lngTokenHandle) doLogon = blnResult Exit Function DamnErr: Dim sERRORtxt As String sERRORtxt = "Error Number: " & Err.Number & vbCrLf & _ "Description: " & Err.Description & vbCrLf & _ "Source: " & Err.Source & vbCrLf & _ "Function: doLogon" & vbCrLf & _ "Date: " & Now() & vbCrLf & _ "Input:" & vbCrLf & _ " strAdminUser=" & strAdminUser & vbCrLf & _ " strAdminPassword=" & strAdminPassword & vbCrLf & _ " strAdminDomain=" & strAdminDomain App.LogEvent sERRORtxt, vbLogEventTypeError Err.Clear End Function |
|
#2
|
|||
|
|||
|
Hi, ccarpenter!U must look the cmd.exe whether may be run by this domain administrator,and find the difference between cmd.exe and taskmgr.exe..
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > Running commands as Administrator |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|