PDA

View Full Version : Urgent problem using RUN in Vista



NewsArchive
03-31-2008, 02:18 AM
Friedrich - I need to get something out the door in a few hours and just
found this.



In my app I have a button under which I have:



Run('EVKey.exe /V SUBSCRIPTION ' & clip(LOC:SubscriptionKey),1)



EVKey.exe is a SB executable compiled as require administrator which just
checks the subscription key and writes to an ini file. The Runcode() value
returned is -4 which means the program did not run.



This works under XP. Why does this not work under Vista and what do I need
to do to make sure it does.





Many thanks



John Fligg

NewsArchive
03-31-2008, 02:18 AM
Hi John,

The answer is simple. The Clarion "RUN" command makes use of the
CreateProcess() Windows API. But CreateProcess() will always fail under
Vista and Windows Serve 2008 if a non-elevated application attempts to
launch another application whose manifest requires elevation.

Use ShellExecuteEx instead.

Does this help?

Friedrich

NewsArchive
03-31-2008, 02:19 AM
Or the ShellExecute Windows API :)

Friedrich

NewsArchive
03-31-2008, 02:19 AM
Thanks Friedrich

Since posting I found that every so often Vista would tell me that my app
did not run properly. After that it allowed RUN to work.

But I will change it.

Weird.

john

NewsArchive
03-31-2008, 02:20 AM
Am I stupid? How do you do that? What is the syntax?

John

NewsArchive
03-31-2008, 02:21 AM
Hi John,

>Run('EVKey.exe /V SUBSCRIPTION ' & clip(LOC:SubscriptionKey),1)

Won't work under Vista. I have a rock solid replacement for it in my
next release of our Utilities. Charles and I have been beating on it
for weeks now both under XP and Vista and it just works.

ITRun('EVKey.exe',True,'/V SUBSCRIPTION ' & clip(LOC:SubscriptionKey))

First parameter is the program to run, second is the waiflag and the
third is the command line parameters. There is a fourth parameter to
determine the startupfolder if needed. All except the first parameter
are omittable and it defaults to not waiting for the program to
complete. RunCode() works without problem to detect the errorlevel
from the process after it terminates, just like with RUN(), on both XP
and Vista.

Best regards,

Arnór Baldvinsson
Icetips Creative, Inc.
San Antonio, Texas, USA
www.icetips.com


Subscribe to information from Icetips.com:
http://www.icetips.com/subscribe.php

NewsArchive
03-31-2008, 02:21 AM
Great.

Here is another poser then ......

What about the standrad actions under a button. You can select Run a
program. What does that do and is it safe to use in Vista????

John

NewsArchive
03-31-2008, 02:22 AM
John,

As Friedrich said : never use a RUN on Vista
use the ShellExecute as mentioned and you will be safe

--
Thank you

Cordialement - Best regards
Jean-Pierre GUTSATZ

CGF

Data Management Center - A tool to let you Migrate Import Export Transfer
all your Data very easily
www.dmc-fr.com
Certified by Microsoft : "Works with Vista" & "Works with Windows Server
2008"

NewsArchive
03-31-2008, 02:23 AM
Erm what is ITRun? The compile does not like it.

John

NewsArchive
03-31-2008, 02:24 AM
> Erm what is ITRun? The compile does not like it.

John,

>> I have a rock solid replacement for it in my next release of our Utilities.
>> Charles and I have been beating on it for weeks now both under XP and Vista
>> and it just works.

It's part of the NEXT release of Icetips Utilities - NOT available yet -
you must own the Icetips GOLD subscription.

