Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


How can I run a program using a vb script

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,2170
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> How can I run a program using a vb script
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 How can I run a program using a vb script - 2/25/2005 3:29:33 AM   
  khedstro

 

Posts: 5
Score: 0
Joined: 2/25/2005
From:
Status: offline
I am running a one program terminal service session and the program I am running is MulitView emulator. When I close the program it does not close the terminal service session. I was given the below batch file to run that would close the session when MultiView was closed.

start /wait MultiView.exe
logoff.exe

This works, but I am wondering how can I accomplish this same thing using a VB Script? I ask because I want the script to run without showing the command prompt window. I want the script to run without seeing it. Silently. I know I could use the .run command, but I am not sure how to write the script. Help!?!?!?
 
 
Post #: 1
 
 Re: How can I run a program using a vb script - 2/25/2005 4:01:48 AM   
  esnmb

 

Posts: 448
Score: 0
Joined: 1/11/2005
From: USA
Status: offline
If it is launched via WSCRIPT then you will not see the script window. Basically double click on the VBS.

Const SHOW_ACTIVE_APP = 1
Set objShell = Wscript.CreateObject("Wscript.Shell")

objShell.Run ("calc.exe"), SHOW_ACTIVE_APP, True
Wscript.Quit

(in reply to khedstro)
 
 
Post #: 2
 
 Re: How can I run a program using a vb script - 2/25/2005 4:12:56 AM   
  esnmb

 

Posts: 448
Score: 0
Joined: 1/11/2005
From: USA
Status: offline
You can do the same thing with some different formating.

Const SHOW_ACTIVE_APP = 1
Set objShell = Wscript.CreateObject("Wscript.Shell")

objShell.Run "calc.exe", SHOW_ACTIVE_APP, True ' The script will continue until calc is closed.
Wscript.Quit

(in reply to khedstro)
 
 
Post #: 3
 
 Re: How can I run a program using a vb script - 2/25/2005 5:23:14 AM   
  khedstro

 

Posts: 5
Score: 0
Joined: 2/25/2005
From:
Status: offline
I can't seem to get it to work. I appreciate your help very much. This is what I have setup as a batch file.

@ echo off
start /wait "C:\Program Files\MultiView\MultiView 2000\jsbterm.exe" "C:\Program Files\MultiView\COINS.zzt"
logoff.exe

This is what I put in the vb script

Const SHOW_ACTIVE_APP = 1
Set objShell = Wscript.CreateObject("Wscript.Shell")

objShell.Run ("C:\Program Files\MultiView\MultiView 2000\jsbterm.exe" "C:\Program Files\MultiView\COINS.zzt"), SHOW_ACTIVE_APP, True
Wscript.Quit

I get an error at line 4 character 71, expected ')'

Your help is greatly appreciated. Thanks

(in reply to khedstro)
 
 
Post #: 4
 
 Re: How can I run a program using a vb script - 2/25/2005 5:54:10 AM   
  mbouchard


