Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Launching VB script from another script

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

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Launching VB script from another 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 >>
 Launching VB script from another script - 4/19/2007 2:26:27 PM   
  kzseatttle

 

Posts: 1
Score: 0
Joined: 4/19/2007
Status: offline
 
Hello,

I have a VB script, say, A.wsf that launches another script, say, B.wsf

The code in A.wsf looks like this:

WshShell.Run "cscript.exe B.wsf", 1, true

A.wsf and B.wsf are in the same directory. Let's assume the directory is c:\scripts

The problem is that this only works if I run A.wsf from c:\scripts. If I run it from any other location, say, c:\, then this does not work. Apparently, WshShell considers the path to B.wsf relative to the directory from where I run the script and not relative to the directory that contains A.wsf. So if I run A.wsf as this: 

c:\cscript scripts\A.wsf

then WshShell will try to find B.wsf under c:\ and not under c:\scripts.

I thought WshShell will try to find B.wsf from the same directory as the caller but that doesnt seem to be the case. Is there any work around for this WITHOUT modifying A.wsf or B.wsf or moving them around? Is there a way to force cscript find B.wsf under in the same directory as A.wsf?
 
 
Post #: 1
 
 RE: Launching VB script from another script - 4/19/2007 4:13:05 PM   
  dm_4ever


Posts: 2637
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
If you try to run a command like this.

WshShell.Run "c:\cscript scripts\A.wsf" then you will encounter an issue with that space between cscript and scripts.  As a workaround you can add two more " or use Chr(34)

i.e. 
WshShell.Run """c:\cscript scripts\A.wsf"""
WshShell.Run Chr(34) & "c:\cscript scripts\A.wsf" & Chr(34)

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to kzseatttle)
 
 
Post #: 2
 
 
 
  

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 >> Launching VB script from another 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