weirddave

ShellExecute parameters not working on some PCs

9 posts in this topic

#1 ·  Posted (edited)

I am trying to pass some parameters to another script using ShellExecute, thisworks fine on Win10 but not on Win7.

I have cut the code down to the bare minimum to illustrate the problem. This is the code with ShellExecute

$test_Params = "a b"
ShellExecute("shellexecute_test.au3", $test_Params)

This is the code that is being called (shellexecute_test.au3):

msgbox(0,"",$CmdLine[0])

The win7 PC reports 0, Win10 reports 2

Could there be a permissions issue?
Is there another way to make this work?

Edited by weirddave

Share this post


Link to post
Share on other sites



#2 ·  Posted

Can you confirm that if you double click "shellexecute_test.au3" on Windows 7 that it executes, opens in Scite or does nothing?  It sounds like file associations aren't added.

Share this post


Link to post
Share on other sites

#3 ·  Posted

It runs, I get a message box with 0 in it (which would be correct when launching it this way). If it wasn't launching correctly I wouldn't get the msgbox at all with the shellexecute method :) 

I'm actually double-clicking the au3 with the shellExecute in it as it happens.
If I compile shellexecute_test it works, but this isn't convenient for debugging :( 

Share this post


Link to post
Share on other sites

#4 ·  Posted

Sorry was a little confused by your first post, I've tested on Windows 7 and Windows 10 and I get MsgBox with 2 on both systems, I do have UAC switched off on Windows 7.

Windows Enterprise 7/10 64 bit with AutoIT 3.3.14.2

Share this post


Link to post
Share on other sites

#5 ·  Posted

Thanks for trying it. The Win7 PC is somewhat locked down, which is why my first suspect is a permissions issue.

I could do with a workaround, debugging without line numbers in the error is a pain, lol

 

Share this post


Link to post
Share on other sites

#6 ·  Posted

Try running the *.exe script "as administrator" .  If that solves the problem, it could be the particular AnitVirus program installed on the PC that is interfering with program operation or it could be the security settings of Windows itself.

-pete

 

 

Share this post


Link to post
Share on other sites

#7 ·  Posted

@weirddave hi

did you checked the ps restriction ?

do you execute the powershell command in the rigth directory ? 

Is powershell installed on w7 computer also ? 

If no you have to import powershell module 

Share this post


Link to post
Share on other sites

#8 ·  Posted

@weirddave - Can you check the value of RegRead('HKEY_CLASSES_ROOT\AutoIt3Script\Shell\Run\Command', '')

Just wondering if its missing parameters on the command line e.g.
"C:\Program Files (x86)\AutoIt3\AutoIt3.exe" "%1" %*

 

1 person likes this

Share this post


Link to post
Share on other sites

#9 ·  Posted

Regedit told me that the key was set to  "C:\engsys\AutoIt\AutoIt3.exe" "%1"

I have changed it to "C:\engsys\AutoIt\AutoIt3.exe" "%1" %*

which seems to have fixed it. 

Interestingly, my key name was HKEY_CLASSES_ROOT\Applications\AutoIt3.exe\shell\open\command

I suspect what I've done is associate au3 files with the exe rather than install autoit on this particular PC. It's coming back to me now, the admin doesn't want to see "random" installs that aren't on the approved list and C:\engsys is ignored by the virus protection here ;) 

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