Download a website's source with VBS
Hello everyone,
Okay probably a simple question, but I'm very green to VBS and I can't
find this anywhere! In the Unix world I use wget to download just the
source file for a given website, but I need to do this same thing in
Windows and preferably with VBS.
Basically what we're doing is downloading an xml file from a vendor's
website then importing it into our MS SQL database via a VBS script
(using QLXMLBulkLoad). I have this part working, but I now need to
download the xml file from the web server. Ideally I'd like to put
this download routine before the code that imports the XML content, but
that's my delimma -- I dunno how to write it :)
Thanks for any suggestions or pointers into the right direction. Take
care --
Alex Tag: Help!!! Date operations Tag: 192283
Cycle through variables
Is there a way to specify a list of say 20 variables in a script and run the
same command for all variables without copying pasting the command 20 times
in a script? Below is an example of my current script - I'd really like to
simplify it to make future modifications much easier. It looks like there
are two options that may produce my desired end result - using an array
and/or using multiple instances of the same variable, for example: Group(1)
= group in domain1, Group(2) = group in domain2, etc.
Can anyone shed some light on how to cycle through many variables to the
same command?
Group01="cn=somegroup,ou=somou,dc=domain1,dc=com"
Group02="cn=somegroup,ou=somou,dc=domain2,dc=com"
(etc.)
Set objGroup = GetObject ("LDAP://"&Group01)
For each objMember in objGroup.Members
i = i + 1
AlertReportXX = i&". "&objMember.sAMAccountName&" (domain.com)"
objTextFile2.WriteLine(AlertReportXX)
EchoXX = "domain.com,,"&objMember.sAMAccountName
objTextFile.WriteLine(EchoXX)
Next
Set objGroup = GetObject ("LDAP://"&Group02)
For each objMember in objGroup.Members
i = i + 1
AlertReportXX = i&". "&objMember.sAMAccountName&" (domain.com)"
objTextFile2.WriteLine(AlertReportXX)
EchoXX = "domain.com,,"&objMember.sAMAccountName
objTextFile.WriteLine(EchoXX)
Next
(etc.)
wscript.echo i
wscript.quit Tag: Help!!! Date operations Tag: 192282
Creating excel file on server
I understand that vbscript is a client side scripting language, but is
there a way to create the file on the server side instead? I'm using
php on my website, and am generating excel files for users to download.
The problem with creating excel files with vbscript is that all users
needs to be using internet explorer and must adjust their security
settings before they can take advantage of this feature. I would
rather have the excel file be created on the server and just upload it
to clients rather than having them go through so much. (Even though it
is a one time setup)
Any other solutions is appreciated. I prefer vbscript because I have
full control over the access file such as formats, merged fields,
formulas, font color, size, print size, etc. I know i can create an
excel file using php with headers, but I don't have as much control
over the appearance of the excel file as I do when using vbscript. Tag: Help!!! Date operations Tag: 192279
Test for setup.exe success.
Is there a way to test for the successful completion of "setup.exe"
using either the exec or run methods? Particularly what I'm trying to
do is do a silent install of Firefox & Thunderbird 1.5.0.4. I've
extracted their installation files and made the necessary modifications
to them, and the "setup.exe" with both of them can be run in silent
mode. If I launch that, how can I determine if it completes
successfully? The following code seems to always return a zero
ReturnCode, regardless of whether setup.exe fails or completes
successfully.
If Not IsObject(oWshShell) Then Set oWshShell =
CreateObject("WScript.Shell")
ReturnCode = oWshShell.Run("setup.exe", 1, True)
Thanks... Tag: Help!!! Date operations Tag: 192278
File Management
office has some Mac Computer
when use file share will Mac will make the ._XXXXX Files
How to make a script when i run this script will find all ._xxxxx file
and delete
then log to a file what file been delete
thanks alot Tag: Help!!! Date operations Tag: 192268
Getting Users TEMP folder
Hi,
Is there any way to get the users temporary folder (C:\Documents and
Settings\<username>\Local Settings\Temp) in vb script
Thanks,
Anishya Tag: Help!!! Date operations Tag: 192260
Problem with quotes
I am creating a script to enumerate all the shares on my local test server
and put the output in a net share command format so that I can easily
transport my shares to another server. The script works fine but I need to
but the share name and share path in "double quotes", and I cannot find a way
to do this. Below is the my script and the desired output.
Set wmiRoot = GetObject("WinMgmts:root/cimv2")
Set wmiColl = wmiRoot.ExecQuery("Select * FROM Win32_Share")
For Each wmiObj In wmiColl
WScript.Echo "net share " & wmiObj.Name &_
"=" & wmiobj.Path &_
" /GRANT:Everyone,Full"
Next
Here is what I am trying to get the output to look like.
net share "script"="C:\script" /GRANT:Everyone,Full
Any help you can provide would be great,
Thank You Tag: Help!!! Date operations Tag: 192258
WScript Application Error
I am running Windows XP SP2 systems at multiple locations that log into a
Active Directory domain and have logon scripts launched via GP. I have VBS
scripts, that run with the logon scripts, that add/remove connections to
network printers. These scripts have been running fine up until about a
month ago when I started getting reports of an error message that comes up
after the script has finished running. WScript.exe - Application Error. The
instruction at "0x7c91103c" referenced memory at "<address>". The memory
could not be "written". The "0x7c9110c" seems to remain constant whereas the
second <address> changes.
The following is an example of a script that is receiving this error:
On Error Resume Next
Set WshNetwork = WScript.CreateObject("WScript.Network")
WshNetwork.RemovePrinterConnection "\\BLV501\ANNEX_BLACK"
WshNetwork.RemovePrinterConnection "\\BLV501\ANNEX_COLOR"
WshNetwork.RemovePrinterConnection "\\BLV501\CENTRAL_BLACK"
WshNetwork.RemovePrinterConnection "\\BLV501\CENTRAL_COLOR"
WshNetwork.RemovePrinterConnection "\\BLV501\FRONT_DESK_FAX"
WshNetwork.RemovePrinterConnection "\\BLV501\NORTH_BLACK"
WshNetwork.RemovePrinterConnection "\\BLV501\NORTH_COLOR"
WshNetwork.RemovePrinterConnection "\\BLV501\SOUTH_COLOR"
WshNetwork.RemovePrinterConnection "\\BLV501\SOUTH_BLACK"
WshNetwork.RemovePrinterConnection "\\BLV501\STAFF_BLACK"
Set WshNetwork = CreateObject("WScript.Network")
WshNetwork.AddWindowsPrinterConnection "\\BLV501\ANNEX_BLACK"
WshNetwork.AddWindowsPrinterConnection "\\BLV501\ANNEX_COLOR"
WshNetwork.AddWindowsPrinterConnection "\\BLV501\CENTRAL_BLACK"
WshNetwork.AddWindowsPrinterConnection "\\BLV501\CENTRAL_COLOR"
WshNetwork.AddWindowsPrinterConnection "\\BLV501\FRONT_DESK_FAX"
WshNetwork.AddWindowsPrinterConnection "\\BLV501\NORTH_BLACK"
WshNetwork.AddWindowsPrinterConnection "\\BLV501\NORTH_COLOR"
WshNetwork.AddWindowsPrinterConnection "\\BLV501\SOUTH_COLOR"
WshNetwork.AddWindowsPrinterConnection "\\BLV501\SOUTH_BLACK"
WshNetwork.AddWindowsPrinterConnection "\\BLV501\STAFF_BLACK"
I have seemed to narrow the problem down to the "On Error Resume Next"
command. If I remove this from the script it will run without the error at
the end, however if the script tries to delete a printer that is not
installed on the local computer or add a printer that the user does not have
permissions for it throws an error and does not complete.
I am relatively new to scripting and most of my experience has been editing
existing scripts. Any help would be appreciated.
Thanks in advance for all your help
David Tag: Help!!! Date operations Tag: 192252
Newbie question - writing username and password
For starters, I've been able to execute/run an FTP app. From here, I
need to pass the username and password. Can someone assist please?
strftp = "ftp za15XXX"
set myshell=wscript.createobject("wscript.shell")
myshell.run (strftp)
WScript.Write "username" --need help
WScript.Write "password" -- need help Tag: Help!!! Date operations Tag: 192248
Add a domain group
How would you script out adding a existing domain group to your own PC.
I've been looking at net.exe but I haven't had any luck. Is there a way to
script it out.
Thanks Tag: Help!!! Date operations Tag: 192245
Dropdown Box in VBScript?
I would like to replace an InputBox with a dropdown box in a very simple
script asking for user input prior to processing it. This is not for a web
page, but to be used on XP machines. Anyone have any suggestions?
Thanks.
---John Tag: Help!!! Date operations Tag: 192238
!Regular Expression for Process Name(s)
To All:
I was wondering if I could use a regular expression for process names in
the process list?
For instance, consider the following:
Dim strComputer : strComputer = "."
Dim objWMIService = GetObject("winmgmts:" & _
"{impersonationLevel=impersonate!\\" & strComputer & _
"\root\cimv2")
Set colProcessList = objWMIService.ExecQuery ("Select " &_
"* from Win32_Process Where Name = 'cpm???32.exe'")
For Each objProcess in colProcessList
objProcess.Terminate()
Next
The regular expression would come into play on the actual process name
so that each process which begins with cpm???.exe would then be killed?
Or am I mis-understanding the concept here?
Any info would be appreciated!
Thanks!
Mark Tag: Help!!! Date operations Tag: 192237
P3P web site integration
How do i implement P3P on my web site. i found documentation on what P3P is
but no integration documents. Tag: Help!!! Date operations Tag: 192236
VB logon script
I have a logon script for all my users. Some times I have users that complain
that not all the shared drives are connected, I also have 2 or 3 users that
the user drive will not map at logon time. Everything will map fine if i run
the script manually from their desktop.
I made sure they have the latest updates, I also checked for any CRC errors,
or latencies problems, but everything was fine.
Can some one give me a clue to where i should start looking for problems?
Thanks Tag: Help!!! Date operations Tag: 192233
VB startup printer script.
Hello,
I'm trying to create a startup script for WinXP workstations via Win 2003
server. I have the VB script for adding printers and can run them
successfuly when running directly on the workstation. However, when I assing
the script via GPO in Active Directory as a startup script, the script does
not run. Upon starting up, the machine shows "startup scripts," but once I'm
logged on no printers appear. I have de-activated Windows Firewall in hopes
that that was the culprit, to no avail. Any help here will be greatly
appreciated.
Thanks in advance,
Vince Tag: Help!!! Date operations Tag: 192231
Problems in Waiting for Web page to Open
Hi
Inexperienced scripter building a small vbs script to allow hotkey
combo launching of a virus scanner that, without the script, would
require "mouse-clicking" through four different pages before the
scanner will start.
The script starts by launching IE and then calling the virus scanner
Start Page, waiting until the page is fully open, tabbing (via
SendKeys)to the appropriate button and Entering (via SendKeys).
The "waiting" in this step is done via:
While IE.ReadyState <> READYSTATE_COMPLETE : Wscript.Sleep tDoEvents
Wend
This brings up a EULA page where I would have liked to have used the
same While....Wend loop to wait until the page was fully open before
using the SendKeys function to "click" the Accept button and move to
the next page. However, use of the While....Wend loop causes the script
to stop and go no further. To overcome this, I have used instead a
Sleep command (WScript.Sleep 5000) whereupon it proceeds without
difficulty.
In the subsequent page, the scanner downloads updates for a time that
is quite variable depending chiefly on the days since the last update.
Once again, the While....Wend loop causes the script to stop while a 25
second Sleep, in its place, overcomes this problem in a somewhat
inelegant manner as perhaps as little as 2 seconds are necessary to
download the updates.
The final page allows choice of what is to be scanned. Here the
While....Wend loop works fine.
Although the script does what it is supposed to do, I`m puzzled as to
why the While....Wend loop works in only two of the four attempts to
incorporate it in this "macro".
Can anybody suggest what might be the problem here?
TIA
Paul Tag: Help!!! Date operations Tag: 192229
Script needed to search for long filenames
Hi,
Does anyone have a script that will search a drive (and all subfolders) and
output (to a text file) a list of all files that exceed a specified number
of characters, including their full path?
Thanks,
Curtis.
--
Please reply to news group only. Thank you. Tag: Help!!! Date operations Tag: 192225
copying files to a drive mapped to a machine on the network
Hi,
I am trying to use Copyfile method of the file sytem object (FSO) to
copy files on my IIS box to another machine on the network. On my IIS
box I have a drive(l:) mapped to the other machine on the network
I use the following code
Object.CopyFile "d:\myfiles\*.*","l:\myfiles"
Will this work. The drive l: is mapped on the IIS box to another machine
on the network. The drive d: is the local drive on the IIS box.
Also after copying if I want to show a file (for example a word
document,photo) on the "l:\myfiles folder" in my asp pages can it be
done.
THanks.
Kumar.
Thanks.
*** Sent via Developersdex http://www.developersdex.com *** Tag: Help!!! Date operations Tag: 192224
RegExp advice please
Greetings:
I have a load of data that I need to alter. I am using the RegExp
object inside a SQL Server DTS Task. The data had links that were
designated in a very proprietary way, and I need to convert these to
HTML hyperlinks. Here are some examples the proprietary links:
[[link text| IMAGE v:\bitmaps\image18.bmp CLIP]]
[[more link text | IMAGE v:\bitmaps\link8.bmp CLIP]]
[[link| IMAGE v:\bitmaps\foonugget\d01.bmp]]
Here is the search I use:
\[\[(.+?)\|\s+IMAGE+\s+.{3}([^\s\]]+)[^\]]*\]\]
And here is the replace:
<A HREF=http://server.mydomain.com/\2>\1</A>
It works and gives me:
<A HREF=http://server.mydomain.com/bitmaps\foonugget\d01.bmp>link</A>
My issue is that I am unsure how to change the backslashes to forward
slashes. As the path may contain one or more subdirectories, I cannot
count on a specific number of tokens.
I had hoped that I could perform a Replace on individual matches in the
SubMatches collection, but it appears to be read-only.
If anyone has any advice, I would REALLY appreciate it.
Thanks,
Corky Tag: Help!!! Date operations Tag: 192222
Enumerate local group members with domain information
Sometimes I've seen topics where people needs domain information and
object name when enumerating local groups. Here is short script for
that... Use the Replace function if the string WinNT:// bothers you.
But it's usefull if you add/remove objects to/from the group.
********************************************************************************************************
********************************************************************************************************
Set oNet = WScript.CreateObject("WScript.Network")
set objGroup = GetObject("WinNT://"& oNet.ComputerName &
"/Administrators")
For Each objUser in objGroup.Members
MsgBox(objUser.AdsPath)
Next
MsgBox("Done.")
********************************************************************************************************
********************************************************************************************************
If you like to remove something...
If objUser.Class = "User" Then
oGrp.Remove objUser.AdsPath,user
End If
If objUser.Class = "Group" Then
oGrp.Remove objUser.AdsPath,group
End If
********************************************************************************************************
Br,
Miika Tag: Help!!! Date operations Tag: 192214
Converting object to string
Hi,
I have the following code to get the folder path:
Set oFileSystem =Server.CreateObject("Scripting.FileSystemObject")
Set tfolder = oFileSystem.GetSpecialFolder(2)
Response.Write(tfolder) will display as C:\windows\Temp
Now I need to get a substring of this result. I cannot use any string
functions as it is giving an error.
Any ideas?
Thanks,
Anishya Tag: Help!!! Date operations Tag: 192212
Reading each word of a file, line by line
Hi all,
* Here is the content of the file I want to modify via vbs :
project version release
a b c
* What I wish to obtain at the end is :
set project = a
set version = b
set release = c
Many thanks in advance for your help.
Regards Tag: Help!!! Date operations Tag: 192202
Listview/HTA help please.
I'm trying to use a listview object in an hta.
I can create the object and populate/display data in the object.
What I don't know how to do is attach a function or sub to the object
events "click", "columnclick" etc..
The pages on MSDN are really lite on the control, I've done everything
so far just using an objbrowser for doc
Any help and all help welcomed and apprieciated.
Thanks in advance,
Regards T.Olsen.
ps. I'm looking to do columnclick so I can sort, if there is a sample
someplace I'm interested in seeing it. Tag: Help!!! Date operations Tag: 192200
CSng adds erroneous digits to the value
I'm stumped with what's happening here. I have a value in a CSV that I
want to round. I wanted to use CSng to force the single data type so
that an error would not occur from trying to round a text string. My
code is simple:
Cells(i, 8).Value = Round(CSng(Cells(i, 10).Value, 4))
where i is an integer used in a loop to run down the cells in columns 8
and 10.
For some reason when I set the value in Cell(i,8), Excel is adding some
apparently random erroneous digits to the end of the value. So for
example, a value appearing as 12.1294 in Cell(i,10) comes out as
12.12946789 in Cell(i,8). It appears to be something that happens when
I insert the value into a cell too. If I just display
Round(CSng(Cells(i, 10).Value, 4))
in a Msgbox everything looks fine. Anybody know what might be causing
this? I'm running MS VB 6.0 with MS Excel 2000. Tag: Help!!! Date operations Tag: 192196
directories permition enumeration ?
hello there
any body with a script to view folders and files permissions in windows ?
I need to write a script to give me a report on who has what on what
file/directory in a drive.
Thanks Tag: Help!!! Date operations Tag: 192195
Script writing Training
I am looking to do a lot of scritpt writing training on my one. I have found
Don Jones training at
http://www.scriptingoutpost.com/category.aspx?categoryID=3 as was looking for
comments.
I am wanting to start with some type of classroom training without having to
sit in the class all day. More of an hour a day type of thing...
Any thought? Tag: Help!!! Date operations Tag: 192192
Help Needed Please -- input function and using the input
Ok so here's teh deal i am totally new to scripting but managed to
create a script in which a prograame called pslist(a tool to log
process data) runs from a locotion on the drive and also checks a file.
This script works fine but only on local system and for local
processes.
I included in the script an input box for user to input the ip address
of the remote machine.
But i dunno how to use this Input data within my script to run pslist
with the remote machine switch.
The code is below, Please any help would be really great.
Option Explicit
Dim objFSO,Input
Dim objShell,strSysDrive
Set objShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
strSysDrive = objShell.ExpandEnvironmentStrings("%SYSTEMDRIVE%")
If objFSO.FileExists (strSysDrive & "\testfolder\ps.txt") Then
Wscript.Echo "Change the name of PSLIST log files before running
another test"
Wscript.Quit
Else
Input = InputBox("Enter the IP Address or the name of the remote
server")
objShell.Run "%comspec% /T:2E /k %systemdrive%\testfolder\pslist.exe
pslist -s \\ "
objShell.Run "%comspec% /T:2E /k %systemdrive%\testfolder\pslist.exe
pslist -s >>%systemdrive%\RMQCA\ps.txt"
End If
Input = InputBox("Enter the IP Address or the name of the remote
server")--->> this is what will give the user to fill in the ip
address.
objShell.Run "%comspec% /T:2E /k %systemdrive%\testfolder\pslist.exe
pslist -s \\ --->> this is where i need that ipaddress to be so that i
can run pslist like :
pslist -s \\ipaddress
I hope i explained what i am after. Thank you all once again Tag: Help!!! Date operations Tag: 192186
format time as 24 hour time
Does anyone know an easy way to format a time string in a 24 hour clock
setting (no AM/PM) in classic ASP ?
i.e.
HH:MM:SS
vbscript/asp doesn't support the Format statement, and FormatDateTime(Now(),
vbShortTime) will only give HH:MM
I really don't want to have to create vb dll just for this....
Thanks,
Mike Tag: Help!!! Date operations Tag: 192177
Help with script
I have a script that I am using that will change the users password based on
a list from a text file, I am also adding notes in the "Info" field in AD,
the questions I have is how can I append to the current info that is in
there. When I run the script it will replace what ever information is in
there. This is what is running against the users account. I want to append
to this not replace what is there already...
Thanks
Gavin...
objUser.Put "Info", "Password changed on 06/06/2006 by Tech Services"
On Error Resume Next
objUser.SetInfo Tag: Help!!! Date operations Tag: 192167
script auditing for a specific folder
Hi all,
I need to modify 500 users winnt ( and a couple of others) folder to
enable auditing for Everyone and set it to fail for full control. I
also need to enable this to propagate down to all files and folders.
Finally, this needs to be done on winxp and 2000. I've been search the
group but have come up empty. Surely there's got to be some way to
script this out. Thanks in advance for ANY help. Tag: Help!!! Date operations Tag: 192166
wsharguments length limit?
Getting a little closer to having this working (thanks for the previous
ideas!)
I now find that if I pass in my second argument to this code:
Option Explicit
Dim objArgs
Set objArgs = WScript.Arguments
Sub CallExcelMacro(strPath, strEName, strMacro)
Dim objXL
Set objXL = WScript.CreateObject("Excel.Application")
objXL.WorkBooks.Open strPath & strEName
objXL.Visible = FALSE
objXL.Run(strMacro)
objXL.Quit
Set objXL = Nothing
End Sub
Call CallExcelMacro(objArgs(0), objArgs(1), objArgs(2))
so that it's longer than 15 characters, then the script won't run.
Ironically, the strPath variable is longer and doesn't seem to cause any
problem. (So maybe it's something else?)
The code that works (by renaming my spreadsheet to accomodate, which isn't a
long term option) from my other (SAS) program that calls this is:
rc = system('cscript.exe //nologo
"\\inlrc11\abc\mets\general\CallExcelMacro.vbs"
"\\inlrc11\abc\temp\state excel\"
"ST Weekly 70170.xls"
"LoadData"');
(The system function basically calls cscript in command line fashion.)
However, the following bombs:
rc = system('cscript.exe //nologo
"\\inlrc11\abc\mets\general\CallExcelMacro.vbs"
"\\inlrc11\abc\temp\state excel\"
"ST Weekly 701709738.xls"
"LoadData"');
Any thoughts on why the longer Excel filename causes this to bomb? Probably
something dumb I'm doing, but this isn't my main language. Again, many
thanks! Tag: Help!!! Date operations Tag: 192165
Can VBS read an environment variable?
We have a vbs script that has hardcoded a destination folder, including
drive letter. Unfortunately, our servers sometimes have the destination on
the C: drive and others may, for example, be on an F: drive. I am thinking
the way to generalize the script would be to set a global environment
variable and instead of hardcoding the drive, substitute the environment
variable value instead.
Does anyone know if this is doable? Tag: Help!!! Date operations Tag: 192163
getting error error '80072116'
Hi all,
I'm trying to convert a vbscript that unlocks domain user accounts from
vbscript to asp
there is a particular portion of the code, see below, that fails with
error error '80072116' :
I'm running this code on a windows 2003 domain.
Any help would be very much appreciated !
Thanks in advance.
' Convert user NT name to Distinguished Name.
--> THIS FAILS --> objTrans.Set ADS_NAME_TYPE_NT4, strNetBIOSDomain &
"\" & strUserNTName
If Err.Number <> 0 Then
On Error GoTo 0
Response.Write "User " & strUserNTName & " not found"
Response.End
End If
On Error GoTo 0
strUserDN = objTrans.Get(ADS_NAME_TYPE_1779) Tag: Help!!! Date operations Tag: 192159
Can't use string in request.form
Any one see whats wrong with this? How can I get around it
echo "REAL " & aryImf(CDC_FIELD,intFields) & "<BR>"
echo "STRING " & Request.Form(aryImf(CDC_FIELD,intFields)) & "<BR>"
My output says
REAL imf_origin
STRING Tag: Help!!! Date operations Tag: 192158
Running script as a service fails to write file
I have a VBScript that is run as a Windows service. It works fine
except for the fact that an output file I write does not get created or
written to. If I run the same script manually (not as a service) the
file is written correctly.
The service is running as the localsystem account with interact with
desktop enabled.
Any thoughts on why the file does not get created?
TIA Tag: Help!!! Date operations Tag: 192157
running object table
I want to create an application launch button within a running application
but want to launch a new instance only if an existing instance of the program
is not running. Both applications are Web apps so just understanding if I.E.
is running is not enough. Any suggestions/samples would be appreciated. Tag: Help!!! Date operations Tag: 192155
Script to know default printer
Hi all,
I need to know who print conection is the deafult in use ?? how can know
this???
anybody can help me??
thanks in advance
Daniel Tag: Help!!! Date operations Tag: 192154
Need help filtering /querying specific text from large text /log file
Hi everyone
I need a script to pull only a small part of text from each line in my
log file with 2000 plus lines. each line contains various web trending
data, ip address, url etc. i need to pull specific part of each line
from the text file/log and put it in its own output.txt file. each
line has a url with various pdf file name at the end need to pull only
the text after the url section example (
www.blahblah.com/salestools/bysn-6lydea_ro_en.pdf) I need only the
info after salestools/ and before .pdf put into its own output
file. Because there are over a hundred pdf names i need this to be a
wildcard. if possible i need to group them as well, (put similar
/same text names in their own colum or group in the output file.)
any ideas? Tag: Help!!! Date operations Tag: 192147
How can I follow a trail of 302 redirects with MSXML2.XMLHTTP?
Hi all ...
I have an interesting one here. I have some code that I've been using
for years to pull down HTTP content as needed. However, I've just run
into a situation that I've never seen before, and can't quite figure a
way around ...
Background: If a URL fed to MSXML2.XMLHTTP via VBScript returns a 302
"redirect" when loaded - VBScript will crap out on the page load due to
security settings in IE, if the redirected URL is in another domain.
You won't get any content back as a part of the response, and the HTTP
status code actually comes back as "0". However ... if you enable the
"Access data sources across domains" option in the security settings
for IE - the MSXML2.XMLHTTP control will follow the 302 path and
eventually get the final result page and return the contents to you.
(/RANT-ON ... I shouldn't have to change settings in IE to control
how my VBScript program will work! Ugh! /RANT-OFF)
However, I would like to detect this 302 activity and track it from the
starting page to the ending page. For instance, here's WGET tracking a
two-layer redirect from a Feedburner link that demonstrates the
situation:
1. WGET http://feeds.geffen.com/artist/robzombie/content?m=145
HTTP request sent, awaiting response... 302 Moved Temporarily
Location:
http://feeds.feedburner.com/~r/artist/robzombie/content/~0/145
[following]
2. WGET http://feeds.feedburner.com/~r/artist/robzombie/content/~0/145
HTTP request sent, awaiting response... 302 Moved Temporarily
Location:
http://www.geffen.com/artist/news/default.aspx/nid/8031/aid/414/?utm_s
ource=rss&utm_campaign=rss&utm_medium=News&utm_content=nid_8031
[following]
3. WGET
http://www.geffen.com/artist/news/default.aspx/nid/8031/aid/414/?u
tm_source=rss&utm_campaign=rss&utm_medium=News&utm_content=nid_8031
Resolving www.geffen.com... 192.251.67.164
Connecting to www.geffen.com|192.251.67.164|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 8,294 (8.1K) [text/html]
Here's some code I put together, to try to loop through each redirect
until a final non-302 result is returned ... and state what the final
link was. But I can't seem to find any way to get this concept to work
based on what MSXML2.XMLHTTP provides me, given its interaction with
Internet Explorer. Basically, if I enable the "Access data sources
across domains" the control will simply follow the 302's and not tell
me about it, and return the final page but with a link that
(technically) doesn't match. If I disable the option, the GET
performed by XMLHTTP craps out, returns a 0 result code.
Any thoughts on a way to accomplish this? Is it even possible, or am I
trying to do something that is completely outside of the control
provided by MS?
Thanks in advance ...
Const READYSTATE_UNINITIALIZED = 0, _
READYSTATE_INITIALIZED = 1, _
READYSTATE_LOADED = 2, _
READYSTATE_INTERACTIVE = 3, _
READYSTATE_COMPLETE = 4
MaxLoadTime = 20
MaxLoops = 10
url = "http://feeds.geffen.com/artist/robzombie/content?m=145"
StatusResult = 302
LoopCount = 0
wscript.echo "START: " & url
Do while loopcount < maxloops and statusresult = 302
loopcount = loopcount + 1
CheckPageLoadTime = 0
PageLoadStartTime = now()
Set objHTTP = CreateObject("MSXML2.XMLHTTP.3.0")
Call objHTTP.Open("GET", url, TRUE)
objHTTP.Send
Do Until objHTTP.ReadyState = READYSTATE_COMPLETE or CheckPageLoadTime
> MaxLoadTime
wscript.sleep 100
PageLoadEndTime = now()
CheckPageLoadTime = DateDiff("s", PageLoadStartTime, PageLoadEndTime)
Loop
HTTPGET = objHTTP.ResponseText
StatusResult = objHTTP.Status
HTTPRedirectLocation = objHTTP.GetResponseHeader("Location")
If CheckPageLoadTime > MaxLoadTime then
wscript.echo "TIMEOUT"
end if
IF StatusResult = 302 then
wscript.echo "REDIRECT: " & HTTPRedirectLocation
url = HTTPRedirectionLocation
end if
loop
wscript.echo "END: " & url
wscript.echo
wscript.echo "HTTP Status: " & StatusResult
wscript.echo "Redirects: " & loopcount
Here's my results with the security option set to disabled:
START: http://feeds.geffen.com/artist/robzombie/content?m=145
END: http://feeds.geffen.com/artist/robzombie/content?m=145
HTTP Status: 0
Redirects: 10
And here's my result with the security option set to enabled:
START: http://feeds.geffen.com/artist/robzombie/content?m=145
END: http://feeds.geffen.com/artist/robzombie/content?m=145
HTTP Status: 200
Redirects: 1
So, to me, it seems as though it is possible to trace the string of
302's through the MSXML2.XMLHTTP control??
Thanks in advance.... Tag: Help!!! Date operations Tag: 192146
Passing parameters from command line
Hopefully this is pretty simple and I'm just not seeing it in my book. I
have a vbs script that calls Excel and runs a macro. I would like to
generalize it so that I can pass in the path to any spreadsheet, the name of
the spreadsheet and the macro to run. I can write a sub to do it and then
call the sub, but because of another language involved in this process, for
it to work I need to be able to call the script via command line and pass the
parameters that way.
Any help would be greatly appreciated. Thanks Tag: Help!!! Date operations Tag: 192144
export startup and shutdown times to file
Hello, I'm very new to scripting and am looking for help, as general or
specific as you care to provide. I want a script that would be run at
computer startup and computer shutdown to record the computer name and time
of the event to text/database/excel/e-mail (I don't care which right now)
file. This wouldn't be the same as reading the event log, as getting
updates from the event log would require the computer to be on.
The general point is that we have users that often spend months away from
the office, and we have no idea who they are or when this occurs. If their
computers are not on, the WSUS server and HFNETCHECK cannot update them. If
I have a way of seeing which machines are off for extended times, we can turn
them on and manually update them.
We would place these scripts in the startup/shutdown area of Group Policy.
Thanks for any ideas. Tag: Help!!! Date operations Tag: 192141
Trouble conting.. script out of range
I'm not sure why, but it seems pretty random. I am getting script out of
range here and there. Here is the part im having trouble with now.
Const ARY_ROWS = 2
Const CDC_FIELD= 0
Dim iRow
For iRow = 0 to Ubound(aryImf,ARY_ROWS)
echo iRow
If aryImf(iRow,CDC_FIELD) = strField Then
My output looks like this: (and I don't know why 0 shows 3 times before
the 1).
0001
Microsoft VBScript runtime error '800a0009'
Subscript out of range: 'iRow' Tag: Help!!! Date operations Tag: 192140
input type = "File" in an HTA
Hi,
I have written a script to do an inventory of servers in my domain. I
have been asked to revise the script so that it will take a list of
servers from a text file and process them one at a time.
I tried to use the following input in my HTA;
<p align="center"><font size="4"> Enter Server Text File Here: <input
type="File" name="Stxt" Size="40"></p>
The problem is that it only pulls the file name and NOT the full path,
so I get a file not found error when I run my script. Is ther a way to
get the full path and file name to return from this method?
<-------------------------Code snip
------------------------------------>
If Trim(Stxt.value) <> " " Then
cList = Trim(Stxt.value)
statval.value = statval.value & " " & cList
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("cList", ForReading)
Do Until objTextFile.AtEndOfStream
<----------------------------End Snip
------------------------------------->
OldDog Tag: Help!!! Date operations Tag: 192137
TRANSFORM/pivot table in VBS
code:
'-----------------------------------------------
Set objConnection = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
objConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & str_BaseGetPath & ";" & _
"Extended Properties=""text;HDR=NO;FMT=Delimited"""
'"TRANSFORM Count(tlnk_Fact.Field2) SELECT tlnk_Fact.Field1 AS
District, Count(tlnk_Fact.Field2) AS [Total Count] FROM " & file_Names
& " GROUP BY tlnk_Fact.Field1 PIVOT tlnk_Fact.Field4;"
str_SQL = "TRANSFORM Count(tlnkFact(1)) SELECT tlnkFact(0) AS District,
Count(tlnkFact(1)) AS [Total Count] FROM " & _
file_Names & " as tlnkFact GROUP BY tlnkFact(0) PIVOT tlnkFact(3);"
rs.Open str_SQL, objConnection, adOpenStatic, adLockOptimistic,
adCmdText
'-----------------------------------------------
returns a "undefined function [tlnkFact]" error.
What am I doing wrong? the following works
str_SQL = "Select * from " & file_Names Tag: Help!!! Date operations Tag: 192130
VB MACRO for Publishing the files
Hi,
Im new to scripting
For a project implementation i need VB MACRO to do the following task.
The core idea is to Publish the pdf files from one drive to an another
dirve to respective user folder for the following scenerio.
Lets start ...
A database table "User" have three columns
REPORT --> it has the pdf file names
USER ---> it has the user name
& STATUS --> it has status whether the file has been published
succssfully
We have the folder in drive H: ( this contains pdf files as in
modulewise, say three modules)
a) ACR
b) ACR-ALL
c) ACR-Netdebit
Each folder contains various pdf's files
On the other hand drive G: ( it contains user names in folder wise)
i have to create various folder on user names(like john, smith, ..)
these folders should be created by refering that "User" table .
Now the core task is to take the pdf from H: to publish in G: on
respective user folder that even inside date folder. ( let say today's
date is june 6, 2006) the folder struture should be like this
2006-->june-->06
Also for every month folder we need create date folder(say 1st june to
30th june).
Also we need to update the status on the table sucess or failure.
I need the Macro vbscript (code) to acheive this.
Pls help me in this regard.
Im eagerly waiting for your response.. this will help me lot..
Thanks in advance.
Thanks & Regards,
_______________
Moulee Tag: Help!!! Date operations Tag: 192122
Copying a file in a series of directories
Hi all,
Situation :
* Windows 2000 Domain
* All home directories are gathered in
\\DomainServer\Home_Directories (approx 200 dir)
What I need to do is to copy one configuration file into each home
directories contained in "\\DomainServer\Home_Directories".
What is the easiest way to achieve this?
I am an utter noob in wsh/vbs/bat scripting....so thank you in advance
for helping.
Regards Tag: Help!!! Date operations Tag: 192121
Desktop VB Script
Does anyone know how I can get a classic desktop and arrange the icons for
all users via a vb script?
--
««««««««««««««««««««««««««««««««
Todd Gregory
Citrix Certified Administrator
Professional Teledata
175 Canal Street
Manchester, NH 03101
phone 800.344.9944
fax 603.625.5078
t.gregory@proteledata.com
Visit our web site www.proteledata.com
»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» Tag: Help!!! Date operations Tag: 192120
query computer name
I'm a freshman to vbscript, i write a script to query computer name by
ip address as list:
strcomputer = "192.168.0.1"
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &
strComputer & "\root\default:StdRegProv" )
' obtain computer name
strKeyPath =
"SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName\"
strEntryName = "ComputerName"
objReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath & SubKey
,strEntryName,strHostName
Wscript.Echo strHostName
it always return the error of type mismatch, can somebody help me
check what's wrong with this script? thanks in advance!
--
fale
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------ Tag: Help!!! Date operations Tag: 192114
how to run a vbscript from windows service
in the ws i have a client which on start starts an appln exe which in
turn calls a vbscript to establish the connection..
when the appln exe is made to run separate the vbscript runs fine..
when it is made to start from the client as the appl exe depends on
this client it says cannot create object to establish connection..but i
am sure i have access rights..
the vb script has set obj=createobject("servicename","ipaddress") Tag: Help!!! Date operations Tag: 192113
Reg Password Complexity for a local account
Hi,
Could anyone plz let me know how to obtain the password complexity for
a local user.
My code is as follows:
Set objDomain = GetObject("WINNT://INGBTCPIC5dt440/localUser)
intPwdProperties = objDomain.Get("PwdProperties") // There is no such
property.
WScript.echo "pwdProperties = " & intPwdProperties
For Each Key In objHash.Keys
If objHash(Key) And intPwdProperties Then
WScript.Echo Key & " is enabled"
Else
WScript.Echo Key & " is disabled"
End If
Next
This code will not work as the proprerty "PwdProperties" is not found
for local user.Is there
any other way to obtain the password complexity?
Thanks & Regards.
Sharan Tag: Help!!! Date operations Tag: 192110
Hello all, I must realize a script that it eliminates file rar older
than 5 days regarding the date retrieve by function Date(). How I can
make?
Maurizio wrote:
> Hello all, I must realize a script that it eliminates file rar older
> than 5 days regarding the date retrieve by function Date(). How I can
> make?
>
> Thanks all!!!