wsh

Quotes in vbscript string causes wsh invalid url error

I'm trying to get the script below to produce a shortcut like this: "C:\Program Files\Internet Explorer\iexplore.exe" http://WebApp/index.aspx set WshShell = WScript.CreateObject("WScript.Shell") strDesktop = WshShell.SpecialFolders("Desktop") set oUrlLink = WshShell.CreateShortcut(strDesktop & "\WebApp.url") oUrlLink.TargetPath = ...

How can I send an email using a SMTP server using Windows Script?

I am new to Windows scripting. I saw the post on sending email on an Exchange server from WScript here, but my scenario is a little different. We need to be able to send the mail using any SMTP server configured in any of our networks from the Windows Script. Can you please help? IM_IBM ...

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 Windows Script Host (WSH), which can use various scripting languages, but the primary langua...

Manupulating Excel files from Windows Scripting Host

Is there a fast way to manipulate the contents of an existing XLS file from Windows Scripting Host? We have Excel templates we received from a customer. Our task is to fill these templates with the data we fetch from an Oracle database. The current approach is to use Windows Scripting Host and VBScript: Get data from Oracle using ADO...

Setting an environment variable in javascript

How can I set an environment variable in WSH jscript file that calls another program? Here's the reduced test case: envtest.js ---------- var oShell = WScript.CreateObject("WScript.Shell"); var oSysEnv = oShell.Environment("SYSTEM"); oSysEnv("TEST_ENV_VAR") = "TEST_VALUE"; oExec = oShell.Run("envtest.bat", 1, true); envtest.bat ---...

What is the difference between CreateObject and Wscript.CreateObject ?

Does anyone know the reasoning behind having the option using: Wscript.CreateObject("some.object") and CreateObject("some.object") within VBScript? when I find documentation or examples that use Wscript.CreateObject, I usually rewrite using CreateObject, because it always seems to work, and then I can easily reuse the code within a...

Unable to access Excel's Application.ComAddIns property if there are no AddIns installed

This code snipped for the Windows Scripting Host displays the number of COM-AddIns currently installed into Excel. It works fine except for when there are no COM-AddIns installed. I believe it should output a "0", but instead it raises an exception (code 800A03EC). Does anyone know why? test.vbs Set objExcel = CreateObject("Excel.App...

How to run VBScript in Windows NT 4?

I have a VBScript which I am scheduling to run daily on many Windows servers. In Windows 2000 and 2003, the script worked fine as the two OS have csript.exe. However, in Windows NT 4, it does not seem to have this executable. Is there an alternative/option to run the VBScript in Windows NT 4? ...

Accessing Win32 CreateEvent/SetEvent from WSH or other native Windows program

I need to interface with a program suite that uses named. Win32 Events (eg, CreateEvent() API) to communicate between running processes. I'm able to do this with some very simple C code h = CreateEvent(NULL, FALSE, FALSE, argv[1]); if (h != INVALID_HANDLE_VALUE) SetEvent(h); However, due to policy issues, I can't install custom...

Can I pick up environment variables in vbscript WSH script?

Is is possible to read system environment variables in a Windows Scripting Host (WSH) VBS script? (I am writing a VBScript using Windows Scripting Host for task for a Cruise Control and want to pick up the project build URL.) ...

Getting my ip address

Hey! 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 http://www.ip-adress.com/ page and retrieved the ip it gave me. Is there a simpler way? Either using C, ...

How can I create a javascript library in a separate file and "include" it in another?

First, a caveat. The main script is not run in a webpage. I will be running the .js file in Windows using Windows Script Host. The problem: I would like to create a javascript "library" containing a number of objects, each with a number of functions. I expect this library will get rather large with time and would like to keep it in a se...

How to Interact with a program using WSH -Jscript

I am trying to click a button on an application in the systray using WSH. Is this possible? Could somebody provide an example written in Jscript please? THANKS ...

wscript.exe and Task Manager

Is there any way to start foobar.js WSH-script in order that standard Task Manager will display a script process name as foobar.something and not as "wscript.exe"? Thanks in advance. ...

How to manage files and dirs under WSH?

Is it possible to manage files and directories (i.e. get a directory's content, create/copy/delete files, etc.) usig javascript in WSH ? I did a quick look at MSDN and I cant find an object that let me do that. ...

Script to retrieve friendly names of all drivers in Windows Vista Driverstore

I am seeking a way to enumerate all Drivers in the local Driverstore of the workstation and retrieve the "friendly name" that is the Name that the User sees in for instance the add printer dialog. Specifically i would also like to list only a specific class of devices like Printer. If possible vbscript or jscript via Windows Scripting H...

Javascript Object vs JScript Dictionary

Javascript Objects and JScript Dictionary are both associative Arrays obj = new Object ; dic = new ActiveXObject("Scripting.Dictionary") ; My question is... Is there any difference between them in terms of efficiency (either space or time) ?? In terms of functionality, I know a Dictionary is better because it allows more than just sca...

JScript Enumerator and list of properties

Consider the following WSH snippet: var query = GetObject("winmgmts:").ExecQuery("SELECT Name FROM Win32_Printer", "WQL", 0); var e = new Enumerator(query); for ( ; !e.atEnd(); e.moveNext ()) { var p = e.item(); WScript.Echo(p.Name + " (" + p.Status + ")"); } It prints in every line a printer name and the word "undefined" in...

IE8 causing FILE input entry to be blank via SendKeys

Application: HTA (therefore IE) This is an application that uses SendKeys to populate a FILE input field. Issue: File is never uploaded. Description: An offscreen form (invisible to user) uploads a file to the server. The file input is entered via SendKeys (javascript). Appears to be isolated to when IE8 is installed. Does anyo...

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 manifests (also mt.exe is useful). Everything went fine but when i tried to execute my applicati...