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

what is this malicious script trying to accomplish?

Sorry if this is not the right place to ask this, please LMK if this question would be suited better somewhere else! I got a particularly interesting piece of junk mail sent to my work email. It is supposedly someone's resume, but it is actually a…
chiliNUT
  • 18,989
  • 14
  • 66
  • 106
4
votes
3 answers

Is using the windows scripting runtime, especially the FileSystemObject thereof a good idea?

Recently I have been asked to do some maintenance on a VB6 application. This involves some file IO. I find the IO operations offered by referencing the windows script host and using the FileSystemObject a lot friendlier than the IO operations that…
Dabblernl
  • 15,831
  • 18
  • 96
  • 148
4
votes
2 answers

Cycle through webpages and copy data

I created this script for a friend that cycles through a real estate website and snags email address for her (for promotion). The site offers them freely, but it's inconvenient to grab one at a time. The first script dumps each pages data into a…
Drivium
  • 537
  • 6
  • 24
4
votes
1 answer

WshShell keystroke multimedia Next Track windows

I have a wscript that sends a keystroke to the active window. I have the codes for keystroke for the following media keys: Vol + (code: &hAF) Vol - (code: &hAE) Prev Track (code: &hB1) Next Track (code: &hB0) (not working) Play/Pause (code:…
papucho
  • 129
  • 6
4
votes
3 answers

Is it harmful to Dim a variable more than once?

This seems like an awfully basic question, but I still can't find an answer for it. In VBScript, is there any harm in declaring the same scalar variable with the Dim statement more than once? I'm working on some related projects and developing some…
afeldspar
  • 1,343
  • 1
  • 11
  • 26
4
votes
2 answers

WScript Sendkey doesn't accept Unicode Characters

I am trying to send char "ä" using WScript Sendkeys.Seems its not working . I found one post Does or Can VBscript's SendKeys support Unicode? My Code: Set sh = WScript.CreateObject("WScript.Shell") sh.Run "notepad.exe", 9 WScript.Sleep 1000 'wait a…
workspace
  • 368
  • 1
  • 6
  • 16
4
votes
4 answers

check if a registry key exists with WScript

im trying to check if a registry key exists and no matter what i try i always get the error message "unable to open registry key for reading" the code im using: keyPath = "HKEY_LOCAL_MACHINE\\SOFTWARE\\BOS\\BOSaNOVA TCP/IP\\Set 1\\Cfg\\Sign…
kisin
  • 177
  • 3
  • 4
  • 13
4
votes
3 answers

In JScript, is it possible to implement getters and setters that look like object properties from the outside?

While trying to port and generally playing around with some non-browser code, I came across getters and setters that looked like normal object properties. Something like this: js> var o = { a: 4, get b(){ return this.a + 3; }, …
hillu
  • 9,423
  • 4
  • 26
  • 30
4
votes
1 answer

Permanent removal of logo in Windows Scripting Host (WSH) scripts

I know two ways to remove the logo permanently. The "official" one: cscript //Nologo //S Will save current command line options for current user. A ftype approach with admin privileges: ftype wsffile="%SystemRoot%\System32\CScript.exe" //nologo…
antonio
  • 10,629
  • 13
  • 68
  • 136
4
votes
1 answer

Redirect output processed via vbscript (cscript) to file

Issue with command output: I am attempting to have a continuous ping report back to a text file. Started with: ping 127.0.0.1 -t >> C:Textping.txt Works great I also want to have timestamps listed before each ping So Wrote: Dim str Do While Not…
user2387022
  • 43
  • 1
  • 1
  • 3
4
votes
4 answers

execute WshShell command from a batch script

I've got a simple question: What's the best way to execute a single WshShell command from a Windows batch (.bat) script? (hopefully it's not creating a new file with VB code)
Oleg Mikheev
  • 17,186
  • 14
  • 73
  • 95
4
votes
1 answer

Cscript. How to make a multi-colored text

I'm trying to get a multi-colored text to the console using Cscript. WScript.Echo('\033[31m' + 'Some Text' + '\033[0m'); This solution does not work. Is there any way to get the multi-colored text to the console?
AndrewC
  • 83
  • 1
  • 5
4
votes
2 answers

Automatically close MsgBox in vbscript?

I am using VBScript to code some automation on excel. I have a MsgBox() within the code, and am looking for a way to close the pop-up window created by MsgBox() automatically without human intervention. Program execution would continue from there.
Arup Rakshit
  • 116,827
  • 30
  • 260
  • 317
4
votes
3 answers

'cscript' is not recognized inside a batch

I need to call a .bat that calls a .vbs. When i run FindDir.vbs from command prompt is ok, but when i try to call it from CallingVbs.bat i got the error message. 'cscript' is not recognized as an internal or external command. The code i'm using to…
Javier Chauvin
  • 133
  • 1
  • 2
  • 10
4
votes
3 answers

How to execute cscript using windows task scheduler?

The problem: When I double click the .bat file it executes as expected. When I schedule it in Windows Task Scheduler it executes except the line that has cscript. Content of .bat file: @echo off cls cscript CSV_To_Excel.vbs c:\tableaudata\test.csv…
Rian Smith
  • 363
  • 2
  • 4
  • 12