vbscript

UTC Time Assignment in VBScript

一个人想着一个人 提交于 2020-06-25 08:39:48
问题 Does anyone have a simple means in VBScript to get the current time in UTC? Thanx, Chris 回答1: I use a simple technique Set dateTime = CreateObject("WbemScripting.SWbemDateTime") dateTime.SetVarDate (now()) wscript.echo "Local Time: " & dateTime wscript.echo "UTC Time: " & dateTime.GetVarDate (false) More info on SWbemDateTime If you wanted to convert UTC back to local time do this: Set dateTime = CreateObject("WbemScripting.SWbemDateTime") dateTime.SetVarDate now(),false REM Where now is the

How to gently close Chrome using CMD or VBS?

天涯浪子 提交于 2020-06-25 06:03:53
问题 I'm having a little problem about closing gently Chrome in order to automatically clean cache. I have a website that is not refreshing correctly, but it does if I clean the cache. For now I have a .bat file with the following code: taskkill /F /IM chrome.exe /T > nul del /q "C:\Users\Francisco\AppData\Local\Google\Chrome\User Data\Default\Cache\*" FOR /D %%p IN ("C:\Users\Francisco\AppData\Local\Google\Chrome\User Data\Default\Cache\*.*") DO rmdir "%%p" /s /q timeout 8 start chrome --restore

GetRef's memory consumption (garbage collection) changed with KB4525236

荒凉一梦 提交于 2020-06-24 22:01:10
问题 We experience out-of-memory issues after installing KB4525236 on our Windows 2016 Servers/Windows 10 Clients. This security fix seems to have changed the moment when memory is garbage collected when calling a function through GetRef . Pré KB4525236 Each instance created in a function called through GetRef got garbage collected as soon as the instance variable was set to nothing Post KB4525236 Each instance created in a function called through GetRef remains in memory and is garbage collected

Replacing text function value input in txt file not work

◇◆丶佛笑我妖孽 提交于 2020-06-23 04:21:09
问题 This is my expiration.txt file : foo1; 2020-03-01 13:33; foo2; 2020-02-01 08:45; foo3; 2020-01-01 11:30; I need open the expiration.txt file and replace the all date value from: 2020-03-01 13:33 to 2020-03-01 2020-02-01 08:45 to 2020-02-01 2020-01-01 11:30 to 2020-01-01 I have tried this code without success, because the replace not working. Const ForReading = 1 Const ForWriting = 2 ' create object set oFSO = CreateObject("Scripting.FileSystemObject") ' open the input file set oInFile = oFSO

What is the best way to iterate through an array in Classic Asp VBScript?

感情迁移 提交于 2020-06-22 13:25:51
问题 In the code below For i = LBound(arr) To UBound(arr) What is the point in asking using LBound ? Surely that is always 0. 回答1: Why not use For Each ? That way you don't need to care what the LBound and UBound are. Dim x, y, z x = Array(1, 2, 3) For Each y In x z = DoSomethingWith(y) Next 回答2: There is a good reason to NOT USE For i = LBound(arr) To UBound(arr) dim arr(10) allocates eleven members of the array, 0 through 10 (assuming the VB6 default Option Base). Many VB6 programmers assume the

Installing .msi remotely without powershell?

本小妞迷上赌 提交于 2020-06-17 06:33:26
问题 We have a multi server system that we need to install at a client site. I would like to put together a script that can: Turn off services on remote machines Uninstall software on several remote machines Install .msi files several remote machines I've struggled with psexec and wmic to do points #2 and #3. It seems like there has to be an easier way without having to resort to PowerShell . 回答1: First, see this thread for WSH Remoting : Remote Install on Windows Server 2012 R2. Then, you can

Installing .msi remotely without powershell?

烂漫一生 提交于 2020-06-17 06:33:13
问题 We have a multi server system that we need to install at a client site. I would like to put together a script that can: Turn off services on remote machines Uninstall software on several remote machines Install .msi files several remote machines I've struggled with psexec and wmic to do points #2 and #3. It seems like there has to be an easier way without having to resort to PowerShell . 回答1: First, see this thread for WSH Remoting : Remote Install on Windows Server 2012 R2. Then, you can

VBS Invalid Query in Windows 10

核能气质少年 提交于 2020-06-17 02:01:31
问题 Why does the following VBS code work in Windows 7 but gives error on Windows 10: strComputer="." Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colProcesses = objWMIService.ExecQuery("Select * from Win32_Process Where Name = 'notepad.exe'") Wscript.Echo colProcesses.Count The error I'm getting in Windows 10 is: test_2.vbs(4,1) SWbemObjectSet: Invalid query What am I doing wrong here? 回答1: Try and use the below code. This

What's the correct way to pass parameters from VBScript to COM interface implemented in C#?

这一生的挚爱 提交于 2020-06-15 18:34:33
问题 I'm trying to expose a fairly simple C# class to COM which should be usable from VBScript (among others). Some objects need to be created via COM calls and will be used in furter calls later on. The definition of the exposed classes and interfaces looks like this: namespace Test { [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)] public interface IComInterface { IFoo CreateFoo(); void UseFoo(int x, IFoo f); } [ClassInterface(ClassInterfaceType.None)] public sealed class CComInterface :

(Number and Number) in VBscript

拥有回忆 提交于 2020-06-14 07:51:48
问题 I have some VB script in classic ASP that looks like this: if (x and y) > 0 then 'do something end if It seems to work like this: (46 and 1) = 0 and (47 and 1) = 1 I don't understand how that works. Can someone explain that? 回答1: It's a Bitwise AND. 47 is 101111 AND 1 is 000001 = 000001 while 46 is 101110 AND 1 is 000001 = 000000 回答2: It's doing a bitwise comparison - Bitwise operations evaluate two integral values in binary (base 2) form. They compare the bits at corresponding positions and