Jump to content

Variable application in CMD from Autoit


Recommended Posts

Good afternoon I need help in this project I would like to apply a variable in CMD from autoit at the moment of starting the program does not show me errors but it also does not perform its function could it help me please

#include <Constants.au3>
#RequireAdmin
$con ="123456"
$usu ="hola"

Local $iPID = Run(@ComSpec & " /K netsh wlan set hostednetwork mode=allow ssid=" & $usu "key=" & $con)
Local $iPID = Run(@ComSpec & " /K netsh wlan set hostednetwork mode=allow ssid=" & $usu "key=" & $con, '', $STDERR_CHILD + $STDOUT_CHILD)
ProcessWaitClose($iPID)
StdoutRead($iPID)

 

Link to comment
Share on other sites

Insert a space before "key=":

Local $iPID = Run(@ComSpec & " /K netsh wlan set hostednetwork mode=allow ssid=" & $usu " key=" & $con)

 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

You should get syntax error messages in the SciTE output pane when you press F5.

Quote

>Running AU3Check (3.3.14.5)  from:C:\Program Files (x86)\AutoIt3  input:C:\Local\Test.au3
"C:\Local\Test.au3"(6,96) : error: syntax error
Local $iPID = Run(@ComSpec & " /K netsh wlan set hostednetwork mode=allow ssid=" & $usu " key="
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Local\Test.au3 - 1 error(s), 0 warning(s)
!>21:58:21 AU3Check ended. Press F4 to jump to next error.rc:2
+>21:58:22 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 1.394

The concatenation operator after $usu is missing.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

Ok at the moment of executing it, it does not create an error message, however, not to perform its function in this case is to create a network hosted on windows, the program runs without any problem according to the SciTE panel, but it does not perform its function on windows.

Edited by Hemrry
Link to comment
Share on other sites

Can you please post the messages you get in the DOS window where netsh gets run?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

Sorry the problem is that it does nothing, it only runs and does not mutrate an error code in the SciTE panel and it also does not show an error in cmd, it runs without an error but does not perform the function

Link to comment
Share on other sites

Your script can display errors in the SciTE output pane at the bottom of the screen AND the DOS window you create by the Run command.
With the "/K" (keep) flag the DOS window will stay open until you close it by entering the Exit command into the DOS window.

Can you please post the script you actually run? In your OP you run NetSh twice which is not necessary.

Another good idea would be a screenshot where we can see the SciTE and DOS window.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

Hi.

Let the script put the command you want to execute into your clipboard and paste it into an adminstrative (Run-As-Admin) CMD box, what output do you receive?

$NSH_CMD="netsh wlan set hostednetwork mode=allow ssid=" & $usu & " key=" & $con)
consolewrite($NSH_CMD & @CRLF)
clipput($NSH_CMD)

 

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

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...