tags:

views:

45

answers:

2
public sub Main()

Set objShell = CreateObject("WScript.Shell")
                 strCommand = "C:/Program Files/s/schedule.exe"
                 objShell.Run strCommand, vbHide, True
Unload Me

end sub

it's supposed to run schedule.exe hidden....but program crashes with

Runtime error '-2147024894 (80070002)' :
method '~' of object '~' failed

basically i need schedule.exe to run silently without interrupting the user.

A: 

If you had a reference to Windows Script Host Object Model you would get this more descriptive error message:

Automation error
The system cannot find the file specified. 

This might clue you that you had to quote the executable filename if it contains spaces like this:

Public Sub Main()
    Dim objShell As Object ' WshShell
    Dim strCommand As String

    Set objShell = CreateObject("WScript.Shell")
    strCommand = "C:/Program Files/7-zip/7z.exe"
    objShell.Run """" & strCommand & """", vbHide, True ' WshHide
End Sub
wqw
expected end of statement
bkbkbk
i compiled this and basically, it doesn't hide 7z.exe
bkbkbk
Put this in a separate project in `Form1` and call it from `Form_Load` event. Just tested it and it does spawn 7-zip and does hide the console.
wqw
Why not just this? `Shell "C:\Program Files\s\schedule.exe", vbHide`
MarkJ
wqw: i need to hide 7-zip....like http://www.zinious.com/products/ZHider/
bkbkbk
A: 

You don't need to use WScript: just use the Shell function with the vbHide argument.

Shell "C:\Program Files\s\schedule.exe", vbHide
MarkJ
I think OP wants to wait for the shelled process to complete.
wqw
http://www.zinious.com/products/ZHider/ is what im aiming for
bkbkbk