Jump to content
Sign in to follow this  
salnet

Problem inserting variables into Run function

Recommended Posts

salnet

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

Share this post


Link to post
Share on other sites
water

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 (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
salnet

Ah, thanks a lot water.

wWith the K-switch I found a missing space.

Share this post


Link to post
Share on other sites
Valuater

Maybe try ShellExecute () also because it allows a perimeter for arguments/variables

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
water

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 (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
salnet

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

Share this post


Link to post
Share on other sites
water

Shouldn't it be

If $vpnconnetingping > 0 Then

because Ping returns the roundtrip time.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
salnet

OK, you are right. I changed this.

But it still show the incorrect messagebox.

Share this post


Link to post
Share on other sites
water

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


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
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
Sign in to follow this  

×