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
18
votes
3 answers

Is it possible to add a directory to DLL search path from a batch file or cmd script?

MSDN says that the function SetDllDirectory() can be used to insert a directory into the DLL Search Path. Can this function be accessed from a batch file or cmd script, perhaps using via cscript? The aim is to have our development version of a dll…
matt wilkie
  • 17,268
  • 24
  • 80
  • 115
17
votes
3 answers

How can I create a javascript library in a separate file and "include" it in another?

First, a caveat. The main script is not run in a webpage. I will be running the .js file in Windows using Windows Script Host. The problem: I would like to create a javascript "library" containing a number of objects, each with a number of…
user38735
15
votes
2 answers

How can I run a WSH script without seeing the Microsoft header?

When a .vbs script is run from the command line, it will by default show a Microsoft header: Microsoft (R) Windows Script Host Version 5.7 Copyright (C) Microsoft Corporation. All rights reserved. How can this be disabled?
lucrussell
  • 5,032
  • 2
  • 33
  • 39
14
votes
5 answers

VBScript getting results from Shell

Set wshShell = WScript.CreateObject ("WSCript.shell") wshshell.run "runas ..." How do I get the results and display in a MsgBox
Cocoa Dev
  • 9,361
  • 31
  • 109
  • 177
14
votes
2 answers

Prompt dialog in WSH using JScript?

How to open a prompt dialog box in WSH usig JScript?? The only pop-up dialog I've found in the doc is the WshShell.Popup() method. But I need a way to request the user to enter a string, like the window.prompt() method in DOM. Thanks.
GetFree
  • 40,278
  • 18
  • 77
  • 104
14
votes
2 answers

How can I write a simple JScript input/output program?

I'm planning on using JavaScript to enter an informatics competition (BIO) tomorrow. However, I can't rely on the examiner having a browser with a decent JavaScript engine, so I was hoping to use Microsoft's JScript instead. However, the…
Eric
  • 95,302
  • 53
  • 242
  • 374
14
votes
6 answers

Get the Windows Download folder's path

I have some Excel VBA code that requires knowing the Downloads folder path. How could I do it? Since you can move around the Downloads folder (and also Documents and most of those folders, via the folder properties), the environmental variables like…
s_a
  • 885
  • 3
  • 9
  • 22
13
votes
4 answers

How to get the associated icon of a file in HTA (HTML/Javascript/VBScript)

I'm building an HTA application in which I need to display a list of file with their associated system icon. I'm using FileSystemObject to list the file but there seem to have no way to get the icon... I've found a script in VBS that can save the…
Patrick
  • 131
  • 1
  • 3
13
votes
3 answers

How to reference a JScript file from another one?

I am writing some server-side scripts using JScript and WSH. The scripts are getting quite long, and some common functions and variables would fit better in a general library script which I included in my various script instances. But, I cannot find…
Thomas Svensen
  • 760
  • 1
  • 7
  • 14
13
votes
5 answers

Capturing output from WshShell.Exec using Windows Script Host

I wrote the following two functions, and call the second ("callAndWait") from JavaScript running inside Windows Script Host. My overall intent is to call one command line program from another. That is, I'm running the initial scripting using…
Eric Johnson
  • 131
  • 1
  • 1
  • 4
13
votes
3 answers

Classic ASP amazon s3 rest authorisation

I am confused on what I am doing wrong here... <% Const AWS_BUCKETNAME = "uk-bucketname" Const AWS_ACCESSKEY = "GOES HERE" Const…
Chris Dowdeswell
  • 858
  • 2
  • 11
  • 25
12
votes
1 answer

passing arguments to javascript through cscript on the command line

I have a small command line JScript routine that I usually run from the command line using cscript in Windows. I'd like to be able to pass in arguments hopefully along the lines of... %:>cscript doSomethingToFile.js FileInQuestion.txt Any insight…
chuck taylor
  • 2,476
  • 5
  • 29
  • 46
12
votes
3 answers

cscript - print output on same line on console?

If I have a cscript that outputs lines to the screen, how do I avoid the "line feed" after each print? Example: for a = 1 to 10 WScript.Print "." REM (do something) next The expected output should be: .......... Not: . . . . . . . . . . In…
Guy
  • 9,720
  • 7
  • 38
  • 42
11
votes
3 answers

cscript jscript JSON

This is a very very (very!!!) strange problem. I have this JSCRIPT that runs on windows XP and 7 using dos CSCRIPT in a file called testJSON.js. if ( ! this.JSON ) WScript.Echo("JSON DOESN'T EXISTS"); And, well, the message appear, but is an…
Andrea Rastelli
  • 617
  • 2
  • 11
  • 26
11
votes
7 answers

Send mail from a Windows script

I would like to send mail from a script on a Windows Server 2003 Standard Edition. I think the server setup is pretty much out of the box. The mail server is an Exchange one, and when you're on the internal network you can use plain old SMTP. I have…
Jörgen Lundberg
  • 1,799
  • 3
  • 22
  • 31
1
2
3
71 72