Jump to content

ShellExecute help/example please


smashly
 Share

Recommended Posts

Hi and thank you for taking the time to view my post.

I'm wondering how I use ShellExecute using the Verb "properties" on a file or folder.

I have been trying for hours now with all sorts of variations to how to call it , but it just doesn't seem to work for me.

Some examples of what I've tried below with a file ( tried files from any directory not just notepad):

ShellExecute("c:\windows\system32\notepad.exe, "", "", "properties", @SW_SHOW)

ShellExecute("c:\windows\system32\notepad.exe, "", "", "properties", "")

ShellExecute("c:\windows\system32\notepad.exe, "", "", "properties")

ShellExecute("notepad.exe, "", "c:\windows\system32\", "properties", @SW_SHOW)

ShellExecute("notepad.exe, "", "c:\windows\system32", "properties", @SW_SHOW)

ShellExecute("notepad.exe, "", "c:\windows\system32\", "properties", "")

ShellExecute("notepad.exe, "", "c:\windows\system32", "properties")

I've tried with folders or files with and without show , minimize , maximize, with and without trailing slash (for folder properties) to call the verb properties and I get the same result every time:

There is no associated program , use control panel to associate a program with this file type.

I feel like an idiot to ask but could some please give me an example.

I'm using Windows XP SP2 , AutoIt beta 3.2.1.14

I just devoted 13 hours (as I'm not always net connected to find the answers) trying to work out why "parameters" and "working directory" fail in ShellExecute only to find it was a bug in the beta autoit (I was using 3.2.1.11). Updated and I really don't feel like going through the same process with the verb "properties" unless need be, so this is why I'm asking for an example.

TYIA

Cheers

Link to comment
Share on other sites

Hi and thank you for taking the time to view my post.

I'm wondering how I use ShellExecute using the Verb "properties" on a file or folder.

I have been trying for hours now with all sorts of variations to how to call it , but it just doesn't seem to work for me.

Some examples of what I've tried below with a file ( tried files from any directory not just notepad):

ShellExecute("c:\windows\system32\notepad.exe, "", "", "properties", @SW_SHOW)

ShellExecute("c:\windows\system32\notepad.exe, "", "", "properties", "")

ShellExecute("c:\windows\system32\notepad.exe, "", "", "properties")

ShellExecute("notepad.exe, "", "c:\windows\system32\", "properties", @SW_SHOW)

ShellExecute("notepad.exe, "", "c:\windows\system32", "properties", @SW_SHOW)

ShellExecute("notepad.exe, "", "c:\windows\system32\", "properties", "")

ShellExecute("notepad.exe, "", "c:\windows\system32", "properties")

I've tried with folders or files with and without show , minimize , maximize, with and without trailing slash (for folder properties) to call the verb properties and I get the same result every time:

There is no associated program , use control panel to associate a program with this file type.

I feel like an idiot to ask but could some please give me an example.

I'm using Windows XP SP2 , AutoIt beta 3.2.1.14

I just devoted 13 hours (as I'm not always net connected to find the answers) trying to work out why "parameters" and "working directory" fail in ShellExecute only to find it was a bug in the beta autoit (I was using 3.2.1.11). Updated and I really don't feel like going through the same process with the verb "properties" unless need be, so this is why I'm asking for an example.

TYIA

Cheers

It looks like all you are doing is opening a new Notepad window so in reality all you need is Run("Notepad.exe")

If you want to open a file that is associated with Notepad then just use

ShellExecute("My_File.txt")

If its a file type with several verb options and the default verb is something that won't cause notepad to open (au3 files ususlly are set to run and not edit)

ShellExecute("my_File.au3","","","Run") Will cause the file to run.

Edit:

BTW

Since I don't use ShellExecute to Run an Exe like you were trying, I'm not positive but I think

ShellExecute("NotePad.exe","My_File.au3") will probably open an au3 file in Notepad. Because the File to execute is notepad and the parameter is my_file.au3

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Looks like there is a "bug" or maybe inconsistens between the documentation and the implementation.

As a woorkaround I think you can use rundll32.exe call. I'll take a look in my notes later on.

Link to comment
Share on other sites

It appears ShellExecute still has bugs , or it's just not fully documented in AutoIt help file.

Another undocumented part of ShellExecute is no mention of @SW_SHOW is required if you leave any fields blank.

eg:

ShellExecute("C:\temp\test.txt, "", "","edit","")

Would result in your file being launched hidden.

This is with any path, any filetype , with or without a verb ...etc.

In other words if there is "" and you want your window to show then you need the @SW_SHOW flag.

@ GEOSoft thank you , but please reread what I posted as I'm a n00b not a total dummy..lol..

no offence meant. (When I'm not online AutoIt Help file is my bible you could say)

@ xcal you are exactly right and cheers m8

Think I'll just leave that "properties" verb out of my hotkey utility I'm making ftm :P

Thank You both for your input it's appreciated.

Cheers

EDIT Thank to all , geez I'm a slow typer , by the time I typed this there was another 2 responses.

Edited by smashly
Link to comment
Share on other sites

Another undocumented part of ShellExecute is no mention of @SW_SHOW is required if you leave any fields blank.

eg:

ShellExecute("C:\temp\test.txt, "", "","edit","")

Would result in your file being launched hidden.

This is with any path, any filetype , with or without a verb ...etc.

In other words if there is "" and you want your window to show then you need the @SW_SHOW flag.

This is not true. You didn't leave the "showflag" field empty, you passed "" to it. A non-numeric string will be converted to 0 if it's treated as a number and since the "showflag" field expects a number, it gets turned to 0. It just so happens that the value of @SW_HIDE is 0. So the only reason for the behavior is you told it to do it.
Link to comment
Share on other sites

hmm, I could just swear I have done this once, but I'm not able to find it again. :P

Probably did it from the run dialog (if ever) and then went on.

Anyhow, this is a reasonably good read anyone wants to launch control applets and config dialogs. RunDll32.exe shell32.dll,....

Link to comment
Share on other sites

Thank You Valik , I stand corrected , now I understand why I was needing @SW_SHOW.

Sheesh maby I am a dummy after all , I can't believe I didn't see that considering I've been using "6" for my Minimise flag and "3" for my maximise flag :">

Cheers

Link to comment
Share on other sites

Thank You Valik , I stand corrected , now I understand why I was needing @SW_SHOW.

Sheesh maby I am a dummy after all , I can't believe I didn't see that considering I've been using "6" for my Minimise flag and "3" for my maximise flag :">

Cheers

Actually (according to the docs) @SW_SHOW is not even a valid flag for ShellExecute()

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

GEOSoft... go read about ShellExecute in the help file. He's not simply trying to open a file in notepad. :P (edit) And 'run' doesn't even look like a valid verb.

If you noticed I was using Run as the verb for an au3 file. Take a look in your registry and you will find that the verb for "Run Script" is "Run". That one I use quite a bit although not with notepad'

ShellExecute("My_File.au3","","","Run") is valid

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

The run file seems to be shown by default, too. ShellExecute("C:\temp\test.txt", "", "","edit") works just fine for me. (The showflag is optional.)

I'm not sure whats up with the Show flag. It's not shown in the ShellExecute docs and I suspect that it either gets ignored or it's interpreted as @SW_NORMAL.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

You don't actually want to do this with ShellExecute. Try this instead:

$objShell = ObjCreate("Shell.Application")
$objFolder = $objShell.Namespace("C:\WINDOWS\system32")
$objFolderItem = $objFolder.ParseName("notepad.exe")

$colVerbs = $objFolderItem.Verbs
For $objVerb in $colVerbs
    ConsoleWrite($objVerb.NAME & @CRLF)
Next

$objFolderItem.InvokeVerb("P&roperties")
WinWait("notepad.exe Properties")
WinWaitClose("notepad.exe Properties")

Edited by lod3n

[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Link to comment
Share on other sites

  • 6 months later...

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...