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

Which version of JScript does cscript.exe use?

Which version of JScript does cscript.exe use? Does it match any version of Internet Explorer, e.g. IE6?
dimmoborgir
  • 189
  • 1
  • 9
3
votes
1 answer

Why doesn't WScript.Shell.ExpandEnvironmentStrings work with %CD%?

In the command line you can output the current directory using echo %CD% like this this: The Windows Scripting Host provides the ExpandEnvironmentalStrings method which can be used like this: Dim objWshShell : Set objWshShell =…
rory.ap
  • 34,009
  • 10
  • 83
  • 174
3
votes
1 answer

JScript: identifying whether double quotes are passed to a WSH script

There are situations when it is important to identify whether double quotes are passed as arguments to a WSH script. For example because they should be passed to another executable to be run. The standard parsing functions/objects: objArgs =…
antonio
  • 10,629
  • 13
  • 68
  • 136
3
votes
1 answer

Digitally Signing scripts in [VSCODE]

In our environment the two main scripting languages that we use are VBScript/WScript and PowerShell. Our PowerShell is set up so that all scripts have to be digitally signed. Inside the PowerShell ISE we added a menu item that saves the current…
CFo
  • 109
  • 2
  • 13
3
votes
2 answers

Windows Product Key - Different answers from different techniques

Following on from this question (which asks how to retrieve a Windows Product Key), there seems to be conflicting information obtained from the various methods. This question asks why is there a difference when they should all return the same…
3
votes
4 answers

Call python script from vba with wsh

I need to call a python script from vba which works fine by using the shell. Sub CallPythonScript() Call Shell("C:\Program Files (x86)\Python27\python.exe C:\Users\Markus\BrowseDirectory.py") End Sub But when I try using wsh (because of…
Billi B
  • 41
  • 1
  • 4
3
votes
3 answers

How to write a script for organizing my desktop windows? (WinXP)

I would like to write a script that moves the currently open Windows to a certain location. Ideally, my program would look like this: var window = FindWindow("Winamp"); window.setPos(1140, 900, 160, 124); // set x, y, width and height window =…
StackedCrooked
  • 34,653
  • 44
  • 154
  • 278
3
votes
1 answer

How to create a Windows Service from .vbs file?

I have a .vbs file which I execute using cscript. Now that the script is sable; I want to run in background all the time. Hence, I want this .vbs file to run as a service. How do I create (install) it?
vintrojan
  • 1,277
  • 1
  • 12
  • 22
3
votes
3 answers

Running cscript.exe from C# .ashx does not execute code in vbscript file

EDIT I added in some error handling to my .vbs file and it is indeed a permissions issue (I now get a "Permission Denied error"). However, supplying my credentials in the web.config tag does not seem to have any effect. Also when…
Brandon Boone
  • 16,281
  • 4
  • 73
  • 100
3
votes
2 answers

How to Close the CMD prompt window after successfull execution of VBScript

I am invoking a VBScript from another to run as administrator. following is the Invoker VBScript code Set objShell = CreateObject("Shell.Application") objShell.ShellExecute "cscript", "C:\Temp\XYZ.vbs", "", "runas", 0 Wscript.Quit 1 Following is…
3
votes
3 answers

How to run several shortcuts (.lnk files) with a script in Windows?

I’m trying to create a script to run all the tools I use working in a particular project (dor instance, gulp, phpstorm, php server, etc.) I’d like to run shortcuts but not executable files. I can see two possible ways to achieve it in…
zhekaus
  • 3,126
  • 6
  • 23
  • 46
3
votes
1 answer

Get version description of js execution environment

I'm running javascript in the Windows Script Host, so there is no browser involved. How do I identify, from within the script, which version of JavaScript its execution environment, WSH, supports? For those who aren't familiar with WSH, it takes as…
MartynA
  • 30,454
  • 4
  • 32
  • 73
3
votes
1 answer

how to read (Default) value in Registry Key in VBScript/JScript

I can read the value of the key name "UpdateCheck" under HKEY_LOCAL_MACHINE\SOFTWARE\CCleaner\ with Shell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\CCleaner\UpdateCheck") But I cannot read that of the key name "(Default)" .…
tester
  • 31
  • 1
  • 2
3
votes
4 answers

How to check default host for VBScript is WScript or CScript?

I would like to know what is default host for VBScript on particular machine, whether that is set to WScript or CScript ? For example, if I use cscript //h:cscript //s then is there any way I can check host for VBScript is set to cscript? I found…
Magg
  • 103
  • 2
  • 7
3
votes
4 answers

How do i prevent a VBScript from running standalone?

I'm doing a mash between VbScript and CMD, i can call the VBScript easily with cscript.exe //NoLogo "%~dp0TASK.vbs" >>"%~dp0output.txt" But I need to disable the feature of users clicking on the VBScript and calling all sorts of errors, rather than…
Bloodied
  • 1,004
  • 7
  • 20