Jump to content

Recommended Posts

hi guys,

What is the difference between run and shellexecute ?

I have a program which call another exe file.
And it works since many years with run command.

$path = "d:\barre.exe"
$path &= " Lanceur" ; A parameter for the exe.
Run($path, @TempDir, @SW_MAXIMIZE) ;
If @error Then
            consolewrite("erreur de lancement de " & $path & " erreur:" & @error & " @TempDir: " & @TempDir & @CRLF)
            shellExecute("d:\barre.exe" , "Lanceur")
                If @error Then
                    consolewrite("erreur de lanceemnt de ShellExecute" & $path & " erreur:" & @error & @CRLF)

Today, for only one user, (on near 150 / 200) the program called doesn't start at all.

The run command is on error, so i tried with shellexecute and it works well.

My main program is launch by many users, it select and find the binary for the second program, copy it on the user computer, and run it locally (d:\barre.exe).

It works well since a very long time. Barre.exe is a toolbar, so with a gui.

I really don't explain this problem.

the folder where is the program is accessible for the user, with full rights, and @tempdir is ok too.

Any ideas ?



Link to post
Share on other sites

yes, I see, but it still fails on ONE computer, right? on THAT computer, the TEMP may not be what you expecting. in your call to ShellExecute you don't specify a WORKING DIR

trying to get a reason for the failure and testing like your code to verify results.

Edited by Earthshine

My resources are limited. You must ask the right questions


Link to post
Share on other sites

ok. i just made my TEMP and TMP variable junk and get the same results you do running just notepad in the code. When the workingingdir is left blank, it works. that's all I've got right now. Is his TEMP dir full?!? hmmmm, maybe he needs a Chkdsk /f

running without tempdir works in all my tests so far. his disk might me messed up dude.

Edited by Earthshine

My resources are limited. You must ask the right questions


Link to post
Share on other sites
  • 3 weeks later...

So the answer to my problem after severals tests:

My exe file is stored locally in Global $DossierBarreSTC = EnvGet("USERPROFILE") & "\Mes Documents\programme\"

I had not precised this in my firsts post but finally it's the root cause.


On this computer, it's ok with  EnvGet("USERPROFILE") & "\Documents\programme\" but not using 'Mes Documents'.

In windows explorer, cmd etc 'Mes document's is well known. And even if i test fileexist in the code before the 'run', the file exists with both paths.


About 300 users, only one in this case.

Code ok

$DossierBarreSTC = EnvGet("USERPROFILE") & "\Documents\programme\"
            $path = $DossierBarreSTC & "binaires\barre stc.exe" 
            $path &= " Lanceur" ; parameter
            $pid = Run($path, @TempDir, @SW_MAXIMIZE)

Code Not ok:

$DossierBarreSTC = EnvGet("USERPROFILE") & "\Mes Documents\programme\"
            $path = $DossierBarreSTC & "binaires\barre stc.exe" 
            $path &= " Lanceur" ; parameter
            $pid = Run($path, @TempDir, @SW_MAXIMIZE)

So, the problem is solved. i have not totally understood why for this user but i bypassed it.

Thanks all.

Link to post
Share on other sites

You could just use the macro @MyDocumentsDir to get the location of the current user's my documents folder location regardless of what it's named or where it's located.

For example on my work laptop I have moved the location of the Documents folder to my OneDrive folder so it gets backed up automatically, and you won't find it under my user profile in the usual place.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...