(http://www.icetips.com/subscribe.php)

David


--
From David Troxell - Product Scope 7 - Encourager Software
Clarion Third Party Profile Exchange Online
http://encouragersoftware.com/profile/clarlinks.html
http://www.encouragersoftware.com/
http://www.profileexchanges.com/blog/

NewsArchive
03-31-2008, 02:29 AM
Damn - I am stuffed then!!!!!!!!

Surely there must be some way to get something to run in Vista.

If I use a button and set the action to Run .... that works. However in this
scenario I have to run some code after the Run has completed having checked
the return code, and Run ... does not allow to wait for completion so far as
I know.

John

NewsArchive
03-31-2008, 02:31 AM
As long as Arnór's stuff is not available, use the ShellExecute Windows API
in combination with WaitForSingleObject (to wait) in your Clarion
application. And GetExitCodeProcess() gives you the return code.

Friedrich

NewsArchive
03-31-2008, 02:31 AM
Should read "ShellExecuteEx"

Friedrich

NewsArchive
03-31-2008, 02:32 AM
Sorry Friedrich - I have absolutely no idea how to use the Windows API
commands.

My pathetic attempt was to use:

ShellExecuteEx('FMKey.exe /V SUBSCRIPTION ' & clip(LOC:SubscriptionKey))

but clearly that is not right. DO I have to include something in the
Includes?

John

NewsArchive
03-31-2008, 02:32 AM
I think I found a solution.

Thinking that WinEVent might have something in but did not I realised I had
ValUtilities.

It seems to work fine on Vista. Just need to sort out trapping the return
codes now.

Thanks to all.

John

NewsArchive
03-31-2008, 02:33 AM
> Sorry Friedrich - I have absolutely no idea how to use the Windows API
> commands.
>
> My pathetic attempt was to use:
>
> ShellExecuteEx('FMKey.exe /V SUBSCRIPTION ' & clip(LOC:SubscriptionKey))
>
> but clearly that is not right. DO I have to include something in the
> Includes?
>
> John

Perhaps starting with Berthume's PowerRun (google it, or look at
clarionconnection.com) would help. It constructs much of this and would be
a decent learning tool to help.
--

Mark Riffey
http://www.rescuemarketing.com/blog/
The Wall Street Journal staff reads it,
maybe you should too.

NewsArchive
03-31-2008, 02:35 AM
Hi John,

>Erm what is ITRun? The compile does not like it.

Read my message<g> It's in my Utilities
(http://www.icetips.com/utilities.php) The vista approved one is not
released yet but will be as soon as I get a moment:)

Best regards,

Arnór Baldvinsson
Icetips Creative, Inc.
San Antonio, Texas, USA
www.icetips.com


Subscribe to information from Icetips.com:
http://www.icetips.com/subscribe.php

NewsArchive
03-31-2008, 02:36 AM
> Won't work under Vista. I have a rock solid replacement for it in my
> next release of our Utilities. Charles and I have been beating on it
> for weeks now both under XP and Vista and it just works.
>
> ITRun('EVKey.exe',True,'/V SUBSCRIPTION ' & clip(LOC:SubscriptionKey))

COOL :-)

Friedrich

NewsArchive
03-31-2008, 02:36 AM
But I get "unknown procedure". I must be missing something.

John

NewsArchive
03-31-2008, 02:37 AM
> But I get "unknown procedure". I must be missing something.

I think you must show Arnor your credit card <g>
Peter

NewsArchive
03-31-2008, 02:37 AM
I would be very happy to but apparently the utilities are not available
right now. I need a fix urgently as this is going out the door tonight.

John

NewsArchive
03-31-2008, 02:38 AM
John,

GLOBAL
After Global Includes
Priority 4000

! ShellExecuteEx

SHELLEXECUTEINFO GROUP,TYPE
cbSize LONG
fMask ULONG
hwnd LONG
lpVerb LONG
lpFile LONG
lpParameters LONG
lpDirectory LONG
nShow LONG
hInstApp LONG
! Optional fields
lpIDList LONG
lpClass LONG
hkeyClass LONG
dwHotKey LONG
hXXX LONG
hProcess LONG
END

si GROUP(SHELLEXECUTEINFO)
END

actionVista CSTRING('runas')
action CSTRING('open')
ret LONG
file_name CSTRING(FILE:MaxFilePath+3)

Then
local data
IsVista BYTE
ret BYTE

Init Open Window
IsVista = 0
IsVista = GETREG(REG_CURRENT_USER,'SOFTWARE\CGF\Data Management
Center','IsVista')

Then here is a routine to call any exe you need

RegarderMieux ROUTINE

ret = 0

file_name = CLIP(yourpathhere) & '\yourexenamehere.exe'
CLEAR(si)
si.cbSize = SIZE(SHELLEXECUTEINFO)
si.fMask = ''
si.hwnd = RegWindow{PROP:Handle}

IF IsVista <> 1
si.lpVerb = ADDRESS(action)
ELSE
si.lpVerb = ADDRESS(actionVista)
END
si.lpFile = ADDRESS(file_name)
si.nShow = 1
si.hInstApp = ADDRESS(si.hInstApp)
si.hProcess = ADDRESS(si.hProcess)
ret = ShellExecuteEx(ADDRESS(si))

keep your credit card ......

--
Thank you

Cordialement - Best regards
Jean-Pierre GUTSATZ

CGF

Data Management Center - A tool to let you Migrate Import Export Transfer
all your Data very easily
www.dmc-fr.com
Certified by Microsoft : "Works with Vista" & "Works with Windows Server
2008"

NewsArchive
03-31-2008, 02:39 AM
ret is defined in globals sorry remove it from local data .....

--
Thank you

Cordialement - Best regards
Jean-Pierre GUTSATZ

CGF

Data Management Center - A tool to let you Migrate Import Export Transfer
all your Data very easily
www.dmc-fr.com
Certified by Microsoft : "Works with Vista" & "Works with Windows Server
2008"

NewsArchive
03-31-2008, 02:40 AM
of course the dmc part in registry is not good for you add your way of
checking you are under Vista.....
VuFtools has something I think.....

--
Thank you

Cordialement - Best regards
Jean-Pierre GUTSATZ

CGF

Data Management Center - A tool to let you Migrate Import Export Transfer
all your Data very easily
www.dmc-fr.com
Certified by Microsoft : "Works with Vista" & "Works with Windows Server
2008"

NewsArchive
03-31-2008, 02:41 AM
Hi Jean-Pierre,

> ret = ShellExecuteEx(ADDRESS(si))
>
>keep your credit card ......

For John's sake I'm posting what is _really_ needed after the
ShellExecuteEx call, as without this code, this is just as dead in the
water as Run() without the wait parameter working, which is what seems
to be what John really needs.

If Not SELF.ShellExecEx(SHi)
hProc = 0
Else
hProc = Shi.hProcess
End

If hProc
If pWait
RetVal = IT_WaitForSingleObject(hProc,-1)
If IT_GetExitCodeProcess(hProc, lRetCode)
RetValue = lRetCode
Else
RetValue = RetVal
End
RetVal = IT_CloseHandle(hProc)
End
End
If Not cCmdLine &= NULL
Dispose(cCmdLine)
End
End

All our API prototypes are prefixed with IT_ for clarity.

Best regards,

Arnór Baldvinsson
Icetips Creative, Inc.
San Antonio, Texas, USA
www.icetips.com


Subscribe to information from Icetips.com:
http://www.icetips.com/subscribe.php

NewsArchive
03-31-2008, 02:42 AM
Arnor,

Thanks I have no code like that wait code of yours...

All I use is what Friedrich helped me with when I had the problem too.....



--
Thank you

Cordialement - Best regards
Jean-Pierre GUTSATZ

CGF

Data Management Center - A tool to let you Migrate Import Export Transfer
all your Data very easily
www.dmc-fr.com
Certified by Microsoft : "Works with Vista" & "Works with Windows Server
2008"

NewsArchive
03-31-2008, 02:42 AM
Hi Jean-Pierre,

>Thanks I have no code like that wait code of yours...
>
>All I use is what Friedrich helped me with when I had the problem too.....

Understood, but without that code there is no way to let the calling
program wait for the running process to finish.

Best regards,

Arnór Baldvinsson
Icetips Creative, Inc.
San Antonio, Texas, USA
www.icetips.com


Subscribe to information from Icetips.com:
http://www.icetips.com/subscribe.php

NewsArchive
03-31-2008, 02:43 AM
Sorry Arnor - just lost I am afraid.

So many compiler errors. I defined these variables and took out the IT
references of course.

hproc LONG
pwait LONG
retval LONG
lretcode LONG


I have to admit I have no idea what I am doing here.

John

NewsArchive
03-31-2008, 02:44 AM
Hi John,

>Sorry Arnor - just lost I am afraid.

If you buy the gold subscription I will email you the updated files
right away along with exact information on how to do this. There is a
lot of equates, prototypes etc. etc. that have to be in place for this
to work and even if I tried to pull something out and email it to you
I'm sure that I would forget something:(

Sorry, should have suggested this right away...

Best regards,

Arnór Baldvinsson
Icetips Creative, Inc.
San Antonio, Texas, USA
www.icetips.com


Subscribe to information from Icetips.com:
http://www.icetips.com/subscribe.php

NewsArchive
03-31-2008, 02:45 AM
Hi John,

>Sorry Arnor - just lost I am afraid.

I just sent you an email with an app attached that does this. Let me
know here if you didn't get it.

Best regards,

Arnór Baldvinsson
Icetips Creative, Inc.
San Antonio, Texas, USA
www.icetips.com


Subscribe to information from Icetips.com:
http://www.icetips.com/subscribe.php

NewsArchive
03-31-2008, 02:46 AM
Thank you Jean-Pierre

But do you have a quick example I could download? I am getting compile
errors and not sure why.

si.hwnd = RegWindow{PROP:Handle} is not happy - I am not sure what to use
instead of RegWindow - it does not like the title of my window

and also does not like:

ret = ShellExecuteEx(ADDRESS(si)) - does not recgonise Shell ExecuteEx

Did everything else as per instructions.

Thanks

John

NewsArchive
03-31-2008, 02:47 AM
RegWindow is the name of MY window
Change it to your window name 'window' 'quickwindow' etc .....

--
Thank you

Cordialement - Best regards
Jean-Pierre GUTSATZ

CGF

Data Management Center - A tool to let you Migrate Import Export Transfer
all your Data very easily
www.dmc-fr.com
Certified by Microsoft : "Works with Vista" & "Works with Windows Server
2008"

NewsArchive
03-31-2008, 02:48 AM
SORRY
I forgot in Global
Inside the Global MAP
Priority 4000

MODULE('Win32')
ShellExecuteEx(LONG),LONG,PASCAL,RAW,NAME('ShellEx ecuteExA')
ShellExecute(LONG hWnd, <*CSTRING Action>, *CSTRING Filename,
*CSTRING Parameters, *CSTRING Directory, LONG
Flags),LONG,PASCAL,RAW,PROC,NAME('ShellExecuteA')
Sleep(long dwMilliseconds),pascal
End

The function not being defined it could not understand it of course

use Arnor's wait code also and you should be fine...

--
Thank you

Cordialement - Best regards
Jean-Pierre GUTSATZ

CGF

Data Management Center - A tool to let you Migrate Import Export Transfer
all your Data very easily
www.dmc-fr.com
Certified by Microsoft : "Works with Vista" & "Works with Windows Server
2008"

NewsArchive
03-31-2008, 02:49 AM
>> Won't work under Vista. I have a rock solid replacement for it in my
>> next release of our Utilities. Charles and I have been beating on it
>> for weeks now both under XP and Vista and it just works.
>>
>> ITRun('EVKey.exe',True,'/V SUBSCRIPTION ' & clip(LOC:SubscriptionKey))
>
> COOL :-)

Yes it is COOL and it works like a charm!

SoftDefense makes heavy use of it and it runs fine on Vista or XP.

;-)

Charles


--
-------------------------------------------------------------------------------------------------------
Charles Edmonds
www.pagesnip.com - "Print and Save the Web, just the way you want it!"
www.clarionproseries.com - "Serious imaging tools for Clarion Developers"
www.ezround.com - "Round Corner HTML tables with matching Banners, Buttons
and Forms!"
www.lansrad.com - "Intelligent Solutions for Universal Problems"
www.fotokiss.com - "World's Best Auction Photo Editor"
-------------------------------------------------------------------------------------------------------