objFSO.DeleteFile operation does not work
Hi everyone,
I'm trying to delete the temporary internet files in IE's Cache using
some MS code as below but even though the script is correct
objFSO.Delete says file not found.
Any ideas much appreciated.
Const TEMPORARY_INTERNET_FILES = &H20&
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(TEMPORARY_INTERNET_FILES)
Set objFolderItem = objFolder.Self
Wscript.Echo objFolderItem.Path
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set colItems = objFolder.Items
For Each objItem in colItems
' Wscript.Echo objItem.Name
strPath = objFolderItem.Path & "\" & objItem.Name
Wscript.Echo strPath
objFSO.DeleteFile(strPath)
Next Tag: Script para formatear Tag: 210086
Creating Excel Chart Using VBS - Setting Axes
Heres a little history to what im doing. In the abscence of MOM 2005 and the
Availability Management Pack i have written a bit of code, that will query AD
for all server objects and using the Uptime.exe resource kit tool i perform a
query of the returned objects. I then use 'findstr' to pull out the Server
Availability line from the text files and collate these into one text file. I
then open the text file and import it into excel and create a line chart
based on the results. Here lies my problem everything works well apart from i
do not know how to set the Axes for the chart/graph. I have recorded a macro
but i am unable to fathom out how to include the code from the macro into the
vbscript below to set the axes. I need the Axes minimum value to be 0 and the
maximum value to be 100.
The code below is something i pulled from the Microsoft site with a few
modifications.
Id be very greatful if someone could show me how i can achieve setting the
Axes min/max values
' ------------------------------------------------------- Create Chart/Graph
sExcelPath = "C:\GetUptime\Output\Uptime.xls"
' Create Excel Application object
Set xlApp = CreateObject("Excel.Application")
'Show
xlApp.Visible = True
' Create a new workbook
Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlBook.ActiveSheet
'Get data NB Delimited
Set rs = CreateObject("ADODB.Recordset")
Set cn = CreateObject("ADODB.Connection")
xlCategory=1
xlColumns=2
strFolder = "C:\GetUptime\Output\"
strSQL = "Select * From Uptime.txt"
strCon = "Driver={Microsoft Text Driver (*.txt; *.csv)};" & _
"Dbq=" & strFolder & ";" & _
"Extensions=asc,csv,tab,txt;"
cn.Open strCon
rs.Open strSQL, cn
'Fill data into sheet
With xlSheet
For f = 0 To rs.Fields.Count - 1
.Range("A1").Offset(0, f).Formula = rs.Fields(f).Name
Next
i = 0
Do While Not rs.EOF
For j = 0 To rs.Fields.Count - 1
.Range("A1").Offset(i, j).Formula = rs.Fields(j)
Next
i = i + 1
rs.MoveNext
Loop
'Number format
.Range("B:B").NumberFormat = "0.0"
End With
' Create the chart
xlapp.Charts.Add
With xlapp.ActiveChart
.ChartType = 65
.HasTitle = True
.SetSourceData xlSheet.Cells(2, 2).CurrentRegion
.PlotBy = xlColumns ' xlColumns
.Location 1
.HasDataTable = False
.HasLegend = False
With .ChartTitle
.Characters.Text = "Server Availability " & Now
.Font.Size = 12
.Font.Name = "Trebuchet MS"
End With
With .Axes(xlCategory)
.HasTitle = True
With .AxisTitle
.Font.Name = "Trebuchet MS"
.Font.Size = 10
.Characters.Text = "Server"
End With
End With
End With
' Save the spreadsheet and close the workbook.
xlApp.DisplayAlerts = False
xlApp.ActiveWorkbook.SaveAs sExcelPath
' Give the user control of Excel
xlApp.UserControl = True
' Clean Up
Set xlApp = Nothing
WScript.echo " System Uptime Scan Complete." Tag: Script para formatear Tag: 210073
Close Command Prompt upon ping time out ?
Hi
I'm writing a vbscript to shutdown a number of remote computers. After the
script issues the remote shutdown to each computer it opens a Command Prompt
window for each server and runs
ping -t <hostname>
for each server in the list. What I want to be able to do is get the
vbscript to call the Command Prompt and ping the server until a "request
timed out" is returned, where it should then close the Command Prompt window.
Anyone have any ideas ?
Regards Tag: Script para formatear Tag: 210070
How to check subfolders not modifed in last two days?
I have a folder on my local drive which contains lots of subfolders, how can
i write a script which checks for those subfolders which were modified in
last two days and gives me an output in excel file with the list of folders
not modified on last two days. Tag: Script para formatear Tag: 210068
Symantec Live State Recovery Automation Objects and Scripting
I am looking for the syntax for using the automation objects in the
Symantec Backup Exec 6.5 LiveState Recovery software.
The documentation on the CD is "ok" and includes some sample scripts,
but I am looking to create backup jobs that include additional drives
besides the system drives and uses the command file method to run pre-
backup and post-backup scripts.
Everything else works. I just think I'm missing something obvious and
don't get much time to work on this stuff ( I'm working on getting
more time though).
Here's what does work:
Set oVolume = Nothing
For Each oTempVol in v2iAuto.Volumes(false)
If (oTempVol.System) Then
Set oVolume = oTempVol
Exit For
End If
Next
So, that gets me the system volumn (but I'd really like to have the D:
and the C:)
' Step 7: Create an image job
'
Set oImageJob = CreateObject("Symantec.VProRecovery.ImageJob")
oImageJob.DisplayName = "Hx" & "yyyyy" & "svxxxap1 Full Image"
oImageJob.Description = "Hx" & "yyyyy" & "svxxxap1 Full Image"
oImageJob.IncrementalSupport = false
oImageJob.Quota = 7
oImageJob.VerifyImage = 1
oImageJob.RunOnce = false
oImageJob.Compression = oImageJob.Constants.ImageCompressionMedium
oImageJob.Reason = oImageJob.Constants.ImageReasonAutomatic
oImageJob.Volumes = Array(oVolume.ID)
oImageJob.Task = oTask
oImageJob.Location(oVolume.ID) = oLocation
And this creates the image job. This part works.
So, what doesn't work?
Well, I tried to get a handle on d:, so I used:
' Step 6a: Get a handle to D:
Set oFSO = WScript.CreateObject("Scripting.FileSystemObject")
Set oDriveD = oFSO.GetDrive("D:")
That worked.
Then in the object image job, I change oImageJob.Volumes to:
oImageJob.Volumes = Array(oVolume.ID, oDriveD)
But, that did not add D: ( note I did use
WScript.Echo "oDriveD = " & oDriveD.DriveLetter
so that I could verify that fso got the D:, which it did).
And I used
oImageJob.CommandFile(VT_BSTR PREIMAGE) = file1.exe
oImageJob.CommandFile(VT_BSTR POSTSNAP) = file2.exe
oImageJob.CommandFile(VT_BSTR POSTIMAGE) = file3.exe
But this did not add file1.exe etc to the properties of the job.
So, my overall code works 90% and now I'm just trying to get these
last few items.
If anyone's done this or has suggestions, I'm interested.
Thanks. Tag: Script para formatear Tag: 210066
vbscript adodb.connection to windows internal database
Hi,
I wrote some vbscript last spring that queries the wsus 2.0 database
using sqloledb
and generates some csv files.
I'm not sure how to connect to the windows internal database for wsus
3.0 from vbscript using the SQLOLEDB provider. I think windows
internal db is really sql 2005 express embedded edition.
Here's some code that used to work, any advice on what would work for
connecting to sql 2005 express embedded edition?
Set objConnection = CreateObject("ADODB.Connection")
objConnection.ConnectionTimeout = 25
objConnection.Provider = "SQLOLEDB"
objConnection.Properties("Data Source").Value = strComputerName &
"\WSUS"
objConnection.Properties("Integrated Security").Value = "SSPI"
thanks,
Bruce Tag: Script para formatear Tag: 210062
Script to copy a file that is not empty
Hello,
I am looking for a script that will copy a file that is not empty. I would
like for it to determine if the file is empty then if it is to skip to the
end and if it is not empty then copy it to another location.
Thank you for any input. Tag: Script para formatear Tag: 210045
Find newest file in a series of folders
Hello All,
I need to create a VB script that will start in a folder(Team) then walk
the tree and find the newest file based on date modified in each
folder(Project and it's subfolders) The goal here is to provide each team
with a list of their Projects and the latest activity on each project to
help them decide which projects are ready to be archived off our main
server.
Team
Project1
Project2
Project 3
Return results to a .txt file that would look like:
Team Project Newest File
Harry Project1 10/17/2005
Harry Project2 11/25/2006
I'm looking for some Code ideas as well as concepts. I've never been very
good at creating efficient algorithms / searches. Each Project may have up
to 10k files and subfolders 10 + deep.
Thanks in advance
Steve Tag: Script para formatear Tag: 210040
Need Help Refining Script
I'm very new to VBScript. I have a need to list out the employee name and
account name for each user within a specific AD container. The following
link is to an article about a script that I used to get me started.
http://www.microsoft.com/technet/scriptcenter/resources/qanda/aug07/hey0802.mspx
I modified the script only slightly. Specifically, I removed the date
variables, modified the SELECT statement to return the sAMAccountName and
displayName, and to refer to my AD container and tree, and finally I
modified the output in from the Do Until loop. Here is my existing script
(with generic domain info):
***** Start *****
On Error Resume Next
Const ADS_SCOPE_SUBTREE = 2
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.CommandText = _
"SELECT sAMAccountName, displayName FROM
'LDAP://ou=sales,dc=mycompany,dc=com' WHERE objectClass='user' "
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
Wscript.Echo objRecordSet.Fields("sAMAccountName").Value,
objRecordSet.Fields("displayName").Value
objRecordSet.MoveNext
Loop
***** End *****
The only problem is that the script seems to be returning machine accounts
in the results. I though that the objectClass='user' portion of the SELECT
statement would filter out all the noise and leave only the user accounts in
the results set.
Below is an example of the results. The first 3 lines are user accounts and
the last 3 are machine names.
az1853 Bopp, Betty
az2755 Baggins, Bilbo
az8541 Vader, Darth
SALES20$ null
SALES57$ null
SALES58$ null
Can someone tell me why the script is picking up more than just user
accounts?
--Tom Tag: Script para formatear Tag: 210038
script for local group assignments?
Is there a logon/startup script I can run that will assign permissons to
groups on a local pc? Meaning having domain users = powerusers, IT
department = administrators, etc??
Instead of going to all the pcs and setting this up manually. Tag: Script para formatear Tag: 210035
Internet Explorer URLs
Greetings,
Is there a script that will log what you type in the URL in IE 6? But,
I want this script to keep a running tab of all URLs that are beening typed
into IE 6? Is this possible.
Any help is welcomed! Tag: Script para formatear Tag: 210032
Removing ActiveX Components with a Script
This is a cross-post to make sure I get it in the right place.
I have an application upgrade that requires me to remove all related ActiveX
components on about 90 workstations running IE7. I would like to script this
if possible using a batch file or link I can send to the users. Can anyone
tell me how I can use vbscript or similar to perform the required 'remove'
command on the objects in the 'c:\windows\downloaded program files' directory?
Thanks,
Joe Tag: Script para formatear Tag: 210029
Connect to AD from stand-alone computer
Hi all!
How to connect to the AD from stand-alone computer? I've found the
connection string for OLE DB connection (Provider=ADSDSOObject;User
Id=myUsername;Password=myPassword;), however I cannot query the AD - an error
"A referral was returned from the server" is occured after I try to Execute
the command.
Here is my code:
-----
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=ADSDSOObject;User
Id=CN=Administrator,CN=Users,DC=cluster,DC=local;Password=Password;"
Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection
objCommand.CommandText =
"<LDAP://server.domain.tld/dc=domain,dc=tld>;(sAMAccountName=" & strLogin &
");distinguishedName;subtree"
Set objRecordSet = objCommand.Execute
-----
The same code works on member server.
Can anybody help?
--
R.V. Tag: Script para formatear Tag: 210018
HTA to hyperlink to Notepad
I wany to put the following in the HTA <body>
<TABLE><TR><TD><A href=001.txt>001</A></TD><TD><A href=002.txt>002</
A></TD></TR>
</TABLE>
The idea being the user clicks on the link and it brings up Notepad.
>From what I've read I believe something like the following needs to be
in the script.
Set objNotepad = CreateObject("Notepad.Application")
objNotepad.Visible = True
but this gives an Active-X error and even if it didn't give an error I
don't know what to do after that.
Thanks in anticipation
Richard Tag: Script para formatear Tag: 210015
Clearing IE cache with VBS
Hi all, the code below doesn't work. Hope someone has found a solution
out there...
Thanks!
http://www.microsoft.com/technet/scriptcenter/resources/qanda/nov04/hey1102.mspx
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2030885&SiteID=1
Const TEMPORARY_INTERNET_FILES = &H20&
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(TEMPORARY_INTERNET_FILES)
Set objFolderItem = objFolder.Self
strPath = objFolderItem.Path & "\*.*"
Wscript.echo strPath
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFile(strPath) Tag: Script para formatear Tag: 210014
GPO Settings with VBscript in W2K3 R2
Is there anyway to set Group Policy settings with Windows Server 2003
R2? I had to use xcacls in with W2K... but I've noticed with W2K3,
there are a lot more scripting capability available than W2K. I went
to the Script Center repository but all they have are examples dealing
with getting current settings. I want to be able to configure/change/
edit/modify settings.
Suggestions are greatly appreciated.
Thanks! Tag: Script para formatear Tag: 210007
Convert wkix32 script to vbs help!
Hi all,
I'd like to convert the following wkix32 script to vbs, but my vb
scripting skills are pretty non-existent. Can someone please assist?
I'd be most thankful...
=========================================================
SetConsole ("HIDE")
If @LOGONMODE = 1
Quit
EndIf
While ReadValue("HKEY_LOCAL_MACHINE\Software\Cisco Systems\VPN
Client","TunnelEstablished") = 0
Sleep 2
Loop
SetConsole ("SHOW")
SetConsole ("FOREGROUND")
SetConsole ("ALWAYSONTOP")
Use X: "\\mydomain.com\netlogon" /Persistent
SHELL "%COMSPEC% /C X:\mylogonscript.cmd"
Use X: /DEL /Persistent
SetConsole ("HIDE")
=============================================================== Tag: Script para formatear Tag: 210001
Need to add users from a CSV file to a security group
I have a list of existing users in a CSV file, does anyone have a script that
I can use to add those users to an existing security group?
Thanks,
Carlos Tag: Script para formatear Tag: 209996
My vbScript answer to the Google Question. {the first 10 digit prime in e}.com
Rember the google question {the first 10 digit prime in e}.com ?
Here is my vbscript answer which finds the first 10 digit prime in e
in half a second or so (depending upon your hardware).
Note, this code is built for speed rather than readability (or 'write
only code' as we call it here!).
s=Timer()
Dim a(100000)
r=Round(Sqr(100000))
For p=2 To r
While a(p)=True
p=p + 1
Wend
x=p * 2
While x<=100000
a(x)=True
x=x+p
Wend
Next
e="2718281828459045235360287471352662497757247093699959574966967627724076630353547594571382178525166427427466391932003059921817413596629043572900334295260595630738132328627943490763233829880753195251019011573834187930702154089149934884167509244761460668082264800168477411853742345442437107539077744992069551702761838606261331384583000752044933826560297606737113200709328709127443747047230696977209310141692836819025515108657463772111252389784425056953696770785449969967946864454905987931636889230098793"
For p=1 To Len(e)-9
c=Mid(e,p,10)
b=True
For x=2 To 100000
If a(x)=False Then
r=CDbl(c)/CDbl(x)
If r=Round(r) Then
b=False
Exit For
End If
End If
Next
If b=True Then
MsgBox c & " is the first 10 digit prime in e at p:" & p & vbCrLf &
"done in : " & Timer() - s & " seconds"
WScript.Quit
End If
Next Tag: Script para formatear Tag: 209995
Creating an exe from a .vbs script
Hi
I have a .vbs script for enabling Auto Logon into a Windows box which
runs as
c:\>wscript.exe AutoLogo.vbs
I need to create an exe file of the same AutoLogon.vbs file.
Is that possible? If yes, how?
_linuxplorer Tag: Script para formatear Tag: 209985
re: 'Save As' routine
I have used the command workbook.SaveAs = intReturn1, where intReturn1 is
the value returned from an input box allowing a user to save an Excel
workbook under the name they wish.
Does anyone know of the instructions necessary to inform a user that a file
already exists in that location, and that they need to save it under a
different name?
--
Charles Dean Tag: Script para formatear Tag: 209984
.vbs script for IIS 6.0 and ISAPI Filter
I am trying to write a .vbs script to create an ISAPI filter within the
default website. From what I can tell, setting an ISAPI filter via .vbs
requires knowledge of using arrays.
Can anybody help on how to accomplish this type of task with either same
code or links to MSDN/Technet, etc?
I also need to set an application mapping within the default website as well
if anybody has any feedback for this.
I tried to use the built-in iisconf.vbs script to copy the metabase from
source computer to target computer but it seems like I cannot get rid of
machine specific settings when using the iisconf.vbs script
Thanks - Tag: Script para formatear Tag: 209977
vbscript & database access
I am a newbie when comes to trying vbscript & database access (via
ODBC or ADO).
So where does one start? Does this require HTA scripting, or can this
be done directly with vbs? I am a developer who is profficient with
vbs and understanding code. Where is a good place to start?
Thanks Tag: Script para formatear Tag: 209974
VBS like a Service
Hi,
I don't know how can explain...
Can I start a vbs like a service?
I have a vbs that generate a txt and I have to run it every 10min. Can I put
it in "Windows Services"?
I don't want to schedule this execution.
How can I do this
--
Rodrigo Ferreira
Regards from Brazil
Sorry for my poor english Tag: Script para formatear Tag: 209966
Need a filtered select box
In Outlook Express, you can get to a list of all available newsgroups for
any of your newsgroup accounts by hitting Control-W or clicking the
newsgroups item from the tools menu. At the top of that Newsgroup
Subscriptions window is a box in which to type some text; when you do, the
main window immediaely displays newsgroups with that text anywhere in their
name, thus giving you a more focused list to choose from.
Does anyone have code to share which can do something similar in a web page
or HTA? I'm thinking it could be implimented by having a 'filter' input
box, an array of all potential items to be shown, and a select box. Each
time the user changes the filter, a regular expression extracts a matches
collection from the join of an array of potential items, and and those
matches are put in the select box. Maybe there is an object with this kind
of filtering built into WXP.
I hate to start these little vast projects with half vast plans.
Any ideas or links to sample script?
-Paul Randall Tag: Script para formatear Tag: 209959
Help needed: Very odd VB Script behavior
I have a web page with a vbscript section that looks like
Sub Window_Onload()
msgbox("Here")
call getprojmonths(intProjNum,0)
End Sub
getprojmonths is a javascript function being called from a vbscript
sub to provide ajax functionality and yes, it works.
Here's the odd part: if I take out the msgbox the call does not get
made. Furthermore, if I put another vbscript statement between the
msgbox and js call it won't work; the js call must immediately follow
the msgbox.
I'm working on rewriting the js as vbscript but I am still curious why
I have to execute a msgbox to get the js call to work.
I'd love to hear why it behaves this way if anyone knows. Tag: Script para formatear Tag: 209957
re: Path Location dialogue box & ammendment to 'Save As' instruction
This post consists of two questions:
1) I have used the command workbook.SaveAs = intReturn1, where intReturn1 is
the value returned from an input box allowing a user to save an Excel
workbook under the name they wish.
Could somebody post the instructions necessary to inform a user that a file
already exists in that location, and that they need to save it under a
different name.
2) The default save location is My Documents. What instructions do I need
to create a dialogue box which allows a user to choose another save location?
Thanks
--
Charles Dean Tag: Script para formatear Tag: 209944
Who Has Permission on shared folders?
I would like to have a list with the following information:
foldername; username; rights
I tried powershell and cacls, but they both don't repeat the username on
each line, so I have to reprocess the output.
I'm a newbie to scripting, but I would appriciate any help that can generate
this kind of information. Tag: Script para formatear Tag: 209942
Command line in vbs script
Hi looking for a bit of help, tried a few things but cant get it to
work, i am trying to run the following DOS command line from a VBS
script.
printmig -b "\\servername\file.cab" \\server1
Tried various ways but no luck can anyone help ?
Thanks Tag: Script para formatear Tag: 209939
Cannot call ActiveX component function from VBScript
I am trying to call ActiveX function which resides on a client
computer from vbscript or javascript. I developed a simple Visual C++
2005 ActiveX component (ocx file) with one exported method which
returns int value. When I try to call this method from VB, everything
works fine and I get the value that method should return.
The ActiveX component was registered on the client computer with
regsvr32. I tried in two ways to call the ocx method from javascript:
- with new ActiveXObject("progID"), where the progID was found in the
registry,
- with <object classid="clsid:xxxxxxx" id="xx">, and classid was also
found in the registry.
VBscript makes the object, but cannot call the ocx method. An error
"Object doesn't support this property or method" appears on the web
page.
At Internet Explorer options I enabled all activex objects both in
Internet and intranet zone.
I looked for some kind of solution everywhere, but didn't succeed. I
am blocked at two lines of code for a week. The code of html page with
vbscript follows. Thanks for any kind of help.
<HTML>
<HEAD>
<TITLE></TITLE>
<SCRIPT language="vbscript">
Sub callTest
document.write(a.test())
End Sub
</SCRIPT>
</HEAD>
<BODY>
<OBJECT id="a" classid="CLSID:A2733628-A334-4207-83F1-F00198758EFF"
name="a" ></OBJECT>
<INPUT TYPE=button value="Test" onClick="callTest">
</BODY>
</HTML> Tag: Script para formatear Tag: 209936
owner propety on files
I have a script that works. I am sure there is a better way to do it.
I am outputing the file properties for all files in a specified directory to
an excel file. I can not figure out a way to include the owner property. I
found something that does pull owner information - it also pulls alot of
information i don't want and i have no idea how to integrate it into my
existing script.
Below i pasted both the script that pulls owner property and my existing
script. Any help getting getting the "existing script" to pull the ower
property is appreciated.
***********************
' pulls info on owners and extras
Dim arrHeaders(34)
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace("C:\Scripts")
For i = 0 to 33
arrHeaders(i) = objFolder.GetDetailsOf(objFolder.Items, i)
Next
For Each strFileName in objFolder.Items
For i = 0 to 33
Wscript.Echo i & vbtab & arrHeaders(i) _
& ": " & objFolder.GetDetailsOf(strFileName, i)
Next
Next
***************************
'Existing script
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colFileList = objWMIService.ExecQuery _
("ASSOCIATORS OF {Win32_Directory.Name='H:\scripts'} Where " _
& "ResultClass = CIM_DataFile")
i = 2
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
'open spreadsheet
Set objWorkbook = objExcel.Workbooks.Open("h:\spreadsheet.xls")
Set objWorksheet = objWorkbook.Worksheets(1)
objExcel.Cells(1, 1).Value = "File Name"
objExcel.Cells(1, 2).Value = "File Path"
objExcel.Cells(1, 3).Value = "File Size in Bytes"
objExcel.Cells(1, 4).Value = "Date Created"
objExcel.Cells(1, 5).Value = "Last Accessed"
objExcel.Cells(1, 6).Value = "Last Modified"
objExcel.Cells(1, 1).Font.Bold = TRUE
objExcel.Cells(1, 2).Font.Bold = TRUE
objExcel.Cells(1, 3).Font.Bold = TRUE
objExcel.Cells(1, 4).Font.Bold = TRUE
objExcel.Cells(1, 5).Font.Bold = TRUE
objExcel.Cells(1, 6).Font.Bold = TRUE
For Each objItem In colFileList
objworksheet.cells(i, 1).Value = objItem.FileName
objWorksheet.cells(i, 2).value = objItem.Description
objWorksheet.cells(i, 3).value = objItem.FileSize
objWorksheet.cells(i, 4).value = WMIDateStringToDate(objItem.CreationDate)
objWorksheet.cells(i, 5).value = WMIDateStringToDate(objItem.LastAccessed)
objWorksheet.cells(i, 6).value = WMIDateStringToDate(objItem.LastModified)
i = i + 1
Next
Function WMIDateStringToDate(dtmDate)
WScript.Echo dtm:
WMIDateStringToDate = CDate(Mid(dtmDate,5,2) & "/" & _
Mid(dtmDate,7,2) & "/" & Left(dtmDate, 4) _
& " " & Mid (dtmDate,9,2) & ":" & Mid(dtmDate,11,2) & ":" &
Mid(dtmDate,13,2))
End Function
Dim arrHeaders(34)
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace("H:\DoubleTake\scripts")
For j = 0 to 33
arrHeaders(i) = objFolder.GetDetailsOf(objFolder.Items, j)
Next
For Each strFileName in objFolder.Items
For j = 0 to 33
Wscript.Echo i & vbtab & arrHeaders(j) _
& ": " & objFolder.GetDetailsOf(strFileName, j)
Next
Next Tag: Script para formatear Tag: 209922
Get Error Description from Number
Am I correct that VBScript does not support Error()? And that if you don't
capture the value of Err.Description that your SOL when it come to needing a
get the description of an error when you only have the code. Tag: Script para formatear Tag: 209918
vista indexing progress?
Hey all. Anyone know how to read vista's indexing progress via
vbscript? I want something that I can show our techs after a pc build
so they dont give the machine to a user before indexing is %100. Tag: Script para formatear Tag: 209911
Naked windows
Hi gang! It's been a while - hope everyone has been well.
So my interest today is um, ahem, well let's just say I want a window
without all its dressings.
Specifically, I would like to make use of IE's window.setTimeout
functionality. And I have no problem with that, it works
fantastically well. However, it occurred to me that I can perhaps
avoid several lines of initialization code. So instead of doing:
Set ie = CreateObject("InternetExplorer.Application")
ie.Navigate2 "about:blank"
While ie.ReadyState<>4: Wscript.Sleep 10: Wend
Set Win = ie.document.parentWindow
'Now I can use Win.setTimeout
perhaps I could go directly to:
Set Win = CreateObject("WhatGoesHere")
Any tips?
Csaba Gabor from Vienna Tag: Script para formatear Tag: 209905
Adding IP printer with VBScript problem
This is the code I'm using to add my IP printer through a script but
only seems to add the port and not the printer to the machine. Can
anyone tell what would keep the printer from getting added to the
computer?
strComputer = "."
'= strComputer can be an array of netbios computer names or =
'= ip addresses put into a for loop =
Public Error
Dim Count:Count=0
Set WshShell = WScript.CreateObject("WScript.Shell")
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root
\cimv2")
Dim IPArray
'= here is where your editing skills happen! =
IPArray = Array( "172.17.20.136")
Dim PrintersArray
'= here is where your editing skills happen again ! =
PrintersArray=Array("c:\hpc2800d.inf")
'= here is where you edit the printer names =
Dim PrinterNames
PrinterNames=Array("HP Color LaserJet 2800 (Remote Office)")
For n = LBound(IPArray) To UBound(IPArray)
'Install the IP printer ports
Install_IP_Ports IPArray(n)
Next
For n = LBound(IPArray) To UBound(IPArray)
Count = Count + 1 'just increments the counter for the message at the
end!
'= Add the printers (Arguments: ip port, path to the .inf files,
printer name) =
'= get the name from the inf files or make one up! =
Add_local_ip_printer IPArray(n), PrintersArray(n), PrinterNames(n)
Next
Make_Default_printer PrinterNames(0)
'= if only one printer in array set to zero e.g. PrinterNames(0) or
comment out!=
'Install the TCP/IP Port(s):
Function Install_IP_Ports(strIPAddress)
Set objNewPort =
objWMIService.Get("Win32_TCPIPPrinterPort").SpawnInstance_
objNewPort.Name = strIPAddress
objNewPort.Protocol = 1
objNewPort.HostAddress = strIPAddress
objNewPort.PortNumber = "9100"
'objNewPort.Queue = "LPT1_PASSTHRU"
objNewPort.SNMPCommunity = "public"
objNewPort.SNMPEnabled = False
objNewPort.Put_
'stop the spooler
Set colServiceList = objWMIService.ExecQuery _
("Select * from Win32_Service where Name='Spooler'")
For Each objService In colServiceList
errReturn = objService.StopService()
WScript.Sleep 100
Next
'start the spooler
For Each objService In colServiceList
errReturn = objService.StartService()
WScript.Sleep 100
Next
End Function
Function
Add_local_ip_printer(strIP,strPath_To_Inf_Files,strPrintername)
WSHShell.run ("CMD.EXE /C RUNDLL32 PRINTUI.DLL,PrintUIEntry /if /b "_
& chr(34) & strPrinterName & chr(34) &" /f " & chr(34) _
& strPath_To_Inf_Files & chr(34) & " /r " & chr(34) _
& strIP & chr(34) & " /m " & chr(34) & strPrinterName & chr(34) _
& " /q /u"),0,true
End Function
Function Make_Default_printer(strPrinterName)
Set colInstalledPrinters = objWMIService.ExecQuery _
("Select * from Win32_Printer")
For Each objPrinter in colInstalledPrinters
If objPrinter.Name = strPrinterName Then
objPrinter.SetDefaultPrinter()
End If
Next
End Function
Wscript.echo "Script Completed " & count & " Printers Added"
'End Script Tag: Script para formatear Tag: 209897
EFS, Active Setup and Desktop Folder
I have a requirement to Encrypt the Desktop Folder. Since it is Locked Open
I cannot do so via normal mechanisms. I have written a VB script that I run
during Active Setup to mark the Folder for encryption and to Encrypt its
files and sub-Folders. The script works about 70% of the time. The result
is that the Files under Desktop get encrypted at the time the script runs,
but the Desktop Folder itslef does not have the attribute set. So new Files
added to the Desktop Folder are not encrypted. Is there some sample code out
there to help me on my way? I need to prevent the Desktop Folder from
getting locked, then Mark it for Encryption, then continue on with the user
login process. I thought Active Sertup would do this, but apparently, it
doesn't seem to work every time. I am hoping there is something explicit I
can do in my code to handle this. Thanks for your help. Tag: Script para formatear Tag: 209894
Regular Expression Help Required
I have downloaded the below code from Microsoft site and modified as per my
requirment. The problem here is the script after matching the first pattern
(837139231DDA)it will write data of that line to an excel file then
immedielty it starts searching for the next pattern without writing the
subsequent line before the next match.
I have another 4 lines between the first match & the second match which is
not getting written to the excel file. Could any one tell me where i am
wrong..
Any help would be great appreciated.
Input file
----------------------------
837139231DDA 3 01 ADD DATE PLACED-- 240807
DATE TO EXPIRE 230809 CIX0044 08/24 13.17 A04NM540
LO SERIAL# HI
SERIAL#
LO AMT HI AMT
CHARGE CODE Y
PAYEE
HUY NGUYEN
SPECIAL COMMENTS
SPECIAL COMMENTS
PH: (07)
837139231DDA 3 01 CHG DATE PLACED-- 240807
DATE TO EXPIRE 230809 CIX0044 08/24 13.17 A04NM540
LO SERIAL# HI
SERIAL#
LO AMT HI AMT
RESTRAINT REASON
DATE NOT PROVIDED
----------------------------
Cod
------------------------------------------------------------------------------------
Const ForReading = 1
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.Workbooks.Add
x = 1
Set objRegEx = CreateObject("VBScript.RegExp")
objRegEx.Global = True
objRegEx.Pattern = "^[1-9]........DDA"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\Script\Test.txt", ForReading)
'Do while objFile.AtEndOfStream
Do Until objFile.AtEndOfStream
strSearchString = objFile.ReadLine
Set colMatches = objRegEx.Execute(strSearchString)
If colMatches.Count > 0 Then
For Each strMatch in colMatches
objExcel.Cells(x, 1) =strSearchString
x = x + 1
Next
End If
Loop
objFile.Clos
----------------------------------------------------------------------------------- Tag: Script para formatear Tag: 209890
Accessing the contents of HTA dataarea after update.
I'm trying to access the values of checkboxes that I've passed through
to an HTML page in a script.
A simple example that displays filenames but does not return the
values is:
<html><head>
<title>HTA Test</title>
<HTA:APPLICATION
APPLICATIONNAME="HTA Test"
SCROLL="yes"
SINGLEINSTANCE="yes">
<script language="VBScript">
Set fso = CreateObject("Scripting.FileSystemObject")
Sub GetFiles
onlinepath = "T:\Testing"
topline = "<Table cellpadding=0 cellspacing=0><TR><TD>File Name</
TD><TD align=center width=240>File OK??</TD></TR>"
Set objFolder = fso.GetFolder(onlinepath)
linenum=1
For each objFile in objFolder.Files
fileis = onlinepath & "/" & objFile.name
filelist = filelist & "<TR><TD>" & fileis & "</TD><TD
align=center><input type=""checkbox""" & checked & " name=""TickBox"
& linenum & """></TD></TR>"
Next
filelist = topline & filelist
DataArea.InnerHTML = filelist
End Sub
Sub TestSub
Set TickBox1 = window.event.srcelement
MsgBox TickBox1.Value
End Sub
</script>
</head>
<body onload="GetFiles">
<Form>
<span id = "DataArea"></span>
<input type="button" value=button value="run" name="run_button"
onClick="TestSub"><p>
</TABLE>
</FORM>
</body></html>
How do I access the values of the checkboxes in TestSub?
Regards,
Richard Tag: Script para formatear Tag: 209885
Path not found error using FSO GetFolder
Hi
I'm using a script to get a list of folders (and subfolders) for a UNC path
but I noticed that if the script tries to get hold of a subfolder path that
is too long to display then it ends with 'Path Not Found' - so the script is
:
Set objFSO = CreateObject("Scripting.FileSystemObject")
objStartFolder = "\\server4\files"
Set objFolder = objFSO.GetFolder(objStartFolder)
Wscript.Echo objFolder.Path
Wscript.Echo
ShowSubfolders objFSO.GetFolder(objStartFolder)
Sub ShowSubFolders(Folder)
For Each Subfolder in Folder.SubFolders
Wscript.Echo Subfolder.Path
Set objFolder = objFSO.GetFolder(Subfolder.Path)
Wscript.Echo
ShowSubFolders Subfolder
Next
End Sub
If I add 'On Error Resume Nex't at the top, then it doesn't display the
error but the script just exits on the problem path again and won't go any
further. I unfortunately don't have the means to change the path structure
and make them smaller or use mapped drive etc. What I effectively need is
the script to ignore any paths that cause a problem and just carry on with
the next.
Is there any other way of getting round this?
Thanks
John Tag: Script para formatear Tag: 209879
Unlocking locked local accounts
Hi there, hope someone can help me
I know there are other issues, but short-term this is the problem!!
I have a number of users locking accounts by incorrectly passing
credentials to a server. I need to be able to periodically sweep for
these locked accounts and unlock them - these are all local accounts.
I have found a number of ways to identify them, but cannot find a way
to unlock them!
For example
ComputerName = localhost
winmgmt1 = "winmgmts:{impersonationLevel=impersonate}!//"&
ComputerName &""
Set UserSet = GetObject( winmgmt1 ).InstancesOf ("Win32_UserAccount")
for each User in UserSet
if user.lockout = "True" then
---what should go here???
end if
next
Finds me the locked accounts, though seems to add some domain accounts
too....
Code below finds only local accounts and gives me details, but how do
I check and fix locked this way?
strComputer = "bob"
Set colAccounts = GetObject("WinNT://" & strComputer & "")
colAccounts.Filter = Array("user")
For Each objUser In colAccounts
Set objUser = GetObject("WinNT://" & strComputer & "/" &
objuser.name)
Wscript.Echo objUser.Name
Next
If it is easier, I do have powershell on this machine as welll
Regards and thanks
Ross Carr Tag: Script para formatear Tag: 209876
Avoid loading images - Avoid sounds
Hello,
I'm writing automation scripts in VBA and VBS to use IE6 to retrieve
data from web sites.
I create an instance of IE (or sometimes connect to one instance
already open) and send it commands to navigate to URLs, and retrieve
the data contained in tables etc.
My questions (so far) are:
1) How do I avoid the loading of images? (Ideally the user should be
able to browse normally while my script runs, this means: if the
solutions involves the "display images" option, can it be set to OFF
in one instance without affecting other IE instances?)
2) How to disable the clicking that happens when IE starts navigation?
(again, disabling it in Control Panel shouldn't affect other
instances, ideally)
Thanks in advance
Chris Tag: Script para formatear Tag: 209865
& and +
hi all
what's the difference between the ampersand and the plus charcters as
cocatenators?
ex
"hello " & "world"
"hello " + "world" Tag: Script para formatear Tag: 209864
Windows 2000 bsod script to prevent or detect bad hard drive
At work we have several pc's that use windows 2000 professional for vision
systems, and for some reason when we have to shut down our sub-stations
invertently one of our pc's gets the bsod and upon restarting the pc's say
that the system file is corrupt. We have about 100 pc's and it wouldn't be
very possible to physically go around and shut off all the pc's as this
would require too much manpower and it would be less expensive to just
replace the pc and replace the hard drive and ghost the new one for later
use.
Is it possible to write a script to scan the hard drives while the pc still
runs normally so we could first prevent the problem and hopefully mark the
bad sectors as bad as to possibly prolong the life of the drives, and also
to let us know that we need to put it on a schedule to change out the drive.
Also if shutting down the pc's in this manner, (Shutting Power Off) maybe
make a script that would automatically shut down all the pc's.
I have never used vbscript but I've heard that such scripting is possible
using it.
Dave Marden Tag: Script para formatear Tag: 209840
Trouble with xcacls in usercreation
Hi -
I have made a user-creation script (by taking bits and pieces from
various sources, which works nicely, except for one thing - this code
creates the homefolders nicely, but doesn't apply the right security
settings:
objFSO.CreateFolder "\\SERVER\data$\" & strUserName
strFolder = "\\SERVER\data$\" & strUserName
strXcacls = "Xcacls " & strFolder & " /C /P system:f ""Domain
Admins"":f " & strUserName & ":M /Y"
WshShell.Run strXcacls, 0
It doesn't give any errormessages when run. Can anybody see what I have
missed?
Additionally, I forgot to assign logon-script to some of the groups of
accounts I created - anybody know of a way to assign a logon-script for
accounts that doesn't have one?
Kind regards Tag: Script para formatear Tag: 209837
Declaring Arrays for use with Split()
I'm very much in the habit of Dim-ing all of my variables and would like be
able to explicitly Dim an array for use with Split(), however its giving me a
'Type Mismatch' error when I try to Dim it.
Dim prefArray(2)
prefArray = split(objFile.ReadLine, chr(9))
The line being read will only, ever have one tab return and thus the line
will only be broken into two values. Tag: Script para formatear Tag: 209833
Help with RegExp
I need help with the following 3 regular expressions:
1. Using the regexp pattern "^(?:[AUT]\d{5}(?:,|$))+$" the following string
is valid:
A12345,A23456,U45678,U12375,T12345,U87456. How would I have to modify the
pattern to allow for a maximum of 5 values e.g.
A12345,A23456,U45678,U12375,T12345?
2. Which pattern do I have to use to validate the following string, e.g.:
1001,5458,3112
Valid numbers are between 1000 and 9999. Each number needs to be separated
with a comma. The string can only contain a maximum of 10 numbers.
3. Which pattern do I have to use to validate the following string, e.g.:
2007
Valid numbers are between 2000 and 2020. Only 1 number is allowed.
TIA
Pete Tag: Script para formatear Tag: 209830
VBScript - String - first letters to Uppercase
Hello,
Can anyone please help me with a function that takes a string, a name,
and makes all the first letters Uppercase?
Actually I can already kinda do the above but I'm stuck on initials eg
if I get...
"j.earl jones a.watson" I would like to make that "J.Earl Jones
A.Watson"
and of course if I get just "a.watson" turn that into "A.Watson"
or simply change "james" to "James" and "james watson" to James
Watson.
Basically all the 1st letters unless there is a "." in which case the
first letter also after the "."
It would also be nice to put some kind of a check in case I get
"j.earl." and there is nothing after the "." then leave it.
Thank you in advance :-)
Yas Tag: Script para formatear Tag: 209829
re: VBScript and Internet Explorer
Could somebody give me a hand with writing a script whereby an Internet
Explorer window can be used to browse a series of pictures, as if browsing
them on a website?
I have the code for creating an IE window, but don't know how to put images
on different pages within that window. It would be great to use the
backwards and forwards arrow buttons to browse these images, if that is
possible.
--
Charles Dean Tag: Script para formatear Tag: 209823
Mapped disk list
We have a script which executes at users logon which should write to a file
the list of user's mapped disks.
If the user has administrative rights on the client it works , for normal
users it doesn't .
The problem is that it seems that the line
Set colItems = objWMIService.ExecQuery("Select * from
Win32_MappedLogicalDisk")
reports no results
How can we have the script running correctly even with normal users ?
Thanks
Below the portion of the script :
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from
Win32_MappedLogicalDisk")
For Each objItem in colItems
objOutFile.writeline "Device ID|" & "Percorso di rete|" & "Volume Name|"
& "Description|" & "Free Space|" & "Size"
objOutFile.writeline objItem.DeviceID & "|" & objItem.ProviderName &
"|" & objItem.VolumeName & "|" & objItem.Description & "|" &
objItem.FreeSpace & "|" & bjItem.Size
objOutFile.writeline
Next Tag: Script para formatear Tag: 209822
Hola a todos.
Sabrían decirme un script para formatear una disquetera, sin necesidad de
que me pida el sistema confirmación?