Jump to content
Sign in to follow this  
mango

ShellExecuteWait ignores switches

Recommended Posts

mango

I've searched the forum and Help and I can't find a solution to my problem. When I use ShellExecuteWait with switches, the switches are ignored. Previously the code used RunWait. The switches ran fine, but since I'm calling multiple install files and I need each one to finish before starting the next which is why I changed to ShellExecuteWait. Any idea why my switches are ignored?

ShellExecuteWait ( $7zip, ' /s' )

.

.

If GUICtrlRead(10) = 1 Then ;prog6

ShellExecuteWait ( $7zip, ' /s' )

EndIf

Share this post


Link to post
Share on other sites
dbzfanatic

Share this post


Link to post
Share on other sites
mango

Thanks, I've tried that and it didn't work. Have tried a lot of permutations, I saved some, but not all. Here are the ones I saved:

ShellExecuteWait('Z:\BSADKEY\!Admin\7z457.exe /S') ; 7zip test

ShellExecuteWait( $7zip ) ; 7zip test

ShellExecuteWait( $7zip & " /s" ) ; 7zip test

ShellExecuteWait( $7zip, " /s ", @SW_HIDE ) ; 7zip test

Share this post


Link to post
Share on other sites
dbzfanatic

Does this work?

$notepad = "Notepad.exe"
ShellExecute($notepad)
$7zip = "Z:\BSADKEY\!Admin\7z457.exe"
ShellExecuteWait($7zip,"/s")

You should see notepad and then 7zip. Also the @SW_HIDE is in the wrong place. That would be

ShellExecuteWait( $7zip, " /s ","","", @SW_HIDE )

Share this post


Link to post
Share on other sites
mango

The problem isn't that the exe doesn't run. My paths are correct. The problem is that the switch isn't implemented. I want to run sequential installations, I want to run them silently, and I want each install to end before beginning another. The switches work when I use RunWait, but AutoIt doesn't wait for the install to finish before starting the next. When I use RunExecuteWait, AutoIt will wait for the install to finish but it ignores switches, it's like the switch isn't even there.

Thanks for the advice on @SW_HIDE - think it's a redundant parameter anyway

Share this post


Link to post
Share on other sites
dbzfanatic
mango

Changing the switch has no effect. This same switch works correctly from the cli and by using RunWait in AutoIt.

If anyone else has a suggestion, I'm all ears.

Share this post


Link to post
Share on other sites
Varian

Is there a reason that your 'verb' is blank? Try using 'OPEN' as your verb. I had no problems running the following:

$7zip = 'Z:\Temp\7z457.exe'
ShellExecuteWait($7zip, '/S', '', 'open')

See if that helps you get to where you want to be. I f your verb changes with the installer type maybe you can use a variable for it, too.

EDIT:Never mind about the verb...this installer requires a capital "S" for the switch: /S, not /s..that is the problem.

Edited by Varian

Share this post


Link to post
Share on other sites
mango

EDIT:Never mind about the verb...this installer requires a capital "S" for the switch: /S, not /s..that is the problem.

Thanks for taking a look. I have tried the capital S as I posted above. It's not the problem. I am using the exact same path and the exact same switch(es) that execute correctly in AutoIt using Run or RunWait. However when using the exact same path + switch combo, ShellWaitExecute ignores the switch(es).

Share this post


Link to post
Share on other sites
Varian

So you're getting the interactive setup? Have you tried to hard code the path in the script for testing? What about ShellExecute instead?

Share this post


Link to post
Share on other sites
mango

So you're getting the interactive setup? Have you tried to hard code the path in the script for testing? What about ShellExecute instead?

Yes.

Yes.

ShellExecute won't be functionally different from Run - I want to run sequential install files and I need AutoIt to wait for each install to complete. AFAIK, ShellExecuteWait is the only way to do that.

Does anyone know how to run files sequentially and have AutoIt wait for the called file to finish executing before continuing? Does anyone know why ShellWaitExecute is ignoring my switches?

Share this post


Link to post
Share on other sites
Varian

Here's a thought:

Create a script, Silent7zip.au3, or something that has:

RunWait("7z457.exe /S" )

Compile it, and save it in the same folder as 7z457.exe

In your main script, set $7zip = Silent7zip.exe, So that ShellExecuteWait runs Silent7zip and waits until it finishes to proceed. As for why this is happening, try to download a beta or stable version of AutoIT to figure out the ShellExecute issue.

One more thang....is this the only executable where ShellExecute(Wait) switches do not work. If other EXEs work properly with ShellExecute(Wait) & switches, I suspect it's a syntax error on your part or an issue with the EXE corruption?

Edited by Varian

Share this post


Link to post
Share on other sites
herewasplato

This single line of code works as expected for me on an XP SP2 VM:

ShellExecuteWait('C:\Temp\7z457.exe', ' /S')oÝ÷ ØÚ+lz÷«j[bëØ­ëÞ­ö¢çOz¸Z¦Ë(ëax"³
è"¶¨º»2²×¦
¥w*.¦W±ëkÊØb±Êy©Ý±ç¢~Ø^¥ªæ±ªÞ¥«,yÛh{e¢·«jëh×6ShellExecuteWait('C:\WINDOWS\explorer.exe', ' /e,c:\')

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites
Skruge

ShellExecute won't be functionally different from Run - I want to run sequential install files and I need AutoIt to wait for each install to complete. AFAIK, ShellExecuteWait is the only way to do that.

Does anyone know how to run files sequentially and have AutoIt wait for the called file to finish executing before continuing? Does anyone know why ShellWaitExecute is ignoring my switches?

Since you're dealing with EXE's and not documents, there's not much difference between ShellExecuteWait and RunWait.

You said that the parameters do work with RunWait, so why not try to find out why it doesn't meet your needs?

One thing to look for is if your 7zip exe spawns child processes and exits before they complete. If this is the case, use ProcessWaitClose to wait for them to close before running the next EXE.


[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Share this post


Link to post
Share on other sites
Morteza

(...) The problem is that the switch isn't implemented. I want to run sequential installations, I want to run them silently

Use -ms instead of -s or /S in 7Zip files

(...) I want each install to end before beginning another.

If you are compressed a Setup.exe file in your 7Zip exe compressed file, this behaviour is natural. Because:

a. Your executable compressed 7Zip file is opened.

b. The file is uncompressed and your uncompressed Setup.exe is executed.

c. Your executable compressed 7Zip file is closeed, however your Setup.exe is running at yet.

ShellExecuteWait() is not checking you Setup.exe, this function is checking your 7Zip.exe file and your 7Zip.exe file is closed at this time.

Edited by Morteza

Share this post


Link to post
Share on other sites
mango

Thanks everybody, I just successfully ran the installs sequentially. : )

This was especially helpful:

Since you're dealing with EXE's and not documents, there's not much difference between ShellExecuteWait and RunWait.

You said that the parameters do work with RunWait, so why not try to find out why it doesn't meet your needs?

One thing to look for is if your 7zip exe spawns child processes and exits before they complete. If this is the case, use ProcessWaitClose to wait for them to close before running the next EXE.

Here's what finally worked:

Run( $7zip & " /S" )

ProcessWaitClose ( $7zip )

I think it would probably work as Run, I'll probably test that after I get my switches worked out (now that they run I noticed a few are incorrect).

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.