VBA command line object requesting login pending user input

I wrote a script that gets some information from the program on the command line. Getting information works as long as you are logged into the program from which I am trying to extract information.

This is how I connect to the program:

Set Appl = CreateObject("WScript.Shell").Exec("cmd.exe im connect")

Return (if you are not logged in): (note: this is the theoretical conclusion if I manually enter the command in the command window)

Connecting to <some server or another>...
Authentication failed for <user: me> on <some server or another>
Enter password for <user: me> on <some server or another> (*****):

And here my macro got stuck.

I tried to check the "Enter Password" return line, but since the file system object invoking the shell is stuck waiting for user input, I can do nothing about it.

So all this does not work:

Set ApplOutput = Appl.StdOut
While Not ApplOutput.AtEndOfStream
    sLine = ApplOutput.ReadLine
    If Left(sLine, 14) = "Enter password" Then
        MsgBox ("ERROR!!" & vbCrLf & "Please login to the Integrity Client") 
    End If
Wend

, ( ), ? , .

!

edit: , , , runas . runas , :

runas /noprofile /user:Administrator cmd

edit2: : , , , . , ( ) , , . , .

+4
1

" ", .... VBA , , .Exec , . , , "" FindWindow API CMD.

- AppWinStyle arguments Exec (. : vb.net), CMD, . , , .

+1

Source: https://habr.com/ru/post/1683162/


All Articles