Jump to content

Problem inserting variables into Run function


salnet
 Share

Recommended Posts

Hello folks,

thank you for this board, I've been a long-time reader and learned a lot about AutoIt, but today I've to ask a question.

I am about to read some variables and connect them in a Run-string, but due to complexibility I fail.

First two row read the variables - variables are saved; I can read them with a message box or something else.

But if I insert the variables into the Run function, I can't get them to work. I tried diefferent ways as you can see, but I think there is only a syntax-problem I slighty miss.

$vpnconnectusername = ENVGET("USERNAME")
$vpnconnectpassword = InputBox("Passwortabfrage", "Bitte geben Sie Ihr Windows-Anmeldekennwort ein:", "", "*")
Run(@ComSpec & " /c " & 'rasdial unserVPN $vpnconnectusername $vpnconnectpassword /Phonebook:res\unserVPN.pbk', "", @SW_HIDE)
$vpnconnectusername = ENVGET("USERNAME")
$vpnconnectpassword = InputBox("Passwortabfrage", "Bitte geben Sie Ihr Windows-Anmeldekennwort ein:", "", "*")
Run(@ComSpec & " /c " & 'rasdial unserVPN" & $vpnconnectusername & $vpnconnectpassword & "/Phonebook:res\unserVPN.pbk', "", @SW_HIDE)
$vpnconnectusername = ENVGET("USERNAME")
$vpnconnectpassword = InputBox("Passwortabfrage", "Bitte geben Sie Ihr Windows-Anmeldekennwort ein:", "", "*")
Run(@ComSpec & " /c " & 'rasdial unserVPN " & $vpnconnectusername & " " & $vpnconnectpassword & " /Phonebook:res\unserVPN.pbk', "", @SW_HIDE)
$vpnconnectusername = ENVGET("USERNAME")
$vpnconnectpassword = InputBox("Passwortabfrage", "Bitte geben Sie Ihr Windows-Anmeldekennwort ein:", "", "*")
Run(@ComSpec & " /c " & 'rasdial unserVPN' & $vpnconnectusername & $vpnconnectpassword & '/Phonebook:res\unserVPN.pbk', "", @SW_HIDE)
$vpnconnectusername = ENVGET("USERNAME")
$vpnconnectpassword = InputBox("Passwortabfrage", "Bitte geben Sie Ihr Windows-Anmeldekennwort ein:", "", "*")
Run(@ComSpec & " /c " & 'rasdial unserVPN ' & $vpnconnectusername & ' ' & $vpnconnectpassword & ' /Phonebook:res\unserVPN.pbk', "", @SW_HIDE)

Thanks in advance for any help to solve this.

Kind regards

salnet

Edited by salnet
Link to comment
Share on other sites

Can you replace " /C " (Close) with " /K " (keep) so the DOS window stays open?

Might give you better error information.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Ah, thanks a lot water.

wWith the K-switch I found a missing space.

Glad you got it working :)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Regarding to my solved problem above I got another question.

I want to inform my users, if a connection was established or not.

This way I am doing this at the moment:

          $vpnconnectusername = ENVGET("USERNAME")
          $vpnconnectpassword = InputBox("Password", "Enter your Login-Password:", "", "*")
            Local $vpnconneting = Run(@ComSpec & " /C " & ' rasdial myVPN ' & $vpnconnectusername & ' ' & $vpnconnectpassword & ' /Phonebook:res\myVPN.pbk', "", @SW_HIDE)
      Local $vpnconnetingping = Ping("192.168.14.31", 250)
If $vpnconnetingping = 1 Then
        DriveMapAdd ("L:", "\\mydomain.local\Departments")
        DriveSetLabel ("L:", "Departments")
        DriveMapAdd ("R:", "\\mydomain.local\Apps")
        DriveSetLabel ("R:", "Apps")
        DriveMapAdd ("H:", "\\wvgw.local\dfs\Homes\" & $vpnconnectusername)
        DriveSetLabel ("H:", "Home")
    MsgBox(0, "Success", "Connection successful.")
Else
    MsgBox(0, "Error!", "Connection NOT successful: " & @error)
EndIf

But is won't work. Regardless if the users the input of the password or the connection wasn't established by any reason, the user gets the success-message.

Can anybody help me with this?

Kind regards

salnet

Link to comment
Share on other sites

Shouldn't it be

If $vpnconnetingping > 0 Then

because Ping returns the roundtrip time.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

What's the value of Ping and @error after you called function Ping?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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