cesinha87 Posted October 12, 2016 Share Posted October 12, 2016 (edited) Hello everyone, I am new to Autoit and I am trying to figure out how to run a command The command I run in the CMD manually is: C:\Program Files\McAfee\Agent\maconfig.exe -custom -prop1 "Test123" I am trying to converting that to Autoit and no success . I tried use the Run command and ShellExecute $CustomProps1 Run(@comspec & ' /c "C:\Program Files\McAfee\Agent\maconfig.exe" & "-custom" & "-prop1" & "Test123") or $CustomProps1 Run(@comspec & ' /c "C:\Program Files\McAfee\Agent\maconfig.exe -custom -prop1" & "Test123") or $CustomProps1 Run("maconfig.exe -custom -prop1 "$KeyValue"", "C:\Program Files\McAfee\Agent", @SW_HIDE) I kind gave up on the ShellExucte command Please any help Edited October 12, 2016 by cesinha87 Link to comment Share on other sites More sharing options...
cesinha87 Posted October 12, 2016 Author Share Posted October 12, 2016 Hello everyone, I am new to Autoit and I am trying to figure out how to run a command The command I run in the CMD manually is: C:\Program Files\McAfee\Agent\maconfig.exe -custom -prop1 "Test123" I am trying to converting that to Autoit and no success . I tried different ways and didn't work, I will paste everything that I have tried , Please let me know the right way $CustomProps1 Run(@comspec & ' /c "C:\Program Files\McAfee\Agent\maconfig.exe" & "-custom" & "-prop1" & "Test123") or $CustomProps1 Run(@comspec & ' /c "C:\Program Files\McAfee\Agent\maconfig.exe -custom -prop1" & "Test123") or $CustomProps1 Run(@comspec & ' /c "C:\Program Files\McAfee\Agent\maconfig.exe" -custom -prop1 ' & "Test123") or $CustomProps1 Run("maconfig.exe -custom -prop1 "$KeyValue"", "C:\Program Files\McAfee\Agent", @SW_HIDE) I kind gave up on the ShellExucte command Please any help Link to comment Share on other sites More sharing options...
cesinha87 Posted October 12, 2016 Author Share Posted October 12, 2016 Hello everyone, I am new to Autoit and I am trying to figure out how to run a command The command I run in the CMD manually is: C:\Program Files\McAfee\Agent\maconfig.exe -custom -prop1 "Test123" I am trying to converting that to Autoit and no success . I tried different ways and didn't work, I will paste everything that I have tried , Please let me know the right way $CustomProps1 Run(@comspec & ' /c "C:\Program Files\McAfee\Agent\maconfig.exe" & "-custom" & "-prop1" & "Test123") or $CustomProps1 Run(@comspec & ' /c "C:\Program Files\McAfee\Agent\maconfig.exe -custom -prop1" & "Test123") or $CustomProps1 Run(@comspec & ' /c "C:\Program Files\McAfee\Agent\maconfig.exe" -custom -prop1 ' & "Test123") or $CustomProps1 Run("maconfig.exe -custom -prop1 "$KeyValue"", "C:\Program Files\McAfee\Agent", @SW_HIDE) I kind gave up on the ShellExucte command Please any help Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted October 12, 2016 Moderators Share Posted October 12, 2016 (edited) Personally, I find ShellExecute easier to read (personal preference). I would do something like this: Local $customProps1 = @ProgramFilesDir & "\McAfee\Agent\maconfig.exe" ShellExecute($customProps1, '-custom -prop1 "Test123"') Or you could stick with a one-liner using Run: Run(@ProgramFilesDir & '\McAfee\Agent\maconfig.exe -custom -prop1 "Test123"') If, as you have it, you want to run in the command line, I would suggest changing your /c to /k so the window stays open. This is also helpful for troubleshooting syntax errors. Edit: I also merged your topics. Please stick to one in the future. Edited October 12, 2016 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! Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted October 12, 2016 Moderators Share Posted October 12, 2016 Just merged your third topic. Stop posting all over the forum! "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! Link to comment Share on other sites More sharing options...
cesinha87 Posted October 12, 2016 Author Share Posted October 12, 2016 Sorry JLogan I am new to the forum and I didn't know where to create the topic. I really apologized Link to comment Share on other sites More sharing options...
cesinha87 Posted October 12, 2016 Author Share Posted October 12, 2016 (edited) Alright I had to modified in order to work. When I ran your command it attempt to run maconfig under Program Files (x86) and error prompt. Here what I ran and worked Local $customProps1 = "C:\Program Files\McAfee\Agent\maconfig.exe" ShellExecute($customProps1, '-custom -prop1 & "Test123"') Here is what I am trying to accomplish. I running a Regread command before and storing on $keyvalue then I want to want the maconfig.exe in silent mode (no prompt) with the registry key value Local $keyvalue = RegRead("HKEY_LOCAL_MACHINE64\SOFTWARE\Microsoft\Deployment 4", "Role") ;MsgBox(0, "", "@error = " & @error) ;MsgBox($MB_SYSTEMMODAL, "Role", $keyvalue) Local $customProps1 = "C:\Program Files\McAfee\Agent\maconfig.exe" ShellExecute($customProps1, '-custom -prop1 & $keyvalue ') It didn't work How can I replace "test123" for the $keyvalue Edited October 12, 2016 by cesinha87 Link to comment Share on other sites More sharing options...
cesinha87 Posted October 12, 2016 Author Share Posted October 12, 2016 (edited) Ok...I believe I am almost there, I just can't pass the $keyvalue in the ShellExecute command. Please help Local $keyvalue = RegRead("HKEY_LOCAL_MACHINE64\SOFTWARE\Microsoft\Deployment 4", "Role") ;MsgBox(0, "", "@error = " & @error) ;MsgBox($MB_SYSTEMMODAL, "Role", $keyvalue) Local $customProps1 = "C:\Program Files\McAfee\Agent" ShellExecute($customProps1 & "\maconfig.exe", '-custom -prop1 $keyvalue', "", "", @SW_HIDE) ShellExecute ($customProps1 & "\cmdagent.exe", '-p', "", "", @SW_HIDE) Edited October 12, 2016 by cesinha87 Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted October 12, 2016 Moderators Share Posted October 12, 2016 You have to do it with the & symbol to add your variable, like so: ShellExecute($customProps1 & "\maconfig.exe", '-custom -prop1 ' & $keyvalue, "", "", @SW_HIDE) "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! Link to comment Share on other sites More sharing options...
cesinha87 Posted October 12, 2016 Author Share Posted October 12, 2016 I think I now why it's not working. They result of $keyvalue is a plain text and in order for the command to work the switches need to be - custom -prop1 "$keyvalue" Question. How can I have the result of $keyvalue and add between the quotes? Link to comment Share on other sites More sharing options...
jguinch Posted October 12, 2016 Share Posted October 12, 2016 ShellExecute($customProps1 & "\maconfig.exe", '-custom -prop1 "' & $keyvalue & '"', "", "", @SW_HIDE) Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
cesinha87 Posted October 13, 2016 Author Share Posted October 13, 2016 Your way is cleaner they way I did . Here is what I did and it worked Local $installroot = RegRead("HKEY_LOCAL_MACHINE64\SOFTWARE\Wow6432Node\McAfee\Agent", "InstallRoot") ;MsgBox($MB_SYSTEMMODAL, "Directory is", $installroot) Local $keyvalue = RegRead("HKEY_LOCAL_MACHINE64\SOFTWARE\Microsoft\Deployment 4", "THD Role") ;MsgBox(0, "", "@error = " & @error) ;MsgBox($MB_SYSTEMMODAL, "THD Role", $keyvalue) Local $customProps1 = $installroot ShellExecute($customProps1 & "maconfig.exe", '-custom -prop1 ' & '"' & $keyvalue & '"', "", "", @SW_HIDE) ShellExecute ($customProps1 & "cmdagent.exe", '-p', "", "", @SW_HIDE) Thank you all for the help, could not have done without your guys help Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now