Jump to content
Sign in to follow this  
Tazx2x

Send text with Variables into CMD!

Recommended Posts

Hey Guys,

 

  I would like Autoit to simple type in : 

 Msiexec /I Code42_client.msi CP_ARGS="DEPLOYMENT_URL=https://code42-auth.antas.com:4285&DEPLOYMENT_POLICY_TOKEN=9ef3e3a5-c58b-4300-9898-ebb99edc09a9" CP_SILENT=true /norestart /qn

Into cmd but it gives me an error. Wheter I use SEND or ControlSend. An ideas

 

Thanks you in advance! 

Share this post


Link to post
Share on other sites

use the Run command. Use the helpfile for examples. post what you are using here if you want help, even if the script does not work. msi are easy to install


My resources are limited. You must ask the right questions

 

Share this post


Link to post
Share on other sites
6 minutes ago, Tazx2x said:

Wheter I use SEND or ControlSend. An ideas

Neither ... just use runwait... something like this: 

RunWait(@ComSpec & ' /c Msiexec /I Code42_client.msi CP_ARGS="DEPLOYMENT_URL=https://code42-auth.antas.com:4285&DEPLOYMENT_POLICY_TOKEN=9ef3e3a5-c58b-4300-9898-ebb99edc09a9" CP_SILENT=true /norestart /qn')

Use /k in case it doesn't work so the cmd window stays open to see the error.

Jos


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Here is my code.

 

#RequireAdmin
run ("cmd")

WinWaitActive ("Administrator: C:\WINDOWS\SYSTEM32\CMD.exe")


ControlSend ("Msiexec /I Code42_client.msi CP_ARGS="DEPLOYMENT_URL=https://code42-auth.antas.com:4285&DEPLOYMENT_POLICY_TOKEN=9ef3e3a5-c58b-4300-9898-ebb99edc09a9" CP_SILENT=true /norestart /qn")
Send("{enter}")

Not sure what im doing wrong 

Share this post


Link to post
Share on other sites
18 minutes ago, Tazx2x said:

Maybe im not following I dont wanna "Run"

So what do you think you do when you Cut&Paste the command into the CMD window and send ENTER?

.. but whatever... look at the helpfile for the proper syntax of controlSend() when you insist as the current use is invalid.

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

While I would recommend what Jos suggested any day over this maybe you just don't have a way around it

 

Const $_SEND_RAW = 1
$sYourCmd = 'Msiexec /I Code42_client.msi CP_ARGS=' & _
            '"DEPLOYMENT_URL=https://code42-auth.antas.com:4285&DEPLOYMENT_POLICY_TOKEN=9ef3e3a5-c58b-4300-9898-ebb99edc09a9"' & _
            'CP_SILENT=true /norestart /qn'

RunWait(@ComSpec & " /c " & $sYourCmd & " /k")
;OR
$PID = run (@ComSpec)
Sleep(1000) ;;NOTE: You need to get the handle from PID instead of just waiting
ControlSend("[CLASS:ConsoleWindowClass]", "", "", $sYourCmd, $_SEND_RAW )
ControlSend("[CLASS:ConsoleWindowClass]", "", "", "{ENTER}")

Its not guaranteed to be successful, AND

you really should be getting the handle rather than just indiscriminately sending crap to any open console window AND

its just bad juju

Share this post


Link to post
Share on other sites

Hey guys thanks for the assist! I think I know what the issue is.

The script works on win7 but when I run cmd as an admin on win 10 this seems to be the issue. I need to figure that out.

When I open cmd on 10 (reg user) everything works but I need it to work as admin!

Share this post


Link to post
Share on other sites

Hello Everyone,

 

 

 I seem to have run into an issue with Windows 10. 

When running (See Below) on windows 10 it prompt for user opens cmd as admin and does nothing.

If I run the same code without (#RequireAdmin) everything works.

I never had these issue with Windows 7 is there something I am missing. 

 

Thank you in advance!

#RequireAdmin
run ("cmd")

WinWaitActive ("Administrator: C:\WINDOWS\SYSTEM32\CMD.exe")


ControlSend ("Test")
Send("{enter}")

 

Share this post


Link to post
Share on other sites

First off, I can't see this working at all, as ControlSend has more than a single required parameter.

Apart from that, whether in Windows 7 or Windows 10, the only way it isn't going to prompt when using #RequireAdmin is if UAC is disabled, or if you start AutoIt as an Administrator.


"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Share this post


Link to post
Share on other sites

@Tazx2x It is not two issues, in fact, threads merged. I answered above why you're likely having problems with the command (before I saw this was your second thread on the same subject).

More importantly, as Jos has tried to point out to you - why go through the headache of mixing languages in your script? You're trying to get an AutoIt script to open a CMD window for you, type text into it, and then run the MSI job. Why not save yourself the headache and simply install the MSI straight from AutoIt, and skip the cmd line middle man? AutoIt can do anything you can do in a cmd line window, and more.

This works for me (version 6.5), /qb so you can see the install:

#RequireAdmin

ShellExecute('msiexec.exe', '/i Code42_Client.msi CP_ARGS="DEPLOYMENT_URL=https://code42-auth.antas.com:4285&DEPLOYMENT_POLICY_TOKEN=9ef3e3a5-c58b-4300-9898-ebb99edc09a9" CP_SILENT=true /norestart /qb')

 

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Share this post


Link to post
Share on other sites

@JLogan3o13 I apologize if I broke any rules opening another post. I figured they were 2 separate issue. 

I fixed the MSI issue but im not following on why I can send commands to cmd after opening as admin. I lookied at the help file 

but it doesnt seem to clarify my issues. 

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...