Posts: 1916
Score: 16
Joined: 5/15/2003
From: USA
Status: offline
[quote[objShell.Run ("C:\Program Files\MultiView\MultiView 2000\jsbterm.exe" "C:\Program Files\MultiView\COINS.zzt"), SHOW_ACTIVE_APP, True[/quote]

The above line should be something like
[quote[objShell.Run ("C:\Program Files\MultiView\MultiView 2000\jsbterm.exe C:\Program Files\MultiView\COINS.zzt"), SHOW_ACTIVE_APP, True[/quote]

Or if you need to seperate the COINS from the JSBTERM with quotes

[quote[objShell.Run ("C:\Program Files\MultiView\MultiView 2000\jsbterm.exe" & "C:\Program Files\MultiView\COINS.zzt"), SHOW_ACTIVE_APP, True[/quote]

(in reply to khedstro)
 
 
Post #: 5
 
 Re: How can I run a program using a vb script - 2/25/2005 8:32:26 AM   
  khedstro

 

Posts: 5
Score: 0
Joined: 2/25/2005
From:
Status: offline
I tried to use the below tip

[quote[objShell.Run ("C:\Program Files\MultiView\MultiView 2000\jsbterm.exe" & "C:\Program Files\MultiView\COINS.zzt"), SHOW_ACTIVE_APP, True[/quote]

I get a type mismatch error now. I am not sure what to do from here. This is what I have in the script now.

Const SHOW_ACTIVE_APP = 1
Set objShell = Wscript.CreateObject("Wscript.Shell")

[quote[objShell.Run ("C:\Program Files\MultiView\MultiView 2000\jsbterm.exe" & "C:\Program Files\MultiView\COINS.zzt"), SHOW_ACTIVE_APP, True[/quote]
Wscript.Quit

Any help would be greatly appreciated. Thanks

(in reply to khedstro)
 
 
Post #: 6
 
 Re: How can I run a program using a vb script - 2/25/2005 8:38:57 AM   
  tnoonan

 

Posts: 364
Score: 0
Joined: 12/14/2004
From:
Status: offline
Remove [quote[ And [/quote]
You were not supose to copy those.

(in reply to khedstro)
 
 
Post #: 7
 
 Re: How can I run a program using a vb script - 2/25/2005 8:38:58 AM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
You could do something like this:

================================================================================================
objShell.Run ("""C:\Program Files\MultiView\MultiView 2000\jsbterm.exe""" & """ C:\Program Files\MultiView\COINS.zzt"""), 0, True
objShell.Run ("%COMSPEC% /C logoff.exe"), 0, True

(in reply to khedstro)
 
 
Post #: 8
 
 Re: How can I run a program using a vb script - 2/25/2005 9:16:01 AM   
  khedstro

 

Posts: 5
Score: 0
Joined: 2/25/2005
From:
Status: offline
This almost works

objShell.Run ("""C:\Program Files\MultiView\MultiView 2000\jsbterm.exe""" & """ C:\Program Files\MultiView\COINS.zzt"""), 0, True
objShell.Run ("%COMSPEC% /C logoff.exe"), 0, True

It begins to load the program, but when it gets to the .zzt file it fails to load. I get an error that says invalid path when I know that C:\Program Files\MultiView\COINS.zzt is there. It is almost there. Any ideas? thanks

(in reply to khedstro)
 
 
Post #: 9
 
 Re: How can I run a program using a vb script - 2/25/2005 9:19:29 AM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
Exact error message ?

(in reply to khedstro)
 
 
Post #: 10
 
 Re: How can I run a program using a vb script - 2/25/2005 9:26:10 AM   
  khedstro

 

Posts: 5
Score: 0
Joined: 2/25/2005
From:
Status: offline
The error is a Windows error message
C:\Documents and Settings\Administrator\My Documents\ C:\Program Files\MultiView\COINS.zzt contains an invalid path.

I then click OK and then it says another error
C:\Documents and Settings\Administrator\My Documents\ C:\Program Files\MultiView\COINS.zzt error loading file.

Any ideas?

(in reply to khedstro)
 
 
Post #: 11
 
 Re: How can I run a program using a vb script - 2/25/2005 9:32:45 AM   
  tnoonan

 

Posts: 364
Score: 0
Joined: 12/14/2004
From:
Status: offline
Is the file in use, Locked, Read only

Check file attribs

(in reply to khedstro)
 
 
Post #: 12
 
 Re: How can I run a program using a vb script - 2/25/2005 9:43:31 AM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
If the error message that you got (either from the program itself or from Windows) indicates that "C:\Program Files\MultiView\COINS.zzt" cannot be found, something else is most likely to be the problem since the script did successfully pass the argument to the multiview program.

Could you try to manually run the program and see if you got any errors ? Like tnoonan said, it might be the file is locked.

(in reply to khedstro)
 
 
Post #: 13
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> How can I run a program using a vb script Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts