Jump to content
Sign in to follow this  
johnmcloud

[SOLVED] Run and unbalanced brackets

Recommended Posts

johnmcloud

Hi, it's me again...

I'm going crazy, i'm lost 2hr...i have used Run 10000 time but this time i have problem with the brackets

Script, with this paramenter work

$exe = "C:\test_x86.exe"
$install = "install"
$exe2 = @WorkingDir & "\test2_x86.exe"
$root = "root\test"
RunWait(@ComSpec & " /k " & $exe & " " & $install & " " & '"' & $exe2 & '"' & " " & $root, @WorkingDir)

But i need to use macro for the $exe

$exe = "C:\test_x86.exe" ; Need to use @WorkingDir

So i have make this:

$exe = @WorkingDir & "\test_x86.exe"
$install = "install"
$exe2 = @WorkingDir & "\test2_x86.exe"
$root = "root\test"
RunWait(@ComSpec & " /k " & '"' & $exe & '"' & " " & $install & " " & '"' & $exe2 & '"' & " " & $root, @WorkingDir)

But not work, give me error C:\Documents is a wrong path etc...classic error by path with space without brackets

Do you know what is the funniest part? If i make:

ConsoleWrite('"' & $exe & '"' & " " & $install & " " & '"' & $exe2 & '"' & " " & $root)

And i copy/paste the result in a CMD window work...

What is my error?

Thanks

Edited by johnmcloud

Share this post


Link to post
Share on other sites
water

What is variable $devcon_x86 used for? I can't find it in your script.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - 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
johnmcloud

I have edited the $variable, copy-paste error, sorry ;)

Share this post


Link to post
Share on other sites
water

When you replace RunWait with ConsoleWrite and remove the @WorkingDir parameter you get:

Consolewrite(@ComSpec & " /k " & '"' & $exe & '"' & " " & $install & " " & '"' & $exe2 & '"' & " " & $root)
.

This writes the complete string to the console. I get:

C:Windowssystem32cmd.exe /k "C:Temptest_x86.exe" install "C:Temptest2_x86.exe" roottest
which doesn't look bad.

What do you get?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - 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
johnmcloud

This is what i get:

C:\Windows\System32\cmd.exe /k "C:Documents and SettingsMYNAMEDesktopTestTest_x86.exe" install "C:Documents and SettingsMYNAMEDesktopTestTest2_x86.exe" roottest

As i have told you, if i copy-paste in cmd work, but with autoit the cmd output give me:

"C:Documents" is not recognized as an internal or external command, operable program or batch file.

Share this post


Link to post
Share on other sites
water

Try it the other way round:

RunWait(@ComSpec & " /k " & "'" & $exe & "'" & " " & $install & " " & "'" & $exe2 & "'" & " " & $root, @WorkingDir)
Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - 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
johnmcloud

@Jos, the result is:

""C:Documents and SettingsMYNAMEDesktopTestTest_x86.exe"" is not recognized as an internal or external command, operable program or batch file.

Cool, now i have four brackets :D

@Water instead:

The syntax of the file name, directory or volume is incorrect.
Edited by johnmcloud

Share this post


Link to post
Share on other sites
Jos

Cool, now i have four brackets :D

You mean Double Quotes ;)

I have see this before and know that enclosing the whole commandline with an extra set of double quotes did resolve it sometimes.

You are running this under the same credentials right?


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     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
johnmcloud

Yeah, sure, same credentials

I'm on XP right now so i can't run CMD like admin

Share this post


Link to post
Share on other sites
water

@Water instead:

The syntax of the file name, directory or volume is incorrect.

Could we just start the exe so we can see if the message comes from the OS or the application:

RunWait(@ComSpec & " /k " & "'" & $exe & "'", @WorkingDir)
Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - 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
johnmcloud

@Water

Same error, so:

The syntax of the file name, directory or volume is incorrect.

If i make this work:

$exe = "C:Test_x86.exe"
RunWait(@ComSpec & " /k " & $exe, @WorkingDir)

With the quotes no...

EDIT: Like this work:

RunWait(@ComSpec & " /k " & '"' & $exe & '"', @WorkingDir)

But if i add the second parameter ( the parameter has space inside ) i have the error C:Documents

Edited by johnmcloud

Share this post


Link to post
Share on other sites
water

Runwait(@ComSpec & " /k " & '"' & $exe & '"')
works here with Windows 7 64 bit.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - 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
johnmcloud

@Water

It's not OS problem,if i make another tipe of command like:

@ComSpec & " /c " & '"' & $exe & '" ' & $uninstall & " " & $root

Work fine, or if i make the first or second parameter without " " and space work:

$exe = @WorkingDir & "test_x86.exe"
$install = "install"
$exe2 = "C:test2_x86.exe"
$root = "roottest"
RunWait(@ComSpec & " /k " & '"' & $exe & '" ' & $install & " " & $exe2 & " " & $root, @WorkingDir)

So if i have two path with space and " " inside the same Run not work

Edited by johnmcloud

Share this post


Link to post
Share on other sites
water

Another question:

You start $exe to install or uninstall $exe2?

You would then have at least 2 levels of programs started by RunWait: Cmd.exe -> $exe

No wonder that it gets complex.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - 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
johnmcloud

YEAH!

I have make totally random quotes until Autoit accept it lol

$exe = '""' & @WorkingDir & "\Test_x86.exe" & '"'
$install = "install"
$exe2 = '"' & @WorkingDir & "\Test2_x86.exe\" & '""'
$root = "root\test"
RunWait(@ComSpec & " /k " & " " & $exe & " " & $install & " " & $exe2 & " " & $root, @WorkingDir)

