wsh

Code fails on “Application.Match” call, “object required” message

做~自己de王妃 提交于 2019-12-25 07:59:20
问题 Need help, in this line....If IsError(Application.Match(iLine, arr, 0)) Then ... Its runtime error is that an object is required. I've tried a number of different things to solve, but am stuck. Been researching but not finding anything as a resolution. When I try to declare..."Dim arr as variant" it retorts that "Expected end of statement". I am simply clicking on "ProcessCollection.vbs" to run the script. I'm using EditPlus3, and it does highlight "Application" in red text in this line. I've

WSH VBScript switch workSHEET in already open Excel workBOOK

Deadly 提交于 2019-12-25 05:32:15
问题 Is it possible to switch worksheets within a workbook in a WSH VBScript (referenced by name) and if so, how would I do it? This will be used in a script that already opens an Excel file. I want to access a worksheets called "Version Control". The following is how I am opening the workbook: xlsFile = path & "\xml-sitemap.xls" Set objExcel = WScript.CreateObject("Excel.Application") objExcel.Workbooks.open(xlsFile) 回答1: This will do it (amended following Ekkehard.Horner's comment) Dim ws Dim wb

how can I run a script without an extension?

懵懂的女人 提交于 2019-12-25 03:24:38
问题 Say I have a file on my desktop that doesn't have extension, but contains some code (say Batch or VBS). Can I run this code without adding an extension to the file? I was personally thinking about using powershell to pass an extension to wscript.exe, but this turned out to be somewhat impossible. 回答1: For VBS\JS scripts you need to specify engine with //E switch. Examples: If file xxx contains VbScript code: wscript //E:VBScript c:\xxx If file xxx contains JavaScript code: wscript //E:JScript

Equivalent of UNIX `exec` in JScript / Windows Script Host

笑着哭i 提交于 2019-12-25 02:29:32
问题 I've got a .js file that's meant to be executed by Node.js on the command-line. I've got everything set up with npm and such to put the file into the user's path as a "bin". My problem is, because the file ends in .js, running it from the command line is shipping it off to the JScript-based Windows Script Host, instead of node, as expected. I'm trying to write a JScript wrapper, to sit at myprogram.js , be executed by Windows Script Host, and ship off to Node.js. Unfortunately, it doesn't

VBScript and batch file fails when run by Task Scheduler

眉间皱痕 提交于 2019-12-25 02:06:42
问题 I have a VBScript that checks to see if MS Word is running hidden, makes it visible, then hides it again. here is the script code that works fine when I double click the file in Explorer: dim oWord Dim wshShell, btn Set wshShell = WScript.CreateObject("WScript.Shell") set oWord = getobject(, "Word.Application") if isobject(oWord) then on error goto 0 wshShell.Popup "Word is running, making visible", 7, "ALPS Push print", &H0 + &H40 oWord.visible=true wshShell.Popup "MS Word is now visible" &

Undefined property: stdClass::$GetDataResult Error message

雨燕双飞 提交于 2019-12-24 20:20:08
问题 I'm Using PHP Soap Client function to connect Remote service using this code try { $result = $soapClient->GetData($parameters); } catch (SoapFault $fault) { echo "Fault code: {$fault->faultcode}" . NEWLINE; echo "Fault string: {$fault->faultstring}" . NEWLINE; if ($soapClient != null) { $soapClient = null; } exit(); } $soapClient = null; Finally I'm calling this function, echo "Return value: {$result->GetDataResult}" . NEWLINE; But It's not working for me and got warning message like this.

MSGBOX position in WSH/VBS

被刻印的时光 ゝ 提交于 2019-12-24 10:46:29
问题 here is my next question and i hope some one can help me :-) Is it possible to position a msgbox in wsh/vbs? alt text http://www.4freeimagehost.com/uploads/a9b04cde0527.jpg I need the msgbox everytime in the foreground. I know that how to position a inputbox, but not a msgbox. Thanks for help. Greetings, matthias 回答1: You cannot do that with a WSH MsgBox using VBS alone. InputBox is the only build in dialog function that allows you to set a position. You can use a WshShell.Popup and make it

Get default printer remotely

笑着哭i 提交于 2019-12-24 02:17:01
问题 Windows 7: cscript C:\Windows\System32\Printing_Admin_Scripts\en-US\prnmngr.vbs -g Windows XP: cscript C:\windows\system32\prnmngr.vbs -g These will get the default printer of the current system. I was wondering if there is a way to run this on my computer to get the default printer of a remote computer by computer name? I tried running: psexec \\c78572 -i -d cscript C:\Windows\System32\Printing_Admin_Scripts\en-US\prnmngr.vbs -g And it appears to run.. but I only see the results in a quick

Cannot retrieve windows product key using VBA - Automation Error

僤鯓⒐⒋嵵緔 提交于 2019-12-24 01:49:04
问题 The following code throws an 'Automation Error' Sub GetWindowsProductKey() Set WshShell = CreateObject("WScript.Shell") MsgBox WshShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DigitalProductId") End Sub But this code works fine Sub GetPath() Set WshShell = CreateObject("WScript.Shell") MsgBox WshShell.RegRead("HKEY_CURRENT_USER\Environment\Path") End Sub Clearly this has something to do with the product key being protected or something. I'm writing a spreadsheet to collect

Retrieving a descriptive value for WMI Win32_Processor.Family property instead of an index

北战南征 提交于 2019-12-24 01:13:38
问题 The below simple VBS example retrieves CPU caption, architecture and family from WMI: s = "" For Each Item In GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\Root\CIMV2").InstancesOf("Win32_Processor") s = s & "Caption = " & Item.Caption & vbCrLf s = s & "Architecture = " & Item.Architecture & vbCrLf s = s & "Family = " & Item.Family & vbCrLf Next WScript.Echo s The output for me is: Caption = Intel64 Family 6 Model 42 Stepping 7 Architecture = 9 Family = 198 What I want is to