Jump to content
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble

MSFN is made available via donations, subscriptions and advertising revenue. The use of ad-blocking software hurts the site. Please disable ad-blocking software or set an exception for MSFN. Alternatively, register and become a site sponsor/subscriber and ads will be disabled automatically. 


Sign in to follow this  

Recommended Posts

Hi,

I am currently writing some command line tools and was wondering what the most portable way of having a script called myscript.vbs that works like any normal command line program.

I have tried so far testing for the name of the script host executable and if it's wscript, then doing in an if block

shell.run "cscript.exe """ & Wscript.ScriptFullName & """"
WScript.Quit

However this opens the script in a new cmd window which is a bit of a problem, especially since you can't read the output before the window closes.

I know I can change the default scripting host of the system to be cscript instead of wscript but it would be nice to do this in a more portable way such that I don't have to change the host environment to achieve this.

Also, if I change the scripting host, then whenever I run any wscript orientated script that I want to run behind the scenes, it pops up a cmd box, which looks rubbish.

Perhaps there is a way of doing the shell.run in the current window or some completely different way of doing this? shell.Exec? Or get cscript to execute in the current window instead of starting a new one?

Any ideas welcome.

Thanks

Share this post


Link to post
Share on other sites

if you use ExeScript to compile your vbs to an exe you should get the predictable results you're looking for.

Edited by #rootworm

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...