wsh

Ping script with loop and save in a txt

谁说我不能喝 提交于 2019-12-11 14:27:01
问题 i try to make an Ping script with vbs. I need a Script, that ping (no ping limit, the program will run all the time) a computername in the network every 2 seconds and save the results in a txt file. For Example: 06/08/2010 - 13:53:22 | The Computer "..." is online 06/08/2010 - 13:53:24 | The Computer "..." is offline Now i try a little bit: strComputer = "TestPC" Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}")._ ExecQuery("select * from Win32_PingStatus where address = '"

How do I print the list of registry keys in HKCU\Environment to SDTOUT using JScript (WSH)?

不想你离开。 提交于 2019-12-11 14:04:20
问题 I want to iterate over the environment keys and print a list of these items. 回答1: You can access the user environment variables via the appropriate WshEnvironment collection; there's no need to mess with the registry: var oShell = new ActiveXObject("WScript.Shell"); var oUserEnv = oShell.Environment("User"); var colVars = new Enumerator(oUserEnv); for(; ! colVars.atEnd(); colVars.moveNext()) { WScript.Echo(colVars.item()); } This script will output the variable names along with values (non

How to set Authentication Methods in IIS programmatically

三世轮回 提交于 2019-12-11 13:27:01
问题 We are working on automating the deployment of some IIS applications. I've used cscript.exe inside a windows batch file to create the web app and such. There are however a few settings currently done by hand that I need to automate. Namely, if you look at the properties of an app, under Directory Structure -> Authentication and access control -> Edit, I need to uncheck Enable anonymous access and check Integrated Windows authentication. Is there an easy way to do this from a windows batch

Handling COM event cancelation in VBScript

折月煮酒 提交于 2019-12-11 10:39:34
问题 I would like to write a script, that sends an E-Mail via our companys SMTP-Server using CDO. First I tried to write an HTA-application for that purpose, but it became rather fiddly to make it cormfortable enough so that other people may handle it well (because of proper recipient resolving). So now I try to use the regular Outlook-Mail mask to prepare the mail first and then catch the send-item event via VBScript to give it's content to my CDO script. Right now, my code looks like this: Dim

How to pass parameters / arguments from one javascript snippet to another, when evaluated

北战南征 提交于 2019-12-11 08:34:32
问题 My goal is to execute a javascript snippet using another javascript snippet using new Function(x1, x2, x3, functionBody) call. My problem appears when i need to pass parameters to the function, this is because functionBody may appear as a new Js script with global declarations and calls. function main() { var a = x1; var b = x2; var c = x3; .... .... } main(); // this is the function that starts the flow of the secondary Js snippets Edit: I have a script responsible for downloading and

What does the two parameters mean for WScript here?

时光怂恿深爱的人放手 提交于 2019-12-11 07:57:57
问题 $WshShell = new COM("WScript.Shell"); $oExec = $WshShell->Run($cmd, 0, false); I don't seem to find the document for this... EDIT Does it need some settings to enable it?I found the above script is not working whether setting the second parameter to true or false 回答1: Run(strCommand, [intWindowStyle], [bWaitOnReturn]) WindowStyle = 0 means "Hides the window and activates another window." WaitOnReturn = false means "the Run method returns immediately after starting the program, automatically

Schedule a .vbs file to run in Windows

非 Y 不嫁゛ 提交于 2019-12-11 06:48:05
问题 I have a VBScript script that starts a cmd prompt, telnets into a device and TFTP's the configuration to a server. It works when I am logged in and run it manually. I would like to automate it with Windows Task Scheduler. Any assistance would be appreciated, here is the VBScript script: set WshShell = WScript.CreateObject("WScript.Shell") WshShell.Run "cmd" WScript.Sleep 100 WshShell.AppActivate "C:\Windows\system32\cmd.exe" WScript.Sleep 300 WshShell.SendKeys "telnet 10.20.70.254{ENTER}"

Cannot retrieve referenced URL

馋奶兔 提交于 2019-12-11 04:01:57
问题 I have JavaScript inside a .wsf file and I'm getting the error: C:\bin\LDLSInfo.wsf(53, 34) Windows Script Host: Cannot retrieve referenced URL: S:\tools\JScript\lib\StandardWSH.js At line 53, it says <script language="JScript" src="S:\tools\JScript\lib\StandardWSH.js"/> I know that LDLSInfo.wsf (the main script) and StandardWSH.js (the script to load) both work fine, because I've ran them from a different machine. It works fine on one machine and not on the other, both are Windows 7 x64

WScript Sendkey doesn't accept Unicode Characters

南笙酒味 提交于 2019-12-11 03:28:31
问题 I am trying to send char "ä" using WScript Sendkeys.Seems its not working . I found one post Does or Can VBscript's SendKeys support Unicode? My Code: Set sh = WScript.CreateObject("WScript.Shell") sh.Run "notepad.exe", 9 WScript.Sleep 1000 'wait a while to load notepad app' sh.SendKeys " äää Hello World!" //buggy line sh.SendKeys "{ENTER}" WScript.Sleep 100' sh.SendKeys "^p" but i am unable to understand the solution. Would be great if you teach me in plain simple code (for solution). I am

Run VBScript using CFExecute throws error but works fine via command line

﹥>﹥吖頭↗ 提交于 2019-12-11 03:19:41
问题 I am trying to run a VBScript but CFExecute throws an error <cfexecute name = "C:\Windows\System32\CScript.exe" arguments = "//NoLogo D:\Excel.vbs D:\test.xls" variable = "data" timeout = "100"> </cfexecute> <cfdump var="#data#"> Error: Error: 424 Source: Microsoft VBScript runtime error Description: Object required But when I run the VBScript with CMD it works fine C:\Windows\System32 > cscript //nologo D:\Excel.vbs D:\test.xls I have full admin access, so why am I getting this error? 回答1: