Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run exe from script 2

Status
Not open for further replies.

lionrampant

IS-IT--Management
Jan 16, 2003
8
US
Hi,

I'm a complete newbie when it comes to VBScript. I have some knowledge of batch files, but it only gets me part way to where I need to be. Some background here, I'm modifying Thunderbird for an enterprise install that our users can install at home as well as at work. Using WinZip Self-Extractor, I've created a setup which runs a batch file that deletes a couple of files on the users' computers and then calls the Thunderbird setup. This works fine except that I can't dismiss the Windows command window. It closes once it's done, but I'd like it to disappear completely. Failing that, it should at least be minimized. Can anyone help with this?

Here's the code:
Code:
:: 1.  Delete userChrome.css and user.js from C:\ 
:: 2.  Run Thunderbird setup

@ECHO OFF

DEL /S c:\userChrome.css >> c:\tbird.log 2>&1
DEL /S c:\user.js >> c:\tbird.log 2>&1
CALL setup.exe

EXIT

As I said, this batch file and the files to install Thunderbird are wrapped in a self-extracting executable.

Thanks in advance for your help,

Ken
 
lionrampant,
from dos:
Exit
Quits the Cmd.exe program (the command interpreter) and returns to the program that started Cmd.exe, if one exists, or to the Program Manager.

so this should work. i'm a little confused by your wording
This works fine except that I can't dismiss the Windows command window. It closes once it's done, but I'd like it to disappear completely.
to me it sounds like it's closed. i wonder if there is a different window open, either from winzip or the .exe.
regards,
longhair
 
longhair --

Thanks for the response. What I was trying to get across was that the DOS window stays open while the self-extractor is running, as does the WinZip SE dialog box. I'd like the DOS window to minimize or hide so as not to confuse the user.

Ken
 
lionrampant,
can't think of a way to force it minimized in your scenario. what about echoing out a statement to the cmd prompt letting the user know what is going on?
regards,
longhair
 
longhair,

Thanks for the idea. If I can't find a way to dismiss/hide the window, then that's what I'll do. At least it will get the message across that the user shouldn't monkey with it.

Thanks,
lionrampant
 
>This works fine except that I can't dismiss the Windows command window. It closes once it's done, but I'd like it to disappear completely.

Try this.
[tt]
:: 1. Delete userChrome.css and user.js from C:\
:: 2. Run Thunderbird setup

@ECHO OFF

DEL /S c:\userChrome.css >> c:\tbird.log 2>&1
DEL /S c:\user.js >> c:\tbird.log 2>&1
CALL setup.exe

[blue]@echo off
cls[/blue]
EXIT
[/tt]
 
yes, vb script. the dos commands that i run from vb scripts, do not show the dos (command) window.
 
here's an example:
it writes the directory into a text file and then read it:
Code:
set fs=CreateObject("Scripting.FileSystemObject")
wshshell.Run("cmd.exe /c dir s:\stellardb\maindata\import\entry_file*.* > c:\a_temp\steldata.txt")  
wScript.sleep 300 
set objTextFile = fs.OpenTextFile("c:\a_temp\steldata.txt")
 
barny2006,
i'm sure you could. but based on his first post i'm assuming he does not know the os that he is installing to
that our users can install at home as well as at work
the above assumption may be incorrect, but it's what we have to go on.
if you have an older os at home you will not have vbs, but you will have dos.
regards,
longhair
 
tsuji --

Thanks, but that will just clear the screen, which I've already done by redirecting errors and standard output to a file.

lionrampant
 
start the batch file using cmd / something or other, i know you cant specify windows size, or am i missing the point
 
barney, longhair --

i'm sure you could. but based on his first post i'm assuming he does not know the os that he is installing to

I'm sorry I didn't make it clear in my first post, but we are assuming Windows XP, Home or Pro, at home. Users with older os's will be directed to contact our helpdesk which will give them the other installer and some instructions. If there is a vbscript that will do what I need, I would appreciate any help you can give me in writing it.

Thanks for your help so far.
lionrampant
 
lionrampant,
from mrmovie in an old thread (thread329-910887)
Code:
Set objFolder = FSO.GetFolder("c:\exes")

For Each aFile In objFolder.Files
  If UCase(Right(aFile.Name,4)) = ".EXE" Then
     WshShell.LogEvent 0, "Running " & aFile.Name

     WshShell.Run(aFile, 1, True)
     'maybe WshShell.Run(aFile.Path & "\" & aFile.Name, 1, True)
     WshShell.LogEvent 0, "Deleting " & aFile.Name
     aFile.Delete
  End If
Next
will have to tweak for your needs but this should get you started.
regards,
longhair
 
>but that will just clear the screen
You sure have all the (last) three lines in place?!
 
tsuji--

>but that will just clear the screen
You sure have all the (last) three lines in place?!

Yes, actually I was already using the EXIT command, but it doesn't run until the CALL setup.exe line completes.

lionrampant

 
> but it doesn't run until the CALL setup.exe line completes
But, you jump to the conclusion that that will just clear the screen.
 
thanks longhair,

if you dont want to see the dos box, not sure if thats the issue i dont have time to read the whole thread ;-)

if you want to use vbscript then

object.Run (strCommand, [intWindowStyle], [bWaitOnReturn])
Parameters
Part Description
object WshShell object.
strCommand Environment variables within the strCommand parameter are automatically expanded.
intWindowStyle Optional. Sets the window style of the program being run.
bWaitOnReturn Optional. If bWaitOnReturn is not specified or FALSE, immediately returns to script execution rather than waiting for the process to end.
If bWaitOnReturn is set to TRUE, the Run method returns any error code returned by the application.

If bWaitOnReturn is not specified or is FALSE, the Run method returns an error code of 0 (zero).



Remarks
The following table lists the available settings for intWindowStyle:
intWindowStyle Description
0 Hides the window and activates another window.
1 Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when displaying the window for the first time.
2 Activates the window and displays it as a minimized window.
3 Activates the window and displays it as a maximized window.
4 Displays a window in its most recent size and position. The active window remains active.
5 Activates the window and displays it in its current size and position.
6 Minimizes the specified window and activates the next top-level window in the Z order.
7 Displays the window as a minimized window. The active window remains active.
8 Displays the window in its current state. The active window remains active.
9 Activates and displays the window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when restoring a minimized window.
10 Sets the show state based on the state of the program that started the application

 
tsuji--

> but it doesn't run until the CALL setup.exe line completes
But, you jump to the conclusion that that will just clear the screen.

No, I tested it as well and that was the result. Thanks for your ideas and please keep them coming.

lionrampant
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top