I have a VB script that we are using group policy to execute during logon to
launch an exe file. Unfortunately the file runs with the window open and
some of our users close it....leaving the application uninstalled. Is there
a way for the script to run the exe file hidden? XP users....2003
server....Active Directory....sample of the script is below....

Dim WSHShell
Set WSHShell = WScript.CreateObject("WScript.Shell")

WSHShell.Run "\\sample\pretend$\setup.exe"


WScript.Quit(0)

Thank you!
Always Learning

Re: Hidden windows by Rafael

Rafael
Wed Apr 06 21:01:27 CDT 2005

Try calling the application and minimize the window.

WSHShell.run "setup.exe" ,2

the 2 means activate and minimize the window.
hope this helps,
RT


"Always Learning" <Always Learning@discussions.microsoft.com> wrote in
message news:41A18E5E-D8FB-4D5F-A72B-8EB5234BF947@microsoft.com...
>I have a VB script that we are using group policy to execute during logon
>to
> launch an exe file. Unfortunately the file runs with the window open and
> some of our users close it....leaving the application uninstalled. Is
> there
> a way for the script to run the exe file hidden? XP users....2003
> server....Active Directory....sample of the script is below....
>
> Dim WSHShell
> Set WSHShell = WScript.CreateObject("WScript.Shell")
>
> WSHShell.Run "\\sample\pretend$\setup.exe"
>
>
> WScript.Quit(0)
>
> Thank you!
> Always Learning



Re: Hidden windows by AlwaysLearning

AlwaysLearning
Thu Apr 07 08:47:16 CDT 2005



"Rafael T" wrote:

> Try calling the application and minimize the window.
>
> WSHShell.run "setup.exe" ,2
>
> the 2 means activate and minimize the window.
> hope this helps,
> RT
>
>
> "Always Learning" <Always Learning@discussions.microsoft.com> wrote in
> message news:41A18E5E-D8FB-4D5F-A72B-8EB5234BF947@microsoft.com...
> >I have a VB script that we are using group policy to execute during logon
> >to
> > launch an exe file. Unfortunately the file runs with the window open and
> > some of our users close it....leaving the application uninstalled. Is
> > there
> > a way for the script to run the exe file hidden? XP users....2003
> > server....Active Directory....sample of the script is below....
> >
> > Dim WSHShell
> > Set WSHShell = WScript.CreateObject("WScript.Shell")
> >
> > WSHShell.Run "\\sample\pretend$\setup.exe"
> >
> >
> > WScript.Quit(0)
> >
> > Thank you!
> > Always Learning



Thank you for the advice, however the window still pops open. Any other
ideas would be appreciated!

Always Learning


>
>
>

Re: Hidden windows by Joe

Joe
Thu Apr 07 09:17:19 CDT 2005

Hi,

"Always Learning" <AlwaysLearning@discussions.microsoft.com> wrote in
message news:2F760391-E5DA-465E-8F66-1A2736E328B9@microsoft.com...
>
>
> "Rafael T" wrote:
>
>> Try calling the application and minimize the window.
>>
>> WSHShell.run "setup.exe" ,2
>>
>> the 2 means activate and minimize the window.
>> hope this helps,
>> RT
>>
>>
>> "Always Learning" <Always Learning@discussions.microsoft.com> wrote in
>> message news:41A18E5E-D8FB-4D5F-A72B-8EB5234BF947@microsoft.com...
>> >I have a VB script that we are using group policy to execute during
>> >logon
>> >to
>> > launch an exe file. Unfortunately the file runs with the window open
>> > and
>> > some of our users close it....leaving the application uninstalled. Is
>> > there
>> > a way for the script to run the exe file hidden? XP users....2003
>> > server....Active Directory....sample of the script is below....
>> >
>> > Dim WSHShell
>> > Set WSHShell = WScript.CreateObject("WScript.Shell")
>> >
>> > WSHShell.Run "\\sample\pretend$\setup.exe"
>> >
>> >
>> > WScript.Quit(0)
>> >
>> > Thank you!
>> > Always Learning
>
>
>
> Thank you for the advice, however the window still pops open. Any other
> ideas would be appreciated!
>
> Always Learning

Try 0 instead of 2, or ...

Here's a post from Al Dunbar (MVP) last week on a similar question. I
haven't tried it personally, and since it's undocumented, I don't hazard a
guess as to whether it applies across all OS's.

-----
Hmmm, couldn't find the code here, must be at work.

Anyway, I basically have a function that accepts a command that could be
processed by CMD.EXE. The function uses the .run method with a command like:

STEALTH = &H20000000
wshshell.run "%comspec% /c >%temp%\tempfile.tmp " & commandstring,
STEALTH, true

When control is returned back to the script, the function then opens the
temp file that the command was piped into, does a .readall, then closes and
deletes it.

The main thing is that the STEALTH window style is not given in the docs,
and for the life of me I cannot remember where I got it from. It is even
better than an intWindowStyle of 2 (minimize), as it does not show up on the
taskbar (not sure about alt-tab visibility, though, but it does show up in
task manager). I haven't tried 0 (hides the window and activates another
window) as I didn't like the last part of the sentence.


/Al
-----

Joe Earnest



Re: Hidden windows by mr_unreliable

mr_unreliable
Sat Apr 09 17:08:04 CDT 2005

hi Always,

What you want to do is easy, _IF_ you are willing to use system api's
from script. The "bad news" is that Microsoft doesn't want you calling
api's from script, and most "professional" scripters will also
discourage the practice.

However, assuming that you are willing to give it a try, there are
two approaches.

1. The most simple and direct way is to use "FindWindow" to get the
handle of the app's window, and then either hide it with "ShowWindow"
using the "SW_HIDE" command constant. _or_ (maybe better) use
"MoveWindow" and just move the window offscreen. (You can move the
window offscreen by setting the left and top coordinates to large
negative numbers (like: -10000, -10000). Note that when the window
is offscreen, it is not technically "hidden" -- you just can't see it.

2. A more subtle approach would be just to "Block" the user's input.
The "BlockInput" api will block all user keyboard and mouse input.

http://www.mentalis.org/apilist/1B463387B31CF691556B7458C7FE1D68.html

I acknowledge that you asked about hiding the window, but you later
implied that the only reason for hiding the window was to foil the
user's attempts to close it before it had finished whatever
(installing?) it was doing. If you block the user's input, he/she
can type and click to their heart's content, but it will have no
effect. Also note: if you do use blockinput, then kindly remember to
unblock when you are finished...

cheers, jw

p.s. As there is no native ability in script to call api's, you will
have to use an actX object to do it. You can write your own, or you
can use a pre-programmed utility. One such utility is called "DynaWrap"
(a.k.a DynaCall), which may be found at Guenter Born's website:

http://people.freenet.de/gborn/WSHBazaar/WSHBazaar.htm

Look for "actX controls", then "The DynaCall Page"


Re: Hidden windows by Michael

Michael
Sat Apr 09 19:15:14 CDT 2005

> WSHShell.Run "\\sample\pretend$\setup.exe"



WSHShell.Run "\\sample\pretend$\setup.exe", 0

No visible window, taskbar button, or application listed in task manager.
Only the running process is listed in task manager.


--
Michael Harris
Microsoft MVP Scripting
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Please ask follow-up questions via the original newsgroup thread.