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

How can I package an "external" text file into an elisp module?

I'm writing an elisp module that requires an external text file. For the curious, the module integrates the interactive JS REPL for Cscript.exe with shell mode in emacs. It allows me to run an interactive javascript shell in emacs, on Windows. This…
Cheeso
  • 189,189
  • 101
  • 473
  • 713
5
votes
1 answer

VBScript WScript.Shell Run() - The system cannot find the file specified

I'm trying to write a VBScript (.vbs) script that uses the WScript.Shell Run() method, but it seems as though Run() can't find the file I'm passing in. I've boiled my script down to the following code that will reproduce the results. This can be…
coryvb123
  • 412
  • 1
  • 6
  • 12
5
votes
4 answers

Debugging Javascript in Visual Studio (or other JS debugger)

I have a .js file that normally gets executed by cscript.exe (i.e. is not run in the browser and cannot be run there). I know, that I can feed cscript.exe the //X parameter in order to get asked for a debugger to choose. Ok. That's fine. I select…
eckes
  • 64,417
  • 29
  • 168
  • 201
5
votes
5 answers

How do I get a list of the active IP-addresses, MAC-addresses and NetBIOS names on the LAN?

How do I get a list of the active IP-addresses, MAC-addresses and NetBIOS names on the LAN? I'd like to get NetBIOS name, IP and MAC addresses for every host on the LAN, preferably not having to walk to every single PC and take note of the stuff…
agnul
  • 12,608
  • 14
  • 63
  • 85
5
votes
2 answers

Get line number of an error in JScript run in Windows Script Host

Say, I have the following code that I run as a .JS file using the Windows Script Host: try { ProduceAnError(); } catch(e) { //How to get an error line here? } Is there any way to know the error line where an error (exception) occurred?
ahmd0
  • 16,633
  • 33
  • 137
  • 233
5
votes
3 answers

VBScript set focus on a window in IE

I'm updating an old piece of code that uses VBScript to pull up a window in IE. For some reason, it likes to open up behind IE. Google gave me the following couple lines for setting window focus in VBScript: set WshShell =…
jtpereyda
  • 6,987
  • 10
  • 51
  • 80
5
votes
1 answer

VB: What is missing in scripting host while it is present in "full" VB?

When programming (scripting) in VB scripting host, how can I learn what is implemented and what not? For example, records (or: the structure keyword) are not implemented, but classes (or: the class keyword) isn't. Dim as is not allowed, as…
TheBlastOne
  • 4,291
  • 3
  • 38
  • 72
5
votes
6 answers

How do I check if wscript/cscript runs on x64 host OS?

I'm running a VBScript that may run under x64 Windows. I need to read a registry key from the 32-bit part of the registry. For that I use path HKLM\Software\Wow6432Node\xyz instead of HKLM\Software\xyz. How can I check if the script is executed…
vividos
  • 6,468
  • 9
  • 43
  • 53
5
votes
4 answers

Windows Script Host (jscript): how do i download a binary file?

i'm trying to automate a file download with Windows Script Host (JScript). i see ADODB.Stream has an Open method whose documentation makes it seem like it should be possible to open a HTTP URL and stream the response body: var url =…
just somebody
  • 18,602
  • 6
  • 51
  • 60
5
votes
2 answers

How to create shortcut to Computer on the user's desktop

I am working on a VBScript that is to show the "Computer" icon on the desktop. I've been able to do one for IE using the following code, however as Computer is a "Special Folder" that does not seem to have an actual location I can't use the same…
user3216887
  • 357
  • 1
  • 3
  • 13
5
votes
1 answer

Internet Shortcut IDList value decoding

I have been trying to find any information on a value that is stored in an url shortcut that is generated from MS-Office for SharePoint Libraries. We are moving away from Office 2007 to Office 365 and the feature of 2007 that creates these links…
Toby Leduc
  • 71
  • 4
5
votes
3 answers

Does JScript support string trim method?

Whilst developing a Windows procedure using JScript, it seems that some string methods fail to work. In this example using trim, line 3 generates the runtime error: "Object doesn't support this property or method". My code: strParent = " a …
Andrew Shep
  • 69
  • 1
  • 6
5
votes
0 answers

Get target of Windows .lnk shortcut using "Start in" directory

I am trying to retrieve the target path of a Windows .lnk shortcut, but the "Target" is not an actual file path according to the .lnk file's properties: I am using the IWshRuntimeLibrary and the shortcut object I am accessing is of type…
kreddkrikk
  • 389
  • 3
  • 12
5
votes
7 answers

how can I read a binary file with in javascript (Cscript.exe)?

I think I can't read a binary file with the Scripting.FileSystemObject class. Can I do it with ADODB.Stream? Something else? I want to get an array of bytes. thanks.
Cheeso
  • 189,189
  • 101
  • 473
  • 713
5
votes
5 answers

Write to file using CopyHere without using WScript.Sleep

I've written a small VBScript to creates a .zip file and then copies the contents of a specified folder into that .zip file. I copy the files over one by one for a reason (I know I can do the whole lot at once). However my problem is when I try to…
mlevit
  • 2,676
  • 10
  • 42
  • 50