Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 24th, 2003, 07:59 AM
ccarpenter ccarpenter is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 2 ccarpenter User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy Running commands as Administrator

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

Reply With Quote
  #2  
Old November 25th, 2003, 08:46 PM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
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..

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Running commands as Administrator


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway