Questions tagged [wsh]

For questions relating to Windows Script Host (WSH), a language-independent scripting host for the Windows operating system. It allows scripts to be run from both the graphical Windows desktop (via WScript.exe) and the command prompt (via CScript.exe).

Windows Script Host (sometimes abbreviated as WSH), in both Wscript.exe and Cscript.exe guises, can run VBScript (*.VBS, *.VBE) and JScript (*.JS, *.JSE), via Microsoft-provided script engines that are bundled with the OS and installed by default.

In addition to VBScript and JScript, there are third-party script engines for WSH that you can download to allow the use of Python, REXX, Perl, and other languages. (The script engines that add into WSH are distinct from standalone script interpreters that might exist for those languages, on Windows).

Multiple languages can be mixed in Windows Script Files (*.WSF). These types of scripts may also be used to link many other external scripts together using a src parameter on the <script> tag in a manner similar to HTML. A WSF makes reference to each script module in a very basic XML hierarchy and it's a package that can be organized in jobs.

Regardless of whether the UI is console-based or graphical, the same underlying script engine is used. In UI mode, the host is WScript.exe (used by default); in console mode, the host is CScript.exe.

The Windows Script Host has been part of every Microsoft Windows operating system's installation since Windows 98.

In 2006, Microsoft released v1.0 of Windows PowerShell, which could be conceived as a replacement for, or successor of, Windows Script Host. PowerShell is now included in every Windows OS. Even so, WSH is still included in every Windows OS, and many Wscript programs will continue to be in service, for many years.

References:

Related tags:

1078 questions
5
votes
3 answers

Real time console output from WScript.Shell Exec

I spent most of the day searching for a solution to this, I'm starting to think its maybe not possible for my requirements My basic setup is to run a vbscript (.vbs) called from an excel vba code. The vba code has to continue on and leave the…
Skytunnel
  • 1,063
  • 2
  • 10
  • 21
5
votes
2 answers

How to delay in VB Script?

How can I delay a Vb Script? The following codes did not work for me: wscript.sleep 1000 Delay 10 Sub Delay( seconds ) Dim wshShell, strCmd Set wshShell = CreateObject( "Wscript.Shell" ) strCmd = "%COMSPEC% /C (PING -n " & ( seconds +…
ladiesman1792
  • 243
  • 2
  • 5
  • 21
5
votes
2 answers

vba WScript.Shell run .exe file with parameter

I am running a VBA macro from Word 2013. I'm trying to run an executable file which requires an argument/parameter of a filename. For example, c:\myfilefilter.exe filetobefiltered.htm I would like to use Shell Run because I want the VBA code to…
user1892770
  • 323
  • 2
  • 3
  • 15
5
votes
3 answers

JScript: how to run external command and get output?

I'm running my JScript file using cscript.exe. In the script I need to call an external console command and get the output. Tried: var oShell = WScript.CreateObject("WScript.Shell"); var oExec = oShell.Exec('cmd /c dir'); WScript.Echo("Status…
Putnik
  • 5,925
  • 7
  • 38
  • 58
5
votes
2 answers

Detect when a web page is loaded without using sleep

I am creating a VB script on windows which opens a site in IE. What I want: Detect when the web page is loaded and display a message. I achieved this by using sleep (WScript.Sleep) for approx. seconds when the site gets loaded. However, the site…
user3562474
  • 51
  • 1
  • 1
  • 2
5
votes
2 answers

How can I edit the SOAP envelope and header with Perl's SOAP::Lite?

I'm trying to modify the soapenv:Header to include addressing in my soap request my $header=SOAP::Header->name("Header")->prefix("soap")->uri("http://www.w3.org/2005/08/addressing"); When I send the request: print $soap->call($header,…
Shayne
  • 51
  • 2
5
votes
3 answers

Excel VBA error using WScript.Shell.Run

After recently upgrading from Excel 2010 to Excel 2013, I moved a custom add-in (.xlam) to the new Application.LibraryPath directory (C:\Program Files\Microsoft Office 15\root\office15\Library\BTRTools). There is a bit of code that launches an…
Terry
  • 2,148
  • 2
  • 32
  • 53
5
votes
1 answer

Can I initialize objects written in JScript from VBScript?

I am trying to write a WSH logon script. Administrators throughout the company need to be able to customize the execution of the script, and execute additional scripts, for specific locations and users. In order to make their jobs easier, I would…
Justin Rusbatch
  • 3,992
  • 2
  • 25
  • 43
5
votes
2 answers

vim creating alias for frequently used command

Possible Duplicate: Aliasing a command in vim So I have to edit waf wscript files a lot . Everytime I execute this command to set the filetype set filetype=python is there a way to set up an small alias for the above command ? SO that I can…
Vihaan Verma
  • 12,815
  • 19
  • 97
  • 126
5
votes
2 answers

How to pass a command with spaces and quotes as a single parameter to CScript?

I'm using CScript to run a VBScript file, and I need to pass a command line to the script where the parameter includes both spaces and quotes. The entire command needs to be passed as one parameter to the script. For example: C:\> CScript…
Wes S.
  • 53
  • 1
  • 1
  • 3
4
votes
3 answers

Javascript Object vs JScript Dictionary

Javascript Objects and JScript Dictionary are both associative Arrays obj = new Object ; dic = new ActiveXObject("Scripting.Dictionary") ; My question is... Is there any difference between them in terms of efficiency (either space or time) ?? In…
GetFree
  • 40,278
  • 18
  • 77
  • 104
4
votes
2 answers

How do I get the computer name of a system and output it to a file in VBScript

I am trying to get the computer name from the registry and write it to a file. At this point, my function call for obtaining the computer name from registry isn't working. Any advice would be appreciated. Option Explicit On Error Resume Next Dim…
Soberone
  • 45
  • 1
  • 2
  • 5
4
votes
2 answers

Show Message dialog while executing

I use this snippet in vbscript: Set WSH = CreateObject("WScript.Shell") cmd = "some command" flag = WSH.Run(cmd, 0, true) As it can be noticed, in .Run() call, "WaitOnReturn" is set to "true" as I want to know when external program finishes and…
theta
  • 24,593
  • 37
  • 119
  • 159
4
votes
2 answers

How to run VBScript in Windows NT 4?

I have a VBScript which I am scheduling to run daily on many Windows servers. In Windows 2000 and 2003, the script worked fine as the two OS have csript.exe. However, in Windows NT 4, it does not seem to have this executable. Is there an…
titanium
  • 347
  • 2
  • 11
  • 21
4
votes
0 answers

What is the difference between creating a COM instance through CreateObject versus ActiveXObject?

This has been touched on here in the second answer but I don't see how it answers the question (nor does the link provided). What can ActiveXObject do that CreateObject cannot, and vice-versa?
JohnZaj
  • 3,080
  • 5
  • 37
  • 51