Thanks for the support Water and Jos

Share this post


Link to post
Share on other sites
water

Glad you got it working :D


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - 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  

  • Similar Content

    • AnonymousX
      By AnonymousX
      So I just got a new computer, and instantly went and installed Autoit onto it. I selected run script as default action when clicking on an au3 file, however every time I do this it opens the script in the editor. I can from there run the script no problem.
      I've tried reinstalling and checking the settings by hitting "Ctrl+1" and have confirmed it is set to run, but yet it just continues to open in the editor.
      Any ideas why this is happening or how to solve?
      New system is windows 10, old was windows 7
    • HariKara
      By HariKara
      Hi AutoIters!
       
      Im trying to launch a .exe file that is nested within the program files (x86) folder structure. i have already used the standard RunAs Syntax and found that it fails to launch the application. I have switched to Run and that seems to work. My issue is I have to use RunAs as the applicaton would need to run under a completely different account. The Current logged in user is a Local User on the machine, however, the application must be run as a domain user. The Machine is domain connected.
       
       have tried the following:
      RunAs("username","logonpassword", $RUN_LOGON_PROFILE, "D:\Program Files (x86)\Vendor\Application Name\Exe Location\Executable.exe") The above fails to launch, there are no errors or syntax issues, it just does nothing when the variables are replaced for the correct values.
      I did the same using the Run command
      Run("D:\Program Files (x86)\Vendor\Application Name\Exe Location\Executable.exe") That seems to work fine, but runs in local user context. Any thoughts? Could it be a local Machine rights issue? Or have i missed something glaring in my script
    • nacerbaaziz
      By nacerbaaziz
      Hello
      i have searched a lot about how to run external programs with the administrator privileges without the script running with administrator privileges using autoit
      But all my attempts failed
      Finally, today I found the VBS function doing this task
      I immediately transferred it to our beloved language (autoit) and i decided to share it with you
      i hope you like it
      This is a simple example about how to use the function

      runAsAdmin("cmd.exe", "/c @echo off & cls & echo test & pause", "c:\", @sw_show)
      this is the function

      func runAsAdmin($program, $parameters = "", $workingDir = @workingDir, $show = "") local $oShell = OBJCreate("Shell.Application") if isOBJ($oShell) then local $result = $oShell.ShellExecute($program, $parameters, $workingDir, "runas", $show) else $result = false endIf return $result endFunc
       
    • PoojaKrishna
      By PoojaKrishna
      Hi friends,
      The Run command on my machine suddenly stopped execution.
      Anyone of you facing the same issue?
      #include <AutoItConstants.au3> #include <FileConstants.au3.> #RequireAdmin $ExeName = FileOpenDialog("Select AutoIt executable", @ScriptDir & "\", "(*.exe)", $FD_FILEMUSTEXIST) If not @error Then If FileExists($ExeName) Then $iPID = Run($ExeName, "", @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD) If @error Then msgbox(0,"Failed", "Failed execution with @error: " & @error) EndIf Else Msgbox(0,"", "File does not exist") EndIf EndIf The above code always fails to execute the executable file. It was working perfect and stopped working now.
      I have tried adding the files and folders to windows defender exclusion list and uninstalling the anti virus but still no luck.
      OS: Windows 10 - 64 bit
      Please help.
       
    • rudi
      By rudi
      Hello,
      for a script to display PDF files I'd like to simply use the default program for PDF files, so I used "ShellExecute(<pdf-file-full-path>)" to open these files.
       
      The result for *SOME* of the workstations is, that the Adobe Reader starts up with asking for its language. (English/German). When starting AcroRd32.exe through "ShellExecute()", this "choose your language" dialog is showing up *ALWAYS*.
       
      Just to have mentioned it: Process Explorer is presenting this command line, it looks the same for both, PCs with and without that question "Choose Language? [English|German]"
      "C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe" --channel=4680.0.860715181 --type=renderer "\\pc0009\Y_DRV_H\Daten\TIF\08\32\G000110832_Freigegeben.idw.pdf"  
      The next approach I thought of was to use Foxit Portable (instead of Acrord32.exe), started from a Network Drive, but it's starting up ugly slowly...
      So I tried to "Run()" instead to "ShellExecute()" the Adobe Reader. Now the result looks more stange, the "select your language" dialog shows up every now and then, but not always for the Win7 installations affected.
       
      If I place a "msgbox()" just in front of the "run()" command, it seems never to show this "select your language" dialog.
      If I take out this MsgBox() the "select your language" dialog shows up sometimes.
      When I "ClipPut()" the run command prior the "Run()" and paste that one to a CMD box, then it seems to *NEVER* happen, that this "select your language" dialog shows up.
       
      "C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe" "\\pc0009\Y_DRV_H\Daten\TIF\08\32\G000110832_Freigegeben.idw.pdf" $AcroRead='"C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe"' $PDF='"Y:\Temp\DRV_H\Daten\TIF\33\85\153385_Freigegeben.dwg.pdf"' MsgBox(0,"Values",$AcroRead & @CRLF & $PDF,1) $MyCommand=$AcroRead & " " & $PDF ClipPut($MyCommand) Run($MyCommand)  
      It looks like, that this "--channel=... --type=renderer" parameters are always fact for the AcroRd32.exe instance, that is opening the PDF to be displayed. The Instance opening the "PDF Display GUI" seems to always be a child process of another AcroRd32.exe process.
       
      Any clue, what's going on "backstage" here? How to avoid this "Choose your language" dialog? Or maybe someone can mention a different "portable" PDF viewer, I could use for this purpose?  
      Any suggestions appreciated, regards, Rudi.
×