vbscript

how to add a drop down list in excel using vbs

℡╲_俬逩灬. 提交于 2020-02-04 03:55:14
问题 Hi I am trying to add a drop down in a excel using vbs and i am getting the below error. vbs(18, 15) Microsoft VBScript compilation error: Syntax error I even recorded a marco and used the code from there still it didn't work. Line 18 and col 15 is the line with the add keyword. Range("A1").Select With Selection.Validation .Delete .Add (Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _ xlBetween, Formula1:="=$Q$9:$Q$11") .IgnoreBlank = True .InCellDropdown = True .InputTitle =

how to check if a file exists with vbscript

ε祈祈猫儿з 提交于 2020-02-03 04:32:05
问题 I have a folder with many files. It looks like this file1.txt, newFile1.txt, file2.txt, newFile2.txt, file3.txt, newFile3.txt, file4.txt, newFile4.txt, .... I have a code that generates the newFilei.txt . I want to write a vbscript that checks if a newFile exists in this folder or not. I tried this Set objFolder = FSO.GetFolder("C:\myFolder\") For Each objFile In objFolder.Files fileName=objFile.name If instr(fileName,"newFile*") =1 Then WScript.Echo "new File exist" End If Next but this

Duration vbscript (vbs) function

依然范特西╮ 提交于 2020-02-03 01:43:26
问题 Is there a function to convert a specified number of seconds into a week/day/hour/minute/second time format in vbscript? eg: 969234 seconds = 1wk 4days 5hrs 13mins 54secs 回答1: Dim myDate dim noWeeks dim noDays dim tempWeeks dim pos myDate = DateAdd("s",969234,CDate(0)) tempWeeks = FormatNumber(myDate / 7,10) pos = instr(tempWeeks, ".") if pos > 1 then tempWeeks = left(myDate, pos -1) end if noWeeks = Cint(tempWeeks) noDays = Cint(((myDate / 7) - noWeeks) * 7) wscript.echo noWeeks & "wk " &

VBScript to detect today's modified files in a folder (including subfolders inside it)

会有一股神秘感。 提交于 2020-02-02 15:30:09
问题 I need to get all the modified files inside a folder including the subfolders inside it, and copy them to another folder. How can it be done using VBScript or any other way to achieve this? Thanks in advance, Bibhu 回答1: try this (copy files modified less than 24 hrs ago ) Set objFS = CreateObject("Scripting.FileSystemObject") ''# Directory to scan strFolder = "c:\test" Set objFolder = objFS.GetFolder(strFolder) Go( objFolder) Sub Go(objDIR) If objDIR <> "\System Volume Information" Then For

Detecting USB and Floppy Drives' Letters via VBScript

我只是一个虾纸丫 提交于 2020-02-02 15:20:26
问题 I have a Vb-script which store all removable drives' letters into a variable, As you know it contains both floppy and USB drives, I want to seperate them, I mean I want to store USB Drives' Letters in a variable and Floppy ones into another variable, Here is the script: strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colDisks = objWMIService.ExecQuery _ ("Select * from Win32_LogicalDisk") Removable = ""

Detecting USB and Floppy Drives' Letters via VBScript

余生长醉 提交于 2020-02-02 15:20:12
问题 I have a Vb-script which store all removable drives' letters into a variable, As you know it contains both floppy and USB drives, I want to seperate them, I mean I want to store USB Drives' Letters in a variable and Floppy ones into another variable, Here is the script: strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colDisks = objWMIService.ExecQuery _ ("Select * from Win32_LogicalDisk") Removable = ""

changing owner of subfolders using icacls in a vbscript

倖福魔咒の 提交于 2020-02-02 15:13:23
问题 I have a network with over 700 users and I want to create a script that could change the owner of the home folders to domain admins and the sub-folders to the users themselves. This is what I could create with the help of my colleges, but this doesn't work for some reason. Can anyone help me please. Thanks. Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFile = objFSO.OpenTextFile("G:\Userhome\userdirlist.txt", 1) Set oShell = WScript.CreateObject("WSCript.shell") Do Until

GetRef to capture methods?

与世无争的帅哥 提交于 2020-02-02 05:19:24
问题 I've just discovered VBScript's GetRef function, which gets a reference to the function named by its argument. Is there any way to get a reference to a method in this way? I have a hunch that VBScript doesn't offer the sophistication of binding needed to do so, but it would sure be nice. 回答1: No, GetRef doesn't support class methods. 回答2: There is a workaround for this, see my answer here Here the full sample Const forReading = 1, forWriting = 2, forAppending = 8, CreateFile = True Set my_obj

How to get an HTA application to accept command line arguments?

我的梦境 提交于 2020-02-02 05:02:45
问题 Sub Window_onLoad arrCommands = Split(ITTool.commandLine, chr(34)) For i = 3 to (Ubound(arrCommands) - 1) Step 2 MsgBox arrCommands(i) Next End Sub When I run my HTA application, I get: arrCommands is undefined I am trying to make an HTA app that accepts command line arguments (optional). 回答1: Your script section contains an Option Explicit statement. That makes defining variables before you can use them mandatory. Add a line Dim arrCommands, i to your procedure: Sub Window_onLoad Dim

Send windows key in vbs?

大憨熊 提交于 2020-02-02 03:08:27
问题 I've looked everywhere for this, is it actually possible to do? If you press WIN + LEFT ARROW it will mount your selected window to the left of your screen, and that's exactly what I'm trying to do. I have tried things like: shl.sendkeys "#{LEFT}" Because I found out that # could be for WIN just like + is for Shift and % is for Alt. This may be a stupid question but it would help me out so much. Thank you for you time 回答1: VBScript's SendKeys doesn't support the Windows key. You can use