Link to home
Start Free TrialLog in
Avatar of bitaoo
bitaoo

asked on

A problem in <oShell.Run>

Hello friends,

The following is my code. oShell.Run returns an error
<Method 'Run' of object 'IWshShell3' failed', I think
it is because there is a blank in "My Directory" ,
do you know how can I solve it?

sub main()
    Dim oShell As Object
    Dim nRet As Long
       
    Set oShell = CreateObject("WSCript.shell")
    nRet = oShell.Run("C:\My Directory\RMS.exe", , False)
    Set oShell = Nothing
end sub

Thanks,
--Bita
ASKER CERTIFIED SOLUTION
Avatar of appari
appari
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Appari's method will work except replace the line

l=GetShortPathName("C:\My Directory\RMS.exe", x, l)

with

l=GetShortPathName("C:\My Directory\RMS.exe", x, 254)
Avatar of bitaoo
bitaoo

ASKER

Thank for your response but the problem is because of
blank between "My" and "Directory. How can I solve that?

Thanks,
--Bita
appari already give you solution. Use GetShortPathName function
Avatar of bitaoo

ASKER

Thanks a lot.