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
8
votes
1 answer

Is it possible to invoke Mathematica's diff functionality from the command line?

TortoiseSVN (as well as other Tortoise clients) include a script to diff notebook files in Mathematica. Diff functionality for Mathematica is implemented in the AuthorTools package (perhaps there is something better?) The script currently works by…
Szabolcs
  • 24,728
  • 9
  • 85
  • 174
8
votes
2 answers

WScript.Shell and blocking execution?

I'm using WScript to automate some tasks, by using WScript.Shell to call external programs. However, right now it does not wait for the external program to finish, and instead moves on. This causes issues because I have some tasks dependent on…
FlySwat
  • 172,459
  • 74
  • 246
  • 311
8
votes
2 answers

JavaScript version used by the Windows Scripting Host

I have been using JavaScript in Windows Scripting, both in .JS files and .WSF files, for several years, but I have found that there are some methods that are not recognized when I put them in a script that is executed outside a web page that are…
JDMorganArkansas
  • 123
  • 2
  • 10
8
votes
1 answer

Opening a File whose Name Contains a Space

I have some simple Excel VBA code that opens non-Excel files like: Sub scriptTest() Set objshell = CreateObject("Wscript.Shell") objshell.Run ("C:\TestFolder\Book1.pdf") Set objshell = Nothing End Sub Running this opens the file in the…
Gary's Student
  • 95,722
  • 10
  • 59
  • 99
8
votes
1 answer

How to parameterise .wsf scripts for telnet sessions?

I want to automate a task for a telnet session on Windows so that I can run it multiple times using different values. I have a .wsf script for doing that task for one time with hard coded values. How can I parameterise the values of a .wsf script.…
Underoos
  • 4,708
  • 8
  • 42
  • 85
8
votes
2 answers

Can I digitally sign JScript (.js) or VBScript (.vbs) files?

I know that one can sign a Windows binary executable file using signtool. So all this time I was under assumption that one cannot sign any of the files interpreted by Windows Script Host, such as JScript (.js) or VBScript (.vbs) because those are…
c00000fd
  • 20,994
  • 29
  • 177
  • 400
8
votes
1 answer

CScript and VBS to Remove Line Breaks from Text File

I have a batch file running which spits out a text/html file. The batch file is causing some line breaks in the text file, which do not translate very well in opening the file in an email. I have been trying to read up on CScript to create a vbs…
sfreelander
  • 161
  • 1
  • 2
  • 11
8
votes
3 answers

Is it possible to change the automatic configuration script address in the LAN settings of Internet Explorer 8 with the help of a script?

I use 2 different automatic configuration script addresses in the LAN settings of Internet Explorer 8. During the course of my work, I need to switch between them very often. Every time I have to do it manually. Is there a way I can automate it…
turbo88
  • 423
  • 2
  • 8
  • 23
8
votes
1 answer

If exists then quit VBS

Please take this script into context with my question: If objFSO.FileExists("C:\Windows\Fonts\" & objFile.Name) Then Wscript.Echo "Font already installed: " & objFile.Name I want a VBS script to quit/exit/terminate if X file already…
user3119717
  • 81
  • 1
  • 1
  • 2
8
votes
3 answers

I need to write VBS WScript.Echo output to text or cvs

I am attempting to write a VBScript that will list all of the installed application on a system in a text file or csv. I was able to find an existing code to list all of the software (including name, version, date, and size). When I currently run it…
Skarykid
  • 83
  • 1
  • 1
  • 3
8
votes
5 answers

Checking VBScript syntax

Any good utilities out there for verifying VBScript syntax without actually running the script? What I'm getting at is if I do something like: If (year == "2005" && type == 1) Then ... End If Is there a tool that will tell me that the '&&' really…
Scott Marlowe
  • 7,915
  • 10
  • 45
  • 51
8
votes
3 answers

Is it possible to marry WSH (wscript) with nodejs

As QA I use WSH scripts to do auto upload, deployment and some time Web testing in IE. WSH(wscript) with JavaScript can open IE window, activate it and access DOM model to do some actions or verify some expected results. It is kind of Selenium 1.0…
kirill
  • 95
  • 1
  • 6
8
votes
1 answer

How can I use JScript to create a shortcut that uses "Run as Administrator"

I have a JScript script that runs using cscript.exe. It creates a shortcut on the desktop (and in the start menu) that runs cscript.exe with parameters to run another JScript script. It looks, in relevant part, like this: function…
alficles
  • 1,471
  • 1
  • 15
  • 24
7
votes
1 answer

WScript in VB.NET?

This is a snipet of code from my program: WSHShell = WScript.CreateObject("WScript.Shell") But for some reason, "WScript" is not declared. I know that this code works in VBScript but i'm trying to get it to work with vb.net. Whats going wrong?
user1196604
  • 105
  • 3
  • 4
  • 10
7
votes
2 answers

Alternative to custom protocols (URI schemes)

I have been extensively using a custom protocol on all our internal apps to open any type of document (CAD, CAM, PDF, etc.), to open File Explorer and select a specific file, and to run other applications. Years ago I defined one myprotocol protocol…
stenci
  • 8,290
  • 14
  • 64
  • 104