wsh

WScript is undefined

一笑奈何 提交于 2020-01-14 04:59:10
问题 I am trying to run a Javascript file locally, which is supposed to create a CSS image sprite using ImageMagick. It's part of the OpenID selector JS component: http://code.google.com/p/openid-selector/ The generate-sprite.js (http://code.google.com/p/openid-selector/source/browse/trunk/generate-sprite.js?r=140) file is supposed to create the image sprite automatically. However, whenever I run it in IE (the local version of the file, of course), I get the error SCRIPT5009: 'WScript' is

Create a shortcut with parameters added to the program path

纵然是瞬间 提交于 2020-01-11 10:43:49
问题 Here's the code, it works if I right click on the new .Lnk and remove the quotes from "C:\Windows\System32\control.exe /name Microsoft.Windowsupdate" to C:\Windows\System32\control.exe /name Microsoft.Windowsupdate echo off Cls set SCRIPT="%TEMP%\%RANDOM%-%RANDOM%-%RANDOM%-%RANDOM%.vbs" echo Set oWS = WScript.CreateObject("WScript.Shell") >> %SCRIPT% echo sLinkFile = "%USERPROFILE%\Desktop\Weekly Maintenance\Windows Update.lnk" >> %SCRIPT% echo Set oLink = oWS.CreateShortcut(sLinkFile) >>

Create a shortcut with parameters added to the program path

柔情痞子 提交于 2020-01-11 10:42:10
问题 Here's the code, it works if I right click on the new .Lnk and remove the quotes from "C:\Windows\System32\control.exe /name Microsoft.Windowsupdate" to C:\Windows\System32\control.exe /name Microsoft.Windowsupdate echo off Cls set SCRIPT="%TEMP%\%RANDOM%-%RANDOM%-%RANDOM%-%RANDOM%.vbs" echo Set oWS = WScript.CreateObject("WScript.Shell") >> %SCRIPT% echo sLinkFile = "%USERPROFILE%\Desktop\Weekly Maintenance\Windows Update.lnk" >> %SCRIPT% echo Set oLink = oWS.CreateShortcut(sLinkFile) >>

How can I use JScript to create a shortcut that uses “Run as Administrator”

风流意气都作罢 提交于 2020-01-09 10:44:07
问题 I have a JScript script that runs using cscript.exe . It creates a shortcut on the desktop (and in the start menu) that runs cscript.exe with parameters to run another JScript script. It looks, in relevant part, like this: function create_shortcut_at(folder, target_script_folder) { var shell = new ActiveXObject("WScript.Shell"); var shortcut = shell.CreateShortcut(folder + "\\Run The Script.lnk"); shortcut.TargetPath = "cscript"; shortcut.Arguments = "\""+target_script_folder+"\\script.js\"

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

本秂侑毒 提交于 2020-01-06 06:17:10
问题 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 binaries on production machines! Is there a way to do this with Windows Scripting Host? I could possibly get signed binaries added to the production environment - so

'cscript' is not recognized inside a batch

喜你入骨 提交于 2020-01-05 08:34:07
问题 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 call .vbs is the same to .bat and to command prompt. cscript FindDir.vbs Both files are in same folder. I do not understand why cscript command works in command prompt but not in .bat. Could anyone explain me why it happens? Thanks 回答1: By mistake i

Call WCF (.svc) service from VBScript, WScript, VBA, etc with parameters

笑着哭i 提交于 2020-01-05 04:48:28
问题 I've been trying to implement the exmaples provided in the question posted previously below: Calling WCF service by VBScript In my specific scenario I need to pass in a single string variable which will return an array of strings but having little luck. I suspect I'm having a tough time getting the envelope request correct. Below is the wdsl that I'm trying to call. Can you give me an example of how i can call this passing in the parameter and parsing the return array? <?xml version="1.0"

Can I get the return value of Shell.Application's ShellExecute?

让人想犯罪 __ 提交于 2020-01-04 14:05:53
问题 I'm using VBScript to create a UAC prompt for a batch file. I don't know how to get the return value of the UAC prompt. For example if I try to UAC a file that doesn't exist I should get an error, right? For example: Dim rc Set UAC = CreateObject("Shell.Application") rc = UAC.ShellExecute("thisdoesntexist.exe", "", "", "runas", 1) WScript.Echo rc rc doesn't contain a code. Also, is there any way I can get the error code of whatever I'm executing? Is ShellExecute asynchronous in VBScript? 回答1:

How to launch System File Checker tool with vbs

假如想象 提交于 2020-01-03 07:04:46
问题 In batch or cmd, sfc.exe run with a simple command: %windir%\system32\SFC.exe /SCANNOW How to run this command with .vbs script (x86 x64)?? Thanks 回答1: You can do something like this, just give a try ! Option Explicit ' Run as Admin If Not WScript.Arguments.Named.Exists("elevate") Then CreateObject("Shell.Application").ShellExecute WScript.FullName _ , WScript.ScriptFullName & " /elevate", "", "runas", 1 WScript.Quit End If Dim ws,MyCommand,Execution Set ws = createobject("wscript.shell")

sending ctrl+c using sendkeys in ruby

旧时模样 提交于 2020-01-02 16:54:27
问题 I need to close the command prompt window using sendkeys function, but when I used the below code it did not work as running of some betch file is in progress so its not taking these below options. require 'win32ole' system("start cmd.exe") sleep(5) # Create an instance of the Wscript Shell: wsh = WIN32OLE.new('Wscript.Shell') # Try to activate the command window: if wsh.AppActivate('cmd.exe') sleep(1) wsh.SendKeys('cd \\') wsh.SendKeys('{ENTER}') # change the directory path where mtn folder