wsh

DotNet version of Windows Scripting Host

不问归期 提交于 2019-12-11 02:08:42
问题 Good morning, I work in a small shop (only two of us) and we currently manage more .vbs scripts that we would like to (we would like to manage zero). One of the nice things about these scripts is that it's quick to make changes (as necessary) and go back to our day jobs. That's all nice and good until we decide that the job needs to be changed substantially, and then a PITA to develop and debug, mostly because it feels like I'm shooting pool with a baseball bat. Is there a more DotNet-y way

Using HTA in vbscript

拟墨画扇 提交于 2019-12-11 01:24:29
问题 While using HTA userform for VBscript, I found that HTA doesn't support WScript and its objects/methods. Is there any alternate way of creating userform or is thery any way to make HTA support WScript? 回答1: An alternative to WScript.Echo would be to simply add content to the DOM: <script language="vbscript"> dim div: set div = document.getElementById("output") div.innerText = "output" </script> <div id="output"/> or if you want a dialogbox instead, you can use MsgBox() <script language=

How to get the main window handle of a process using JScript?

ぃ、小莉子 提交于 2019-12-10 22:18:30
问题 Is there any method in JScript to get the handle of the main window of a process by providing the process name? The Process.MainWindowHandle property works only in JScript .NET. Is anything similar available in classic JScript? 回答1: I am not sure if this works, just try to loop window.parent until its undefined. something like - var mainWindow = window; while( mainWindow.parent ) { mainWindow = mainWindow.parent; } you also have something like window.top which always returns you the topmost

How to include a JavaScript file in another JavaScript file THAT IS NOT RUN FROM INSIDE A BROWSER? [duplicate]

强颜欢笑 提交于 2019-12-10 22:03:42
问题 This question already has answers here : How to reference a JScript file from another one? (3 answers) Closed 6 years ago . I know that many similar questions have been asked before. The difference in my case is that I am using Windows Scripting Host and am running the script from the DOS command line, not from inside a browser. The only way I can think of doing this is to read the file from the disk as text using fso.OpenTextFile(ThisFile, 1) , and then using the eval function to treat the

How to execute cscript using windows task scheduler?

独自空忆成欢 提交于 2019-12-10 19:56:58
问题 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 c:\tableaudata\test.xlsx echo.file converted >>log.txt What is throwing me off is the fact that log.txt gets created indicating that the .bat file is being executed. But .xlsx is not created. However, on manually double clicking .bat both log.txt

Make an HTA file run as admin (elevated)

大兔子大兔子 提交于 2019-12-10 17:32:23
问题 In wsf, vbs and js files you can easily find out if they run elevated and if not you can easily make them. The code I've written for that is this: EnsureElevatedPrivileges(); WScript.Echo("Running elevated now!"); function EnsureElevatedPrivileges() { if (!WScript.Arguments.Named.Exists("elevate")) { new ActiveXObject("Shell.Application").ShellExecute(WScript.FullName, "\"" + WScript.ScriptFullName + "\" /elevate", "", "runas", 1); WScript.Quit(); } } But this doesn't work in HTA files

Show Message dialog while executing

六眼飞鱼酱① 提交于 2019-12-10 17:07:23
问题 I use this snippet in vbscript: Set WSH = CreateObject("WScript.Shell") cmd = "some command" flag = WSH.Run(cmd, 0, true) As it can be noticed, in .Run() call, "WaitOnReturn" is set to "true" as I want to know when external program finishes and additionally it status Problem is that external program needs some time to finish and I want to pop "Please wait..." MsgBox but I can't this way as I set "WaitOnReturn" on "true" which I need as I need result from that program for additional processing

File permissions with FileSystemObject - CScript.exe says one thing, Classic ASP says another

点点圈 提交于 2019-12-10 13:08:32
问题 I have a classic ASP page - written in JScript - that's using Scripting.FileSystemObject to save files to a network share - and it's not working. ("Permission denied") The ASP page is running under IIS using Windows authentication, with impersonation enabled. If I run the following block of code locally via CScript.exe: var objNet = new ActiveXObject("WScript.Network"); WScript.Echo(objNet.ComputerName); WScript.Echo(objNet.UserName); WScript.Echo(objNet.UserDomain); var fso = new

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

空扰寡人 提交于 2019-12-10 07:53:08
问题 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 "%%1" %%* ftype jsfile="%SystemRoot%\System32\CScript.exe" //nologo "%%1" %%* ftype vbsfile="%SystemRoot%\System32\CScript.exe" //nologo "%%1" %%* Double- % 's are needed only if you use the lines in a batch file. The latter will all users via affect

Setting an environment variable in javascript

喜你入骨 提交于 2019-12-10 04:58:54
问题 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 ----------- set pause I expect to see TEST_ ENV _VAR in the list of variables, but it's not there. What's wrong? edit: If someone can produce a working code sample, I