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
4
votes
4 answers

Hosting WSH (VBScript, JavaScript) in your delphi application?

I'm looking to execute user supplied scripts from my Delphi application. Is it possible to host the Windows Script Host engine in my application and supply it with scripts to execute? Or, is there a better way to approach this problem? P.S I'm not…
James Couvares
  • 1,743
  • 1
  • 16
  • 15
4
votes
1 answer

Should we deploy scrrun.dll (Windows Scripting Runtime)?

Our VB6 application relies heavily on the use of scrrun.dll (Windows Scripting Host). Until a year ago we used to deploy this dll with our installer. Since the Windows Scripitng Host is supposed to be part of Windows we removed the dll from the…
Dabblernl
  • 15,831
  • 18
  • 96
  • 148
3
votes
2 answers

Microsoft.Windows.ActCtx on Windows Xp

These days I'm very much busy on developing an activex/com application. Some of our customers are working under heavily restricted windows environments. So i decided to make my application regfree. I found genman32.exe which can easily create…
user121101
  • 31
  • 2
3
votes
2 answers

Using Javascript in HTA file to read/write from Windows registry

I'm currently attempting to write Javascript in order to read and write from the Windows registry in an HTA file. Here is the current code I am using to write: writeInRegistry = function (sRegEntry, sRegValue) { Regpath =…
Jon
  • 31
  • 1
  • 1
  • 2
3
votes
4 answers

Is there a local runtime environment for running Javascript? (like Windows Scripting Host for JScript)

I wonder if there is a 'local runtime environment' for hosting Javascript code, that's not browser based, for running small local apps? Something like WSH (Windows Scripting Host) for JavaScript (not MS-JScript). I would like to run some javascript…
andora
  • 1,326
  • 1
  • 13
  • 23
3
votes
1 answer

How do you split a 64bit number into high 32 bits and low 32 bits in VBScript?

I've got a 64 bit number in VBScript (WScript) that I want to divide into 32 bit high part and low part. The number is represented as a string (in base 10). The largest supported primitive is a 53 bit double, so I can't do a usual modulus op to get…
Crazy Chenz
  • 12,650
  • 12
  • 50
  • 62
3
votes
1 answer

VBScript passing value by reference (VarPtr) to ActiveX function

I'm trying this: Dim oApp Dim iReturnedResult Set oApp = CreateObject("Some.Application") Set F_Ord = oApp.Documents.Open("Window 1", VarPtr(iReturnedResult)) The ActiveX control expects the second parameter to be a Long by reference. This…
3
votes
2 answers

Use PowerShell to create a shortcut to launch a PowerShell script

I have a need to create a shortcut on a Windows 2019 Server for the Eclipse application so that it runs a PowerShell script instead of opening Eclipse. The script runs a few commands first and then opens the Eclipse application. When I edit an…
L0bst3rGuy
  • 31
  • 1
  • 2
3
votes
2 answers

.bat for batch rename to increment numbers in fname

I have a large folder of .cbr's, and I'm renaming them by issue number to correctly order them. What do I need to include in the ren line to have each file increment the number in the file name via windows command prompt? I'll be doing this…
werdnanoslen
  • 102
  • 4
  • 7
  • 22
3
votes
3 answers

in JavaScript, when finished with an object created via new ActiveXObject, do I need to set it to null?

In a Javascript program that runs within WSH and creates objects, let's say Scripting.FileSystemObject or any arbitrary COM object, do I need to set the variable to null when I'm finished with it? Eg, am I recommended to do this: var fso = new…
Cheeso
  • 189,189
  • 101
  • 473
  • 713
3
votes
2 answers

How to hide cmd.exe and cscript command prompts?

I have a test.cmd file on my desktop. In it contains the following line: cmd.exe /c "cscript foo.js" Is it possible to completely silence/quiet/supress/hide any and all console windows from popping up? I would like to execute the .cmd without any…
Nicole
  • 99
  • 3
  • 7
3
votes
1 answer

Define and call Wscript function inside Javascript file to run in Windows Script Host

I need exactly like I asked in question title. I have a javascript file for calculating Thanksgiving date for every year, provided the year value input. Now I want this javascript to be executable by Windows Script Host and also allowed to create as…
Vicky Dev
  • 1,893
  • 2
  • 27
  • 62
3
votes
2 answers

Is asynchronous call of JavaScript function possible in Windows Script Host?

Imagine you have a simple function in Windows Script Host (JScript) environment: function say(text) { WScript.Sleep(5000); WScript.Echo(text); } Is it possible to call say() asynchronously? Note: Such browser-based methods as setInterval()…
3
votes
3 answers

How to minimize window?

How to minimize window? I am making HTA application and I want replace window title bar with my custom one. I've disabled it by HTA's "caption=no" option and placed my own minimize/maximize/close buttons. I found two ways to minimize…
Levon
  • 189
  • 2
  • 8
3
votes
1 answer

Retrieving a descriptive value for WMI Win32_Processor.Family property instead of an index

The below simple VBS example retrieves CPU caption, architecture and family from WMI: s = "" For Each Item In GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\Root\CIMV2").InstancesOf("Win32_Processor") s = s & "Caption = " &…
omegastripes
  • 12,351
  • 4
  • 45
  • 96