Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Server > Scripting > Re: Can cscript.exe be made to use a path to locate sctripts?

Reply
Thread Tools Display Modes

Re: Can cscript.exe be made to use a path to locate sctripts?

 
 
Pegasus [MVP]
Guest
Posts: n/a

 
      02-18-2010


"John H." <> said this in news item
news:8c115c92-ad52-42df-a43f-...
> Hi,
>
> Honestly, I’ve tried to find this on my own. I’m new to Windows
> scripting. I feel like I’m missing some really basic concept. Is it
> possible to have cscript.exe search the PATH (or other directory list)
> to find a .vbs file to execute? I have a series of .vbs scripts
> stored is a set of network directories with long path names. I’d like
> to be able to execute these scripts by just entering “cscript.exe
> scriptname.vbs” from the command line w/o specifying full path to
> the .vbs file each time.
>
> I’ve added the script directories to my PATH. My PATHEXT
> environmental variable has .vbs in the list.
>
> Thanks,
> John


You can do it the other way round: If you just enter "scriptname.vbs" then
the Command Processor will find it for you.

 
Reply With Quote
 
 
 
 
Pegasus [MVP]
Guest
Posts: n/a

 
      02-18-2010


"John H." <> said this in news item
news:94092298-b71b-48d4-b588-...
> Okay, I got that to work. Thanks. The scripts that I want to run
> require cscript.exe as a script host. Since the default script host
> is wscript.exe I was getting an error when I ran the .vbs file
> directly from the command line. So I ran cscript.exe /H:cscript to
> change the default. Now I can just run the .vbs file from the command
> line. Very cool!
>
> Is there a down side to changing my default script host to cscript.exe
> that might trip me up later?
>
> Thanks,
> John


None that I'm aware of.

 
Reply With Quote
 
Al Dunbar
Guest
Posts: n/a

 
      02-19-2010


"Tom Lavedas" <> wrote in message
news:0e2e09ff-9d77-4509-8265-...
> On Feb 18, 2:38 pm, "Pegasus [MVP]" <n...@microsoft.com> wrote:
>> "John H." <johnheitmul...@gmail.com> said this in news
>> itemnews:94092298-b71b-48d4-b588-...
>>
>> > Okay, I got that to work. Thanks. The scripts that I want to run
>> > require cscript.exe as a script host. Since the default script host
>> > is wscript.exe I was getting an error when I ran the .vbs file
>> > directly from the command line. So I ran cscript.exe /H:cscript to
>> > change the default. Now I can just run the .vbs file from the command
>> > line. Very cool!

>>
>> > Is there a down side to changing my default script host to cscript.exe
>> > that might trip me up later?

>>
>> > Thanks,
>> > John

>>
>> None that I'm aware of.

>
> Maybe a tiny one, if the OP dislikes command console windows popping
> up anywhere as much as I do. Of course, this only happens when a
> procedure is launched by dropping a file onto it or a shortcut that
> points to it. Or when it is run by double-clicking in explorer.
> Other than that, there's probably no other downside.


Agreed. The downside is that most of us (and most of our scripts) assume
that the default is wscript.exe.

But the OP could modify his script to first determine which scripting engine
is being run, and re-run itself with cscript if if finds it is being run by
wscript. Then he can start the script by any method, whether by
double-clicking or typing scriptname.vbs at a prompt.

Alternately, he could create a non-standard filename extension (.vbsC) and
associate that with cscript.

/Al


 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: DC with "Windows cannot obtain the domain controller name for your computer network" Danny Sanders Active Directory 0 01-21-2010 02:26 PM
active sync issue mk3100 patrick craig ActiveSync 0 01-15-2010 05:06 AM
Re: Incorrect server name Ace Fekay [MCT] Windows Server 4 10-28-2009 02:17 PM
Connected - but no Partnership Adena ActiveSync 10 09-17-2008 08:19 PM
Syncing error in Activesync Michael Kenny ActiveSync 4 01-25-2007 07:29 PM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59