wsh

Is it possible to add a directory to DLL search path from a batch file or cmd script?

放肆的年华 提交于 2019-12-05 15:26:07
问题 MSDN says that the function SetDllDirectory() can be used to insert a directory into the DLL Search Path. Can this function be accessed from a batch file or cmd script, perhaps using via cscript? The aim is to have our development version of a dll found before a pre-existing older one in %WINDIR% etc. without having to write a program just for that. Thanks in advance for your time and thoughts. 回答1: You can place the DLL in the same path as the executable, which is searched first before

JScript: how to run external command and get output?

China☆狼群 提交于 2019-12-05 09:59:06
I'm running my JScript file using cscript.exe. In the script I need to call an external console command and get the output. Tried: var oShell = WScript.CreateObject("WScript.Shell"); var oExec = oShell.Exec('cmd /c dir'); WScript.Echo("Status "+oExec.Status); WScript.Echo("ProcessID "+oExec.ProcessID); WScript.Echo("ExitCode "+oExec.ExitCode); and var oShell = WScript.CreateObject("WScript.Shell"); var ret = oShell.Run('cmd /c dir', 1 /* SW_SHOWNORMAL */, true /* bWaitOnReturn */); WScript.Echo("ret " + ret); but no luck: the command runs (most likely) without errors but I have no output.

How to open a pdf with WScript.Shell

落爺英雄遲暮 提交于 2019-12-05 08:00:48
问题 I'm creating a HTA application that needs to open PDF document. I cannot assum that the user will have acrobat installed on his PC as in this example The WScript (documentation) allow you to run a command line application. But what I would like, is for the WScript to simulate a double click on the file. I would like to be able to do something like var wshShell = new ActiveXObject("WScript.Shell"); wshShell.Exec(pdfFilePath); // That does not work 回答1: In cmd , you can open a file like this:

Opening a File whose Name Contains a Space

♀尐吖头ヾ 提交于 2019-12-05 05:10:18
I have some simple Excel VBA code that opens non-Excel files like: Sub scriptTest() Set objshell = CreateObject("Wscript.Shell") objshell.Run ("C:\TestFolder\Book1.pdf") Set objshell = Nothing End Sub Running this opens the file in the Acrobat Reader. However if I try to open a file whose name contains a space character like: Sub scriptTest() Set objshell = CreateObject("Wscript.Shell") objshell.Run ("C:\TestFolder\Bo ok1.pdf") Set objshell = Nothing End Sub I get: Both files open fine if I use the Run command from the Windows Start menu. How can I overcome this problem ?? When executing the

Prompt dialog in WSH using JScript?

青春壹個敷衍的年華 提交于 2019-12-05 01:36:40
How to open a prompt dialog box in WSH usig JScript?? The only pop-up dialog I've found in the doc is the WshShell.Popup() method. But I need a way to request the user to enter a string, like the window.prompt() method in DOM. Thanks. I think the WScript object does not provide such a method however you can show an input box from vbscript running on WSH. So here is one possible solution which lets you call that VB function from within JS! Please note the file extension for the following code fragment ".wsf". <!-- Test.wsf --> <job id="InputBoxInJS"> <script language="VBScript"> Function

Get target of Windows .lnk shortcut using “Start in” directory

房东的猫 提交于 2019-12-05 00:57:07
问题 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 IWshShortcut: WshShell shell = new WshShell(); IWshShortcut link = (IWshShortcut)shell.CreateShortcut(lnkFileName); // This returns "C:\Windows\Installer\{F843C6A3-224D-4615-94F8-3C461BD9AEA0}\PaintShopProExeIcon.ico" var targetPath = link.TargetPath; // This

Is it possible to invoke Mathematica's diff functionality from the command line?

狂风中的少年 提交于 2019-12-04 23:32:16
问题 TortoiseSVN (as well as other Tortoise clients) include a script to diff notebook files in Mathematica. Diff functionality for Mathematica is implemented in the AuthorTools package (perhaps there is something better?) The script currently works by creating a small notebook file in the temp directory, and opening it in the front end. The notebook has a big button that will do the diff and has the file names to be diffed hard coded. A disadvantage is that the notebook with the diff code will be

How do I use jQuery in Windows Script Host?

耗尽温柔 提交于 2019-12-04 18:33:51
问题 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 jQuery's many references to the window object. What practical way is there to use jQuery in code that runs without a browser? Update: In response to the comments, I have successfully written JavaScript code to read the contents of files using new

check if a registry key exists with WScript

人走茶凉 提交于 2019-12-04 09:53:35
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 On\\"; try { var shell = new ActiveXObject("WScript.Shell"); var regValue = shell.RegRead(keyPath); shell = null; } catch(err) { } what im missing here? You probably need to remove the trailing slash. If you use that, it will look for the default value for the key you have specified, and if it does not find it, will give that error. Conversely, if you try

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

眉间皱痕 提交于 2019-12-04 07:04:42
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 copied to a text editor, saved as test.vbs and ran. The type command simply outputs the text inside the file passed in. Dim WShell Set WShell = WScript.CreateObject("WScript.Shell") WShell.Run("type C:\inetpub\wwwroot\iisstart.htm") Set WShell = Nothing If you were to run the code in Run() directly from the CMD prompt, it works fine. But when it's run