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
10
votes
2 answers

Using VBScript to find most recent file date in a single folder

How could I modify this VBScript to return only the newest file's name and Last Modified date? Currently it returns anything modified in the last 24 hours. I want to look for the most recent file only. I borrowed this from StackOverflow, not yet…
mikeclemson
  • 147
  • 1
  • 2
  • 7
10
votes
6 answers

Advice for Windows XP Scripting, WSH versus PowerShell

After much experience scripting in the Unix/Linux open-source world, using languages such as Bourne Shell, Perl, Python, and Ruby, I now find myself needing to do some Windows XP administration scripting. It appears that the legacy environment is…
Greg Graham
  • 484
  • 4
  • 11
10
votes
5 answers

Display a message box with a timeout value

The question comes from code like this. Set scriptshell = CreateObject("wscript.shell") Const TIMEOUT_IN_SECS = 60 Select Case scriptshell.popup("Yes or No? leaving this window for 1 min is the same as clicking Yes.", TIMEOUT_IN_SECS, "popup…
Anonymous Type
  • 3,051
  • 2
  • 27
  • 45
10
votes
2 answers

How do I use jQuery in Windows Script Host?

I'm working on some code that needs to parse numerous files that contain fragments of HTML. It seems that jQuery would be very useful for this, but when I try to load jQuery into something like WScript or CScript, it throws an error because of…
Vivian River
  • 31,198
  • 62
  • 198
  • 313
9
votes
1 answer

Getting ActivePython to work with WSH

I've installed ActivePython 2.7.2 and I'm trying to execute a .pys script via the console with wscript/cscript, [i.e. ActivePython (PythonScript with .pys extension) in Microsoft's WSH(Windows Scripting Host)] and when trying with wscript I get…
ldmvcd
  • 968
  • 3
  • 10
  • 15
9
votes
2 answers

Run a vb script using System.Diagnostics.Process but only partially successful in feeding in input text to the process' stdin

Edit: first things first The point of the vbscript is to act like a REPL or command prompt/bash environment, it is simplified to just reprinting the user input So in other words the cscript process should stay alive and the user input for each…
im_chc
  • 1,023
  • 15
  • 24
9
votes
2 answers

What is the %* or $* argument list equivalent for VBScript?

Is there a %* (batch files) or $* (bash script) argument list equivalent for VBScript ? I want to retrieve the exact command line invocation. Contrived example: cscript //nologo script.vbs /arg1:a -s "a b" 1 c /arg2:"x y" "d e" -l '3 4' should…
mvanle
  • 1,847
  • 23
  • 19
9
votes
2 answers

Scripting Git Commands in Windows

I have a few git commands I would like to automate in a restrictive windows environment. I find myself running these same commands over and over, executing in Git Bash. $ git cd "R:/my/directory/repo" $ git pull $ git checkout "MyBranch" $ git…
o.carltonne
  • 365
  • 1
  • 3
  • 13
9
votes
6 answers

Failproof Wait for IE to load

Is there a foolproof way for the script to wait till the Internet explorer is completely loaded? Both oIE.Busy and / or oIE.ReadyState are not working the way they should: Set oIE = CreateObject("InternetExplorer.application") oIE.Visible =…
user3408723
  • 145
  • 1
  • 2
  • 9
9
votes
3 answers

Start excel from Task Scheduler was working, now fails

I've been running my excel 2000 vba program with Task Scheduler and cscript and vbscript for about a year now. A few days ago it stopped working. I can run the program manually. Whenever Task Scheduler starts it, the black window displays for about…
RoseAb
  • 133
  • 1
  • 5
9
votes
7 answers

How to change cscript.exe to wscript.exe execution for all VBScript files?

After installing the new server, I am facing an issue. I have lot of .vbs files, all need to run in wscript, reason, I use all those command like WScript.Echo "hello" I want to be able to see the output when I double click the VBScript file. But…
i need help
  • 2,386
  • 10
  • 54
  • 72
9
votes
3 answers

There's any way to run vbscript directly to wscript or cscript command line

I want to run a vbs command from command line as I would in batch calling cmd.exe /c "echo.Hello World! & pause" Obviously this doesn't work wscript /C MsgBox("Hello world") I could print the vbs and then call the temporary file and then delete…
Vitim.us
  • 20,746
  • 15
  • 92
  • 109
9
votes
2 answers

Create COM/ActiveXObject in C#, use from JScript, with simple event

I'd like to create a COM object in C#, and use it via IDispatch from JScript. That part is pretty simple. I also want to implement simple callbacks on the COM object, similar to the event exposed by the XmlHttpRequest object that is usable in a…
Cheeso
  • 189,189
  • 101
  • 473
  • 713
9
votes
4 answers

How can I save an MSXML2.DomDocument with indenting? (I think it uses MXXMLWriter)

I have an instance of MSXML2.DomDocument. I wave to save it, with indenting. This code works, but does not indent: var dom = new ActiveXObject("MSXML2.DomDocument"); // fiddle with dom here dom.save(filename); I think I can use an MXXMLWriter…
Cheeso
  • 189,189
  • 101
  • 473
  • 713
8
votes
12 answers

Getting my ip address

I have a computer on a small network, so my ip is 192.168.2.100. I am trying to get my real ip. I download the no-ip client but that just seems like a lot of trouble for such a simple thing. I created this php script that got…
AntonioCS
  • 8,335
  • 18
  • 63
  • 92
1 2
3
71 72