Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Chances are that you have to create your own "shell" function using the Win32 API.</p> <p>Using the CreateProcessWithLogonW API you can create new processes under different credentials and optionally load user profile information.</p> <p>In the code snippet below if you replace</p> <ul> <li>username - with your username</li> <li>domain - with your domain or "vbNullString"</li> <li>password - with your password</li> <li>parameter 4 - replace 0 with 'LOGON WITH PROFILE' to load the specified users profile.</li> </ul> <p>See the documentation for the <a href="http://msdn.microsoft.com/en-us/library/ms682431(VS.85).aspx" rel="nofollow noreferrer">CreateProcessWithLogonW API</a> for further specifics. Going this route you have full control and full responsibility for launching the application.</p> <p>Again this is just a sample and you may have to play with it a little to get it to do what you want.</p> <pre><code> Imports System.Runtime.InteropServices Public Module modShell &lt;StructLayout(LayoutKind.Sequential)&gt; _ Public Structure STARTUPINFO Public cb As Integer Public lpReserved As String Public lpDesktop As String Public lpTitle As String Public dwX As Integer Public dwY As Integer Public dwXSize As Integer Public dwYSize As Integer Public dwXCountChars As Integer Public dwYCountChars As Integer Public dwFillAttribute As Integer Public dwFlags As Integer Public wShowWindow As Short Public cbReserved2 As Short Public lpReserved2 As Integer Public hStdInput As Integer Public hStdOutput As Integer Public hStdError As Integer End Structure &lt;StructLayout(LayoutKind.Sequential)&gt; _ Public Structure PROCESS_INFORMATION Public hProcess As IntPtr Public hThread As IntPtr Public dwProcessId As Integer Public dwThreadId As Integer End Structure Public Declare Unicode Function CreateProcessWithLogonW Lib "Advapi32" (ByVal lpUsername As String, ByVal lpDomain As String, ByVal lpPassword As String, ByVal dwLogonFlags As Int32, ByVal lpApplicationName As String, ByVal lpCommandLine As String, ByVal dwCreationFlags As Int32, ByVal lpEnvironment As IntPtr, ByVal lpCurrentDirectory As String, ByRef si As STARTUPINFO, ByRef pi As PROCESS_INFORMATION) As Integer Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As IntPtr) As Integer Public Const LOGON_WITH_PROFILE As Int32 = &H1 Public Const NORMAL_PRIORITY_CLASS As Int32 = &H20& Public Const STARTF_USESHOWWINDOW As Int32 = &H1 Public Const SW_HIDE As Int16 = 0 Public Const SW_SHOW As Int16 = 5 Public Function Shell(ByVal strCmdLine As String, ByVal strCurrentDirectory As String) As Boolean Dim pi As PROCESS_INFORMATION Dim si As New STARTUPINFO si.cb = Marshal.SizeOf(si) si.dwFlags = STARTF_USESHOWWINDOW si.wShowWindow = SW_SHOW Dim result As Integer = CreateProcessWithLogonW("username", "domain", "password", 0, vbNullString, strCmdLine, NORMAL_PRIORITY_CLASS, IntPtr.Zero, strCurrentDirectory, si, pi) If result &lt;&gt; 0 Then Call CloseHandle(pi.hThread) Call CloseHandle(pi.hProcess) Else Return False End If Return True End Function End Module </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload