Jump to content
Tazx2x

Send text with Variables into CMD!

Recommended Posts

Tazx2x

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
Earthshine

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

  • Like 1

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Tazx2x

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
Tazx2x

Maybe im not following I dont wanna "Run" I just wanna type this "String" into cmd.

Share this post


Link to post
Share on other sites
Earthshine

lol, jos gave you the answer. that is what you want to do actually.


My resources are limited. You must ask the right questions

 

Share this post


Link to post
Share on other sites
Jos
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

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Bilgus

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
Tazx2x

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
Tazx2x

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
JLogan3o13

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.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
JLogan3o13

@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

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
Tazx2x

@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

×