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:

1060 questions
563
votes
21 answers

"rm -rf" equivalent for Windows?

I need a way to recursively delete a folder and its children. Is there a prebuilt tool for this, or do I need to write one? DEL /S doesn't delete directories. DELTREE was removed from Windows 2000+
FlySwat
  • 160,042
  • 69
  • 241
  • 308
126
votes
9 answers

Windows XP or later Windows: How can I run a batch file in the background with no window displayed?

I know I have already answered a similar question (Running Batch File in background when windows boots up), but this time I need to launch a batch: from another batch, without any console window displayed, with all arguments passed to the invisible…
VonC
  • 1,042,979
  • 435
  • 3,649
  • 4,283
86
votes
1 answer

Difference between wscript and cscript

What is the difference between cscript and wscript? Which is best for doing Telnet and FTP automation in Windows?
rashok
  • 10,508
  • 11
  • 76
  • 90
85
votes
5 answers

Can I pass an argument to a VBScript (vbs file launched with cscript)?

I have this script saved in "test.vbs": Set FSO = CreateObject("Scripting.FileSystemObject") Set File = FSO.OpenTextFile(workFolder &"\test.txt", 2, True) File.Write "testing" File.Close Set File = Nothing Set FSO = Nothing Set workFolder =…
Peter
  • 1,443
  • 3
  • 12
  • 9
37
votes
4 answers

How do I set the timezone from command line ?

How can I set the timezone in Windows from command line or from a batch file? Do I need to use powershell or cscript?
Eduard Florinescu
  • 13,721
  • 26
  • 101
  • 164
34
votes
3 answers

how can I check if a file exists?

I want to check to see if a file exists and if it does, I want to open it and read the 1st line, If the file doesn't exist or if the file has no contents then I want to fail silently without letting anyone know that an error occurred.
Cocoa Dev
  • 8,655
  • 29
  • 105
  • 173
30
votes
6 answers

Base64 Encode String in VBScript

I have a web service load driver that's a Windows Script File (WSF), that includes some VBScript and JavaScript files. My web service requires that the incoming message is base64 encoded. I currently have a VBScript function that does this, but it's…
Patrick Cuff
  • 26,370
  • 11
  • 63
  • 93
24
votes
2 answers

How can I download a file with batch file without using any external tools?

First to clarify this question is aimed to HTTP(s) download .For FTP may be I'll ask (and answer) another question. Here are some similar questions - but I want to be more precise . Besides excluding external tools I want the solution(s) to be…
npocmaka
  • 51,748
  • 17
  • 123
  • 166
23
votes
3 answers

What is the ProgId or CLSID for IE9's Javascript engine (code-named "Chakra")

Using .NET, I can write an app that hosts a scripting engine that complies with Microsoft's IActiveScript conventions. This includes JScript and VBScript from Microsoft, and also PerlScript, RubyScript and I don't know what else from third-parties.…
Cheeso
  • 180,104
  • 92
  • 446
  • 681
23
votes
6 answers

Script to make content entry into a text file

How do I include some "text" into a .txt format file without opening the same via a script on Windows?
user358485
  • 243
  • 1
  • 3
  • 10
20
votes
5 answers

Can I pick up environment variables in vbscript WSH script?

Is is possible to read system environment variables in a Windows Scripting Host (WSH) VBS script? (I am writing a VBScript using Windows Scripting Host for task for a Cruise Control and want to pick up the project build URL.)
mike nelson
  • 18,814
  • 13
  • 59
  • 66
20
votes
2 answers

Should we use CScript.exe or WScript.exe to run .vbs files?

VBScript (.vbs) files can be run using either cscript.exe or wscript.exe. What's the difference between these two options?
Pacerier
  • 76,400
  • 86
  • 326
  • 602
18
votes
7 answers

Running Javascript with CScript?

I'm trying to learn how to run Javascript (instead of VBScript) using CScript.exe, but when I try, I get an error: cscript temp.js Input Error: There is no script engine for file extension ".js". I thought this is possible -- any idea what's wrong?
user541686
  • 189,354
  • 112
  • 476
  • 821
18
votes
5 answers

Force a VBS to run using cscript instead of wscript

What is the stackoverflow approved (and hence correct) method to force a VBS to run using cscript instead of wscript - irrespective of what the user tries? A quick Google search shows plenty of examples, but some of them simply don't work and those…
Richard
  • 1,371
  • 7
  • 21
  • 46
17
votes
4 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
1
2 3
70 71