Jump to content

Recommended Posts

Posted

I am trying to use _WinNet_AddConnection2(). The options for the $iOptions parameter are:

Quote

[optional] Connection options. Can be one or more of the following:
    1 - The network resource connection should be remembered
    2 - The operating system may interact with the user for authentication purposes
    4 - The system not to use any default setting for user names or passwords without offering the user the
        opportunity to supply an alternative. This flag is ignored unless bit 2 (interactive) is also set.
    8 - Forces the redirection of a local device when making the connection
    16 - The operating system prompts the user for authentication using the command line instead of a GUI.
        This flag is ignored unless bit 2 (interactive) is also set.
    32 - If this bit is set, and the operating system prompts for a credential, the credential is saved by the credential manager.
        If the credential manager is disabled for the caller's logon session, or if the network
        provider does not support saving credentials, this flag is ignored.
        This flag is also ignored unless you set
bit 5 (command line instead of GUI).

I want to use the "32" flag to save the credentials and for some reason the documentation says that in order to use the "32" flag, you also need to use the "16" flag which prompts for the username and password via the command line instead of a GUI. So I tried this, but unfortunately I cannot enter the username and password via the command line.

Here is my test code:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Change2CUI=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#include <WinNet.au3>

_WinNet_AddConnection2(Null, '\\server\share', 0, 0, 1, 2+4+16+32)

; keep script alive
While True
    sleep(100)
WEnd

I compiled this as a command line exe and ran it and I get this in the console:

The password or user name is invalid for \\server\share.

Enter the user name for 'server':

But when I type, the letters do not appear in the console so I cannot enter the username or password.

I have tested this with a real, valid server address that I know works and have gotten the same result. I have also tested this without using the "16" or "32" flag and a windows GUI appears which allows me to enter a username and password and this works fine.

Is there anyway for autoit to allow entering information in via the console with a winapi function like this or is it not supported?

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...