Jump to content
Sign in to follow this  
johnmcloud

[SOLVED] Run and unbalanced brackets

Recommended Posts

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

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


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-30 - Version 1.6.2.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - 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
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
Share on other sites

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 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-30 - Version 1.6.2.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - 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
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
Share on other sites

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

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 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-30 - Version 1.6.2.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - 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
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
Share on other sites

@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

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

@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 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-30 - Version 1.6.2.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - 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
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
Share on other sites

@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

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


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-30 - Version 1.6.2.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - 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
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
Share on other sites

@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

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 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-30 - Version 1.6.2.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - 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
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
Share on other sites

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

Glad you got it working :D


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-30 - Version 1.6.2.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - 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
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - 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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By WoodGrain
      Hi All,
      Trying to open windows explorer to a WebDav location and it's not working quite how I want, on the computers it is setup as a "network location" (as opposed to a "mapped drive", and this unfortunately can't be changed), the "Data" WebDav folder sits directly under "This PC" if that's an easier way to get to it. any suggestions as to what I can correct to get the 2nd example to work?
      ; This works, but I'm trying to avoid this as users normally see the URL style in the 2nd example below $folderToOpen = "\\mycompany.sharepoint.com@SSL\DavWWWRoot\Data" Run("Explorer.exe " & $folderToOpen) ; This does not work, it tries to open the WebDav url in the default web browser $folderToOpen = "https://mycompany.sharepoint.com/Data" Run("Explorer.exe " & $folderToOpen) ShellExecute also opens it in the default browser.
      Saw _WinAPI_ShellOpenFolderAndSelectItems but couldn't get the 2nd example to work.
      If I manually open Windows Explorer and paste in https://mycompany.sharepoint.com/Data it loads the WebDav directory without issue.
      If I have to use the pathing from the first example it is fine, just trying to give users a familiar experience.
      Thanks!
    • By nacerbaaziz
      hello autoit team
      is there any wey to check if any process run as admin or no?
      i mean e.g if i want to restart any process, now i have the ability to get the process path and commands line
      what i need is a wey to check if the process was runing as admin or no to restart it with the same state.
      here is the part that am using it to restart the process
      func _processRestart($i_pid, $s_ProcessPath) if not (ProcessExists($i_ProcessPid)) then return SetError(1, 0, -1) local $s_ProcessWorkDir = _WinAPI_GetProcessWorkingDirectory($i_ProcessPid) ProcessClose($i_ProcessPid) ProcessWaitClose($i_ProcessPid) ProcessWait(ShellExecute($i_pid,"", $s_ProcessWorkDir)) ProcessesGetList() return true endFunc thanks in advance
    • 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
    • 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
    • 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
       
×
×
  • Create New...