Implementation or reference for HMAC-SHA1 signature in VB
Hi,
I need to implement the HMAC-SHA1 signature in my ASP/VBScript website.
Does anyone have an implementation or reference for such hashing
algorithm?
Thanks,
Gabi. Tag: DropDown box in worksheet Tag: 198738
Implementation or reference for HMAC-SHA1 signature in VB
Hi,
I need to implement the HMAC-SHA1 signature in my ASP/VBScript website.
Does anyone have an implementation or reference for such hashing
algorithm?
Thanks,
Gabi. Tag: DropDown box in worksheet Tag: 198737
vbscript to split up pst file
I have a number of clients who have pst files that are WAAAAAAAAAY too big.
I created the following vbscript create a new PST file according to quarter.
I have been able to create the new pst file but cannot figure out how to copy
over the folder strcture and emails within the given dates from the source
pst to the newly created destination. Can somone give me a hint as to where
I can go from here?
I'm pretty good at batch scripting but vbscript is a whole new world to me.
so go easy on me :)
What I have so far -
Option Explicit
On error resume next
Dim objOutlook, objNameSpace, oBQ, oEQ, oYEAR, oSOURCE, oDEST
oBQ = inputbox ("Enter beginning quarter")
if (oBQ<1 or oBQ>4) then
wscript.echo "The number " & oBQ & " does not signify a quarter. You are a
dork."
wscript.quit
End if
oEQ = inputbox ("Enter ending quarter")
if (oEQ<1 or oEQ>4) then
wscript.echo "The number " & oEQ & " does not signify a quarter. You are
a dork."
wscript.quit
End if
oYEAR = inputbox ("Enter the year")
if (oYEAR<1990 or oYEAR>2020) then
wscript.echo "The number " & oYEAR & "is either before 1990 or after 2020.
Either way, you are a dork."
wscript.quit
End If
oSOURCE = inputbox ("Enter the name of the source .pst file. Note: file
must be in the c:\email folder. <e.g. 'jsim' NOT 'jsim.pst'>")
Set objOutlook = CreateObject("Outlook.Application")
Set objNameSpace = objOutlook.GetNamespace("MAPI")
objNameSpace.AddStore "C:\email\" & objNameSpace.CurrentUser & "_Q" & oBQ &
"- Q" & oEQ & "_" & oYEAR & ".pst"
Set objNameSpace = Nothing
Set objOutlook = Nothing Tag: DropDown box in worksheet Tag: 198724
Creating Macintosh Shares
Is there a way to create a VB Script that will create Macintosh shares on a
Win2K Adv server running File and Print services for Mac?
Alex Tag: DropDown box in worksheet Tag: 198720
Webpage which can Authenticate via Active Directory
Hello
We have various web scripts and in each one we have to store all the users
in a seperate database.
It would simplify things a lot if we could show a webpage where users enter
their Windows username and password and the form would authenticate via
active directory and either fail if incorrect or set some variable to allow
users to access the rest of the script.
I was hoping to be able to write this in VB Script as this is what all the
scripts are written in.
Thanks for any help
Robin Tag: DropDown box in worksheet Tag: 198718
Script Error *Help Please*
Hello All,
Hope someone can help with this, below I have pasted the script that I am
using:
<OBJECT language="vbscript" ID="MsRdpClient"
CLASSID="CLSID:9059f30f-4eb1-4bd2-9fdc-36f43a218f4a"
CODEBASE="msrdp.cab#version=5,1,2600,1095"
WIDTH=<% resWidth = Request.QueryString("rW")
if resWidth < 200 or resWidth VIEWASTEXT VIEWASTEXT VIEWASTEXT>
1600 then
resWidth = 1024
end if
Response.Write resWidth %>
HEIGHT=<% resHeight = Request.QueryString("rH")
if resHeight < 200 or resHeight > 1200 then
resHeight = 768
end if
Response.Write resHeight %>>
</OBJECT>
When launching this asp I receive the following error:
Microsoft VBScript compilation error '800a03f9'
Expected 'Then'
/TSAC_XP.asp, line 46
if resWidth < 200 or resWidth VIEWASTEXT VIEWASTEXT> 1600 then
Looking forward to a response.
Thanks Tag: DropDown box in worksheet Tag: 198716
Batch file
would appreciate valuable help in setting up a batch file to perform
the following steps on w2003 server.
1.Stop service
2.backup c:\application folder\ to networked drive (share/map)
3.start service
4.ftp file to mainframe host
Thanks
AQ Tag: DropDown box in worksheet Tag: 198707
Script Not Totally Working in Scheduled Tasks
Hello,
I have a script here that runs every 5 minutes in scheduled tasks. The
script checks to see if the pc has a certain ip address and if it does it
disables the dhcp client and displays a message. The problem is I have the
task scheduled to run w/ the administrator's credentials. And unless the
administrator is the one signed in to the pc, the dhcp client will disable
but the message box does not display on the screen. It will give the
message beep however. Then the task continually says "running" because it
is waiting for the user to hit "ok", yet the user can not see the message
box.
What am i missing?
Any help will be greatly appreciated. Tag: DropDown box in worksheet Tag: 198706
Multilingual (UTF-8) support in HTML/URL Encoding/Decoding
Hi,
I have a multi-lingual website, especially with English and Hebrew
chars and using codepage 65001 (UTF-8).
I use the Server.HTMLEncode or Server.URLEncode with Hebrew chars when
needed.
But, when decoding them back - I get garbage.
For example, a Hebrew string after Server.URLEncode and a following
URLDecode:
"P&&&&& "&&&&&&&DAD" 2DAD9D9D9D!"
When used with English chars - all is OK.
The URLDecode function I'm using is:
Function URLDecode(str)
str = Replace(str, "+", " ")
For i = 1 To Len(str)
sT = Mid(str, i, 1)
If sT = "%" Then
If i+2 <= Len(str) Then
sR = sR & _
Chr(CLng("&H" & Mid(str, i+1, 2)))
i = i+2
End If
Else
sR = sR & sT
End If
Next
URLDecode = sR
End Function
I copied this function from somewhere. It's probably the problem. Isn't
it?
What should I use to enable URL/HTML Encoding/Decoding that supports
UTF-8 as well?
Thanks, Gabi Tag: DropDown box in worksheet Tag: 198705
Removing " in user input
Hi,
I am writing a internal website for my company and need some help. I
need to remove (or escape it) the " and ' from the user input so it can
be put in a SQL database. Currently what i have been doing is this
input = Replace(Request.form("input"), "'", "")
and that gets rid of the ' just fine, but how do I work with "? Can I
escape it with a \ or anything so it can go in my SQL database?
Thanks very much for your help! Tag: DropDown box in worksheet Tag: 198693
how to inherit mailbox permissions ?
Hi,
I'm currently trying to set permissions on a mailbox I create via a
script.
I can easily set those permissions for a certain user but I want to be
able to apply inheritance to that mailbox so that the permissions are
equal to those of a mailbox created via the "Active Directory Users and
Computers" snap-in.
Does anyone know how to achieve that (providing it's possible at all) ?
Thanks in advance,
Kevin Tag: DropDown box in worksheet Tag: 198686
Excel Macro
Hi
I have a folder with a large list of files. I need a macro that goes through
each file and searches for a specific number ( a clients FNN). I then need it
to copy all of the information from this row into a new document and then
paste the information. The information from each file needs to be on a new
line.
Is it possible to write this in VBS?
Thanks in advance Tag: DropDown box in worksheet Tag: 198672
Excecute script parts synchron
Hi,
Is it possible to execute parts of a script synchron, so as if two or more
scripts run parallel, but in one script, not in different scripts how you
can do it with shell.run.
Manfred Tag: DropDown box in worksheet Tag: 198671
Version of Office
Hi! How can I check what language version of MS Office is installed on the
machine (with vbscript)? Tag: DropDown box in worksheet Tag: 198665
Error Checking in AD Query
Hello
I've been trying to query AD to return the truncated domain name from a
list of users in a text file, based on the 'name' of the user. I'm very
new to scripting so at this stage I just piece together other's hard
work and try to make it happen! I seem to be able to return the domain
name o.k., but I'm missing around 40 names in a list of over 700,
consequently I can't match up each username with a domain name, so the
result is next to useless. I suspect that some of the usernames may be
invalid, but without an error checking routine I'm can't be sure. Does
anyone have a way of error checking the results of an AD query? I've
posted my script here, apologies if it's a bit scrambled, I've had
several attempts. Any help appreciated.
Const ADS_SCOPE_SUBTREE = 2
Const ForWriting = 2
Const ForReading = 1
LogFile = "C:\query\fso_initial.txt"
FinalFile = "C:\query\fso_final.txt"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(LogFile, ForReading)
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
' *** Open input text file and read through values
strLine = objFile.ReadAll
objFile.Close
arrDN = Split(strLine, vbCrLf)
For x = 0 To UBound(arrDN)
strLine = Trim(arrDN(x))
Next
' *** End Text File Read
Set objFile = objFSO.OpenTextFile(FinalFile, ForWriting)
For Each strItem In arrDN
' *** AD Query
objCommand.CommandText = _
"SELECT distinguishedName FROM 'GC://dc=SOMEDOMAIN,dc=net' WHERE
objectCategory='user' " & _
"AND name = '" & strItem & "'"
On Error Resume Next
Set objRecordSet = objCommand.Execute
Do Until objRecordSet.EOF
strDN = objRecordSet.Fields("distinguishedName").Value
objUser = Right(objRecordSet.Fields("distinguishedName").Value,
29)
' *** Write back to Text File
objFile.Writeline objUser
objRecordSet.MoveNext
Loop
Next
objFile.Close Tag: DropDown box in worksheet Tag: 198662
HTML Progress Bars
Regarding this thread:
http://groups.google.com/group/microsoft.public.scripting.vbscript/msg/272e4296c1d80aef
Great thread btw, I used this as part of my recent login script. I
tried all 3 of these this with the new beta of IE 7 and it takes on the
full screen... any html experts that can look at this or is this just
bleeding edge MS??
Thanks! Tag: DropDown box in worksheet Tag: 198658
install Flash Player 9.class doesn't support automation: 'GetObject'
My Team uses vbscript to install Flash Player 9 on 1000 user's pc. A
few get back to me getting the error :" class doesn't support
automation: 'GetObject' " . Any1 has any clue on what happens
Little Apple
A very very junior SA Tag: DropDown box in worksheet Tag: 198656
AD distribution list attribute query
Hi all,
Not sure if this is the right group to post this to, but here goes:)
I'm wondering if there is any distribution list attribute I can query that
will tell me when a mail was last sent to a group.
Many thanks, in advance, for your time.
Lew Tag: DropDown box in worksheet Tag: 198650
How to return a sting of numbers from a longer string
Let's say I have a string like this, which I'll call docAddress.
http://www.website.com/cgi-bin/mt/mt.cgi?__mode=view&_type=entry&id=003322&blog_id=1
I want to return the six digit string inside it, which in this case is
003322, but it could be any six digit number, and I'll call it EntryNum.
Is there a way to do that with a .vbs file?
The split function won't work for this situation because the number is not
simply located between two separators.
I could do this easily in with a Word macro, but I'm less sure about VB
script. Tag: DropDown box in worksheet Tag: 198649
Dynamic Group List
All,
I am looking for a way to populate a drop down box of an HTA with all groups
within a specific OU. Does anyone have a way for me to do this by chance??
Thanks!!
Ryan Tag: DropDown box in worksheet Tag: 198646
Removing network printers via login script
I am trying to remove all network printers, then readd the correct
printers via a login script.
here is what I have below:
Dim j
Set objPrinters = objNetwork.EnumPrinterConnections
For j = 0 To objPrinters.Count - 1 Step 2
' Remove only networked printers
If Left(objPrinters.Item(j +1),2) = "\\" Then
Line 158 ---> objNetwork.RemovePrinterConnection objPrinters.Item(j
+1),True,True
End If
Next
I am getting an error when the script runs:
Line: 158
Char: 3
Error: This network connection does not exist
Code 800708CA
Source: WSHNetwork.RemoveNetworkDrive
I am confused at where this error is coming from...
Any help would be greatly appreciated. Tag: DropDown box in worksheet Tag: 198645
Local to Remote switch for retrieving file ownership in XP
I have an .hta script that works locally, but will not work remotely.
I've created the same path as I'm checking locally on a remote server
and changed the "." to the name of the remote device. I get error
80041002 on line 32 (the For Each objItem In colItems). I looked up
the error and it appears to be a problem retrieving my object
information. Any clues? Thanks!!!:
<html>
<head>
<title>GridAC - List Folder Sizes</title>
<HTA:APPLICATION
ID="GridAC"
APPLICATIONNAME="GridAC"
SCROLL="yes"
SINGLEINSTANCE="yes"
>
</head>
<SCRIPT LANGUAGE="VBScript">
Sub Window_OnLoad()
Window.ResizeTo 300, 600
Window.moveTo (screen.width-240)/2, (screen.height-600)/2
End Sub
Sub FileOwner
strComputer = "."
strFolder = "C:\Tools\Scripts\"
Set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set fso = CreateObject("Scripting.fileSystemObject")
Set aFolders = fso.getFolder(strFolder)
For Each strFile in aFolders.files
strHTML = strHTML & "File Name:," & strFile.name & ","
set colItems = objWMI.ExecQuery _
("ASSOCIATORS OF {Win32_LogicalFileSecuritySetting='" & strFile &
"'}" _
& " WHERE AssocClass=Win32_LogicalFileOwner ResultRole=Owner")
For Each objItem In colItems
strHTML = strHTML & "File Owner:," & objItem.ReferencedDomainName
& "\" & objItem.AccountName & "<br>"
Next
Next
passHTML.innerhtml = strHTML
End Sub
</SCRIPT>
<body>
<input type="button" value="Run Script" name="run_button"
onClick="FileOwner"><p>
<p>
<span id="passHTML"></span>
</body> Tag: DropDown box in worksheet Tag: 198641
echo message should popup
set WshShell = CreateObject("WScript.Shell")
WshShell.Echo "Hello"
I would like this to popup with a message box, but it only displays
text in the command line.
How can I modify the VBS code to have a popup.
This will need to work on multiple machines, without altering
environment settings etc.
Thanks
Nick Tag: DropDown box in worksheet Tag: 198639
Grab selected file names
I am trying to programmatically determine which file names are selected
in a given window. e.g. - my objective is to have a user open an
explorer window. He multi-selects several files, right clicks, and then
from the context menu sends the filenames to a file. How would I go
about pulling the selected list of filenames, while pushing this data
into an array or writing it to a file? I'm not quite sure where I
should look for this...file system object?
Thanks so much! Tag: DropDown box in worksheet Tag: 198634
How to install FTP Service
Is there a way to install the FTP Service via vbscript rather then having
somone go into Add/Remove programs, ADD/Remove windows programs, and
selecting the File Transfeer Protocal service?
Thanks
J Tag: DropDown box in worksheet Tag: 198631
VB Script with Windows Task Scheduler
Hello.
I have a problem with vb scripts that I call using the task scheduler.
The problem is that the scripts continue to run and never stop. The
scripts are calling an excel, and access applications. I'm using
removing the object of each instance using "application.quit", and also
removing the object in my vb script "set objExcel=Nothing", and the
task scheduler has the scrupt running for 48 hours when it should run
no more than 10 minutes. Can some please help with this.
Here's a sample of my vbscript:
Dim appAccess, strConPathToDB
strConPathToDB = "C:\ftoups.mdb"
Set appAccess = createObject("Access.Application")
appAccess.Visible = True
appAccess.OpenCurrentDatabase strConPathToDB
appAccess.DoCmd.OpenModule "ModuleImport_ExportNew", "GetDataNew"
appaccess.Run "GetDataNew"
appAccess.Quit
Set appAccess = Nothing
Here's the last line of code that the above vb script references:
Sub()
Application.Quit
End Sub Tag: DropDown box in worksheet Tag: 198630
A script to format a raw drive.
Hello
I've got a new drive that for various reasons, I have been using diskpart to
wipe the partition table. When I add it as a secondary I always go through
the Disk Managment console to first initalize disk 1, format with a 3gig
partition, and set it as active.
How can I do that via a VB script? Tag: DropDown box in worksheet Tag: 198626
Accessing Local Policies and making
I am needing to write a script to set local policies on some servers
repeadily. These particular servers are not allowed to be touched by group
policies on the Domain. I need to write a script to automate such things as:
o Adding a domain account to the "Log on as batch job" security setting.
Is there a way to access these through VBscripting? If so, could somebody
please point me to the specifics?
Regards,
--
Randy Tag: DropDown box in worksheet Tag: 198625
To run CScript as default
I have a number of .vbs login scripts that I want to run using the WSH in
cscript rather than wcsript.
I there a line that I can put at the start of the scripts to ensure that
they are run in cscript?
Any help appreciated. Tag: DropDown box in worksheet Tag: 198624
Possible VB Error in Access 97 DB?
Not sure if this is the right group for this post but here it is:
We have a Bunch of users that Connect to a shared Access 97 DB (have to join
a access workgroup first). Everything fine until crash on Friday, Now those
stations cannot log in. Same user ID can log in to the DB from another PC, I
can log in on my station but not on theirs. Seems like only the stations
that were in the DB at time of crash can no longer get in. They get â??Compile
Error in hidden moduleâ?? but ONLY ON STATIONS that were in access at the time
of the crash.
Any thoughts? Tag: DropDown box in worksheet Tag: 198623
How would you approch this project?
I am hoping for a code example of how to do this, and hopefully it will
help me to see an easy way to code what seems to be a huge monster.
I need to create a form that has two pulldown menues (field names
Option1 and Option2). Each will house a list of the 50 U.S. States.
Users would then be able to choose two states, and get a listing for a
courier used for pickup\deliveries (exp: My order is in Ohio, but I
need it delivered to Maine. Who do I use?)
I am not as familiar with code as I would like, but it seems I would
need something like this:
If option1 = this, and option2 = this, then the answer (field name
Result) = this
I know that looks stupid, but I am hoping to show you how I am
approching this in my head.
Any ideas on how you would approch this project would be great. If you
could offer a sample of code, I'm sure I could use it as a template for
other projects. My idea is that this is just standard IF this THEN that
coding, but I don't know the basics enough to create the code from
scratch.
Thanks for any time you can give. Tag: DropDown box in worksheet Tag: 198618
SLOW SLOW Script... Event Logs > Database....Am I asking it to do too much?
Hi,
The below script, connects to the AD, enumerates a list of servers
within the domain - this bit is quick... The second part then connects
to each server in that list and copies its event logs to an SQL Server,
so the script is run on box 1, the remote server changes and is Box 2,
and the SQL server is box 3. (for arguments sake) all on the same site,
on the same Gigabit network...
The first box rushed through its logs, now on the 3rd box, I'm lucky if
one event record is copied every few seconds...
I'm thinking that exporting the logs into a Text File and then run a
DTS from the SQL server to import them might be quicker... But this way
adds to the idea of integrity...
If anyone can see anything blindingly obvious with the structure of
this I would appreciate it.
btw - strNewDate was made because the strTimeWritten string wasn't
formatted correctly for the SQL server (and it was the only way I could
think to fudge it) :-)
I've got the echo's are there just to give me an idea of what its up to
and when...
I just don't understand why it starts off quick and then grinds to a
halt only 4 servers in a list of about 50....
Help...
<SNIP>
On Error Resume Next
Const ADS_SCOPE_SUBTREE = 2
Dim vblComputer, vblCount
vblCount = 0
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.CommandText = _
"Select Name, distinguishedName,operatingSystem,operatingSystem,
operatingSystemVersion from " & _
"'LDAP://DC=<DOMAIN_NAME>, DC=<DOMAIN_NAME>' where
objectClass='computer'and operatingSystem='Windows 2000 Server' or
operatingSystem='Windows Server 2003' ORDER BY operatingSystem"
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
vblComputer = objRecordSet.Fields("Name").Value
WScript.Echo "now moving onto " & vblComputer
vblCount = 0
getLogs(vblComputer)
WScript.Echo "Wrote " & vblCount & " Records"
objRecordSet.MoveNext
Loop
Sub getLogs(vblComputer)
Set objConn = CreateObject("ADODB.Connection")
Set objRS = CreateObject("ADODB.Recordset")
objConn.Open "DSN=<DATABASENAME>","<USERNAME>","<PASSWORD>"
objRS.CursorLocation = 3
objRS.Open "SELECT * FROM EventTable" , objConn, 3, 3
Set dtmStartDate = CreateObject("WbemScripting.SWbemDateTime")
Set dtmEndDate = CreateObject("WbemScripting.SWbemDateTime")
DateToCheck = Date - 1
dtmEndDate.SetVarDate Date, True
dtmStartDate.SetVarDate DateToCheck, True
strComputer = vblComputer'"."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer &
"\root\cimv2")
Set colEvents = objWMIService.ExecQuery _
("Select * from Win32_NTLogEvent Where TimeWritten >= '" _
& dtmStartDate & "' and TimeWritten < '" & dtmEndDate & "'")
For each objEvent in colEvents
objRS.AddNew
objRS("Category") = objEvent.Category
objRS("ComputerName") = objEvent.ComputerName
objRS("EventCode") = objEvent.EventCode
objRS("Message") = objEvent.Message
objRS("RecordNumber") = objEvent.RecordNumber
objRS("SourceName") = objEvent.SourceName
strDate = objEvent.TimeWritten
yy = Left(strDate,4)
mm = Mid(strDate,5,2)
dd = Mid(strDate,7,2)
hh = Mid(strDate,9,2)
mn = Mid(strDate,11,2)
ss = Mid(strDate,13,2)
strNewDate = yy & "-" & mm & "-" & dd & " " & hh &":"&mn & ":" & ss
'strTimeWritten = objEvent.TimeWritten
objRS("TimeWritten") = strNewDate
' objEvent.TimeWritten
objRS("Type") = objEvent.Type
objRS("User") = objEvent.User
objRS.Update
WScript.Echo "Wrote Record Number : " & vblCount
vblCount = vblCount + 1
Next
objRS.Close
objConn.Close
End Sub
</SNIP> Tag: DropDown box in worksheet Tag: 198609
Startup path i Office
Need to find Office path to Startup directory that works no matter if it is
Office 2000, 2002 or 2003. The code below works fine for 2003. How can I
check the Office version that is installed? Thanks!!
Dim strDestOffice
Set WshShell = WScript.CreateObject("WScript.Shell")
strDestOffice = WshShell.ExpandEnvironmentStrings("%programfiles%\Microsoft
Office\OFFICE11\STARTUP")
Set WshShell = Nothing Tag: DropDown box in worksheet Tag: 198608
Domain\Domain\UserName instead of only Domain\UserName thru WMI Qu
strComputer = "."
Dim objWMIService : Set objWMIService = GetObject("winmgmts:" & _
"{impersonationLevel=impersonate}!\\" & _
strComputer & "\Root\CIMV2")
Set colComputer = objWMIService.ExecQuery ("Select * from
Win32_ComputerSystem")
For Each objComputer in colComputer
strAccount = objComputer.UserName
Next
msgbox strAccount
When I run the above code on local computer, I get "Domain\Domain\UserName"
as output instead of "Domain\UserName". Do we have any specific reason for
this. I am running this script on Windows XP machine.
Thanks in advance
Deepak Tag: DropDown box in worksheet Tag: 198606
encrypt data from client side
Hello every body:
Does anyone know any way to encrypt data from client side?
I would like not to use any activex.
Thank you for advance.
Frank Tag: DropDown box in worksheet Tag: 198605
Checking service state?
Hello,
I developing a script that would send me an email if theres a change in the
status on Win services on one of our servers. This is the basic version that
sends mail and echoes user that there's a change. Problem is that the email
part of it is not very reliable. Sometimes the mail is not sent. Any idea
what's wrong? The mail fails in about 20% of times that some service is
started or stopped.
My idea here is to check the services state every 30 seconds. Am I doing it
right with this query?
Thanks
-Will
Here's the code:
Set objNetwork = Wscript.CreateObject("Wscript.Network")
Set objWMIService =
GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
'**************************************************
Recepient = "will@domain.com"
Subject = "Service state has changed
'**************************************************
strComputer = "."
SendEmail = 0
Set objWmiEventSource = objWMIService.ExecNotificationQuery _
("SELECT * FROM __InstanceModificationEvent WITHIN 30 WHERE TargetInstance
ISA 'Win32_Service' ")
DO
Set objService = objWmiEventSource.NextEvent
If objService.TargetInstance.State <> ObjService.PreviousInstance.State
Then
SendEmail = 1
Else
SendEmail = 0
End If
If SendEmail = 1 Then
Set objNetwork = Wscript.CreateObject("Wscript.Network")
Machine = objNetwork.ComputerName
Sender = Machine & "@domain.com"
Set objEmail = CreateObject("CDO.Message")
objEmail.From = Sender
objEmail.To = Recepient
objEmail.Subject = Subject
objEmail.Textbody = "Servers '" & objService.TargetInstance.SystemName & "'
service '" & _
objService.TargetInstance.DisplayName & "' state has changed. Old
state was: '" & _
objService.PreviousInstance.State & "' New state is: '" &
objService.TargetInstance.State & "'"
objEmail.Configuration.Fields.Item
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mailserver"
objEmail.Configuration.Fields.Item
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.Fields.Update
objEmail.Send
Wscript.Echo "E-Mail should have been sent!"
SendEmail = 0
End If
Loop Tag: DropDown box in worksheet Tag: 198604
Vbscript code to unzip a zip file
Hi
Anyone help me out in providing VBscript to unzip or extract a zip
file.I tried alot.but not successfull.
Regards
Lakshmi
--
yjalakshmi
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------ Tag: DropDown box in worksheet Tag: 198603
Getting domain name twice in user name .{WMI Query}
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer &
"\root\cimv2")
Set colComputer = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")
For Each objComputer in colComputer
Wscript.Echo "Logged-on user: " & objComputer.UserName
Next
When I run the above mentioned code I am getting domain name twice in
user name .
Like "Domain\Domain\user name "
Please help me to resolve this problem Tag: DropDown box in worksheet Tag: 198602
WinHttp: 'Cannot connect to server' problem
The code is like below:
Dim oHttp
Set oHttp=CreateObject("WinHttp.WinHttpRequest.5.1")
sUrl = InputBox("Url",wscript.ScriptName,"http://www.dormforce.net")
With oHttp
.Open "GET",sUrl,False
.Option(6)=0
.SetTimeouts 5000,5000,30000,5000
.SetRequestHeader "Accept","*/*"
.SetRequestHeader "Accept-Language","zh-cn"
.SetRequestHeader "User-Agent","Mozilla/4.0 (compatible; MSIE 6.0;)"
.SetRequestHeader "HOST","www.dormforce.net"
.SetRequestHeader "Connection","Keep-Alive"
.Send
If .Status<>200 And .Status<>302 Then
WScript.Echo .GetAllResponseHeaders 'Do sth with 'LOCATION' header
Else
WScript.Echo .GetAllResponseHeaders
End If
End With
What ever I tried, my XP SP2 always prompts: "
A connection with the server could not be established."
Error Code: 0x80072EFD
the Microsoft.xmlHttp works OK, but how to explain this? Tag: DropDown box in worksheet Tag: 198601
Anyone know how to get individual message attributes via vbscript?
Getting the store size or even the mailbox size is no big deal, but I
need to drill into the individual objects and get the information from
them such as the size of the message and its sent/recd. time.
I have been diggin around most of the weekend and while there appear to
be some applications that can do this, they are too limited for my
needs. Has anyone got a decent script that can get into the individual
mailboxes and pull the info? I am assuming I need to use MAPI since I
want to span mailboxes, not just gather the logged in user, but no love
on any searches I try.
Help? Anyone? Tag: DropDown box in worksheet Tag: 198595
acessing form controls names
hi i need to have acess to the form controls names in a procedure .this is
my code where tx and ck are the form names...
<script language="vbscript">
<!--
sub vb1(Byval ck, byval tx)
msgbox ck & " " & tx
if window.document.fp1.ck.checked=false then
window.document.fp1.tx.disabled=true
window.document.fp1.prec1.value=""
else
window.document.fp1.prec1.disabled=false
window.document.fp1.prec1.focus()
window.document.fp1.prec1.value="Preço"
end if
end sub
'-->
</SCRIPT> Tag: DropDown box in worksheet Tag: 198592
Restart printed job
I'm sending a few print jobs to a print queue that I've setup to "keep
printed documents." This queue is on a Windows Server 2003 box. Is there
anyway to script it so that those jobs can be restarted through vbscript?
The reason I need the queue to keep the printed documents is so that I can
print them a second time. I keep seeing scripts to resume paused jobs, but
not to actually restart jobs that have been printed already and are still in
the queue. Any pointers would be great. Tag: DropDown box in worksheet Tag: 198585
What's wrong with this code?
I am having a hard time figuring out what is wrong with this code. I
can't get it to go inside the If statement
//begin code
Option Explicit
Dim MyDate, MyWeekday, Day1
On Error Resume Next
MyDate = Date
MyWeekDay = Weekday(MyDate)
Day1 = "7"
If MyWeekDay = Day1 Then
WScript.Echo "Today"
End If
//end code
But if I change the If statement to this it works fine:
If MyWeekDay = "7" Then
WScript.Echo "Today"
End If
But I am looking to compare two variables whose values will change. I
won't bother with the details.
Please help!! Tag: DropDown box in worksheet Tag: 198582
Problem opening .chm Help File from MsgBox/InputBox
I cannot open a .chm help file from a VbScript MsgBox and InputBox.
When I click on the .chm file in Windows Explorer, it displays normally and
runs in hh.exe process.
My script refers to this help file in a message box and an inputbox:
MsgBox "Click Yes or No", vbYesNo, , "C:\scripts\MyHelp.chm", 1010
But when I click on the Help button, the following message appears with
"Windows Help" in the title bar:
"The document C:\scripts\MyHelp.chm is not a Windows Help file, or the file
is corrupted." In Task Manager, I see VbScript starts winhlp32.exe, I guess
to open that .chm file. (After clicking OK and the script finishes,
winhlp32.exe continues running in the background.)
So it appears VbScript expects a .hlp file.
Can I not point to a .chm help file in a VbScript message box/inputbox?
Win 2000 SP4
WSH 5.6
Help file created by HTML Workshop 4.74.8702.0 Tag: DropDown box in worksheet Tag: 198580
Challenge: Parallel Port
Hello, does anyone know how to send data to and get data from parallel
port using vbscript?
Thanks! Tag: DropDown box in worksheet Tag: 198575
FileSystemObject: Invalid procedure call or argument Error 800A00
Line 24 generates the following error: Invalid procedure call or argument
Error 800A00005
The script below runs fine if I comment out lines 24-26, but I need to
create the text file that those lines are intended to create.
Does anyone...
1. Know how to fix those lines so that they work? and
2. Know where I can find reading material so that I would know how to do it
right, i.e., what I'm doing wrong?
Thanks in advance for your time and help.
Marceepoo
'Canniablized from Hey_Scripting_Guy.chm
'
'Get a List of All the Files in a Folder and Its Subfolders
'
'
'
sFileList = ""
Set objFSO = CreateObject("Scripting.FileSystemObject")
objStartFolder = "o:\"
Set objFolder = objFSO.GetFolder(objStartFolder)
Set colFiles = objFolder.Files
For Each objFile in colFiles
sFileList = sFileList & objFile.Name & vbCrLf
'Wscript.Echo objFile.Name
Next
ShowSubfolders objFSO.GetFolder(objStartFolder)
WScript.Echo sFileList
'Set objFile = objFSO.OpenTextFile("o:\NewFile.txt", ForWriting)
'objFile.WriteLine sFileList
'objFile.Close
Sub ShowSubFolders(Folder)
For Each Subfolder in Folder.SubFolders
'Wscript.Echo Subfolder.Path
Set objFolder = objFSO.GetFolder(Subfolder.Path)
Set colFiles = objFolder.Files
For Each objFile in colFiles
'Wscript.Echo objFile.Name
sFileList = sFileList & objFile.Name & vbCrLf
Next
'Wscript.Echo
ShowSubFolders Subfolder
Next
End Sub Tag: DropDown box in worksheet Tag: 198573
language setting
Hi,
I want to disable the control panel from user access, For that I require
a script that will automatically set 2 languages for the user over their
desktop.
regards
adehas Tag: DropDown box in worksheet Tag: 198567
Why Do I Get a Leading Space Written to File Names?
Does anybody understand why the following snippet of a script should create
a file name which has a leading space? This simplified script reads each
file in a folder (FOL) and removes leading and trailing spaces from the
filename and then writes each file to a folder FOLREN.
strBOOKNAME = file name in folder FOL
strBOOKNAME = Trim(strBOOKNAME) ' remove leading and trailing spaces
objFSO.CopyFile cFOL & strFIL.Name, cFOLREN & strBOOKNAME & ".mp3"
MsgBox Asc(strBOOKNAME) ' this always returns a value greater than 32
Yet when I browse the files in windows explorer or use ASC(filename) I find
that the output file has a single leading space.
any ideas would be appreciated, Davy Tag: DropDown box in worksheet Tag: 198562
New Script Library
Hi All,
I have set up a new Script Library website. Quite a few languages are
represented such as VBScript, Perl, Javascript, Rexx and Python. My expertise
is with vbscipt and asp, but am thinking of learning some others.
The content is currently made up of the scriptcenter scripts but over the
next few weeks I will be adding several hundred of my own scripts I have
written over the last 8 years.
main url = http://www.thescriptlibrary.com
have a look and let me know what you think. Any ideas for improvement are
welcome. Tag: DropDown box in worksheet Tag: 198558
Hello,
How to create dropdown box with vbscript in excel worksheet?