accessing an access (.mdb) file on my pc and the net
Is there a way to access a .mdb (Access) file on my pc and on my web site at
the same time. The idea here would be to be able to update one from the
other directly.
Please let me know where to look for this, any sample code would be great.
Thanks.
Scott Baxter Tag: VBscript Training Tag: 150066
checksum to be applied in VB script
Hi All,
And i have a new problem here, I am copying a lot of files(*.txt,*.doc
etc) to a remote machine, now is there any way i can apply a checksum
on that.I need to verify wheather all the required files have been
copied correctly.Any ways u guys can suggest to apply that.
Thanks in advance for ur suggestions.
Gaurav Tag: VBscript Training Tag: 150050
VBS close any executable
Any way to have a VBS script close an Executable, for example, close
Internet Explorer (iexplore.exe)?
Any help would be great thanks! Tag: VBscript Training Tag: 150048
File Version in Other Version Information
I am attempting to find the File Version of a file and am specifically
looking for the File Version that appears in the Other Version
Information. The value of File Version is different than the File
Version value in the Other Version Information section and this Other
Version Information File Version value is what I need to properly
identify the file (happens to be a graphics driver file). I have
searched the newsgroups and have been unsuccessful. I have attempted
the following:
1. Using the GetFileVersion of the FileSystemObject and
2. GetDetailsOf
The GetDetailsOf is close but I am not seeing the values I am
expecting. I am wondering if this specific extended property is NOT
retrievable. It would seem there is a way but I have yet to find it.
I have also searched the registry and have been unsuccessful going
that route as well. Of course I may be overlooking a much simpler
solution, so I am open to any feedback/assistance.
Thanks in advance.
R Tag: VBscript Training Tag: 150047
Advice on reporting via ASP
Hello everyone,
I have recently developed a web application across my clients intranet. We
used ASP with Interdev 6.0 and SQL server as the backend.
They have now come to me asking me to develop some reports that can be
accessed via a drill down within the app. They don't have Crystal Reports so
this is not an option. Can anyone suggest an alternative to using crystal
reports to publish dynamic reports via the web and ASP?
Thanks in advance,
Jeff Tag: VBscript Training Tag: 150046
Email Attachment Using VBScript
Hello,
I am using the following code that I found on this message board to try and
send an email attachment. It is not working. Depending on what I change I
keep getting one of three different errors. I get an error stating that the
specified protocol is unknown; I also get an error that the system cannot
find the file specified when I know it is in the correct location; and I get
an error stating that the Object doesn't support this property or method:
'objMessage.AddAttachment'. Can anyone help with this? I was trying to run
this on my SMTP server directly.
Thanks,
Robbie
Set objEmail = CreateObject("CDO.Message")
objEmail.From = "someone@somedomain.com"
objEmail.To = "account@domain.com"
objEmail.Subject = "test message"
objEmail.AddAttachment "d:\attachment.txt"
objEmail.textbody = "Text of message goes here"
objEmail.Send Tag: VBscript Training Tag: 150037
Reading first 2 characters/line from textfile
This is probably a stupid thing, but I have a killer headache and
can't see the problem. I have an asp page that reads from a
tab-delimited text file.
textfile = fileObj.OpenTextFile(Server.MapPath("textfile.txt"), 1)
My script is SUPPOSED to move through the text file line by line and
perform the following:
- set a variable "key" to the first two characters of the line
- if key matches another variable ("selection"), then do a bunch of
stuff. if not, move to the next line.
Everything works perfectly EXCEPT -- in addition to getting the
results I expect, I am getting a match if the two characters exist
anywhere in the line.
Here's the code for this part:
do while textfile.AtEndOfStream = false
key = textfile.Read(2)
if key = selection then
(blah blah blah)
end if
loop
I understood that Read(2) would read the first two characters of the
line unless I did something that moved the cursor. Do I need to
specify the beginning of the line? Or is something else going on?
My textfile looks something like this:
ST Address City Zip
Where ST is the two letter abbreviation for state. But I'm getting a
match for Nebraska (NE) if the line looks like:
CA 1234 Main NE San Diego 97111
Help??? Tag: VBscript Training Tag: 150035
stdregprov enumkey problem
I am having difficulty with enumerating the contents of
the HKEY_USERS key of the registry. When I run it against
a Windows XP Pro SP1 box, it works properly. However, a
Windows 2000 Pro SP4 box does not return the correct
information (It looks like it might be information from
the HKEY_CURRENT_USER?).
I suspect it's a problem with the provider, but don't
know for sure. If so, is anyone aware of a workaround?
TIA,
Stephen
Here's my code:
PCName = "."
Set objLocator = CreateObject
("WbemScripting.SWbemLocator")
Set objService = objLocator.ConnectServer
(PCName, "Root\DEFAULT")
If Err.Number <> 0 Then
MsgBox "An error occurred while connecting to
the remote workstation.", vbCritical, "Error!"
Err.Clear
Exit Sub
End If
Set objRegistry = objService.Get("StdRegProv")
sPath
= "Software\Microsoft\Windows\CurrentVersion\Run"
result = objRegistry.EnumKey(HKEY_USERS, "",
arrSubKeys)
If Err.Number = 0 Then
For Each strSubKey In arrSubKeys
If Right(strSubKey, 8) <> "_Classes" Then
' objRegistry.GetStringValue HKEY_USERS,
strSubKey & "\" & sPath, strValue
' MsgBox strSubKey & vbCrLf &
strValue 'String(Len(strSubKey), "-")
varTemp = strSubKey & "\" & sPath
GetNCheck HKEY_USERS, varTemp
End If
Next
Else
MsgBox "Error " & Err.Description
End If Tag: VBscript Training Tag: 150034
SQL Server on Windows XP Pro and ASP
I want to set up SQL Server on Windows XP Pro so that I can use the database
capabilities of ASP and IIS. I am probably using some incorrect settings,
but I am not sure what they are. Here is what I am currently doing:
When I run sqlservr.exe I see the following:
2003-12-19 15:51:28.20 server Microsoft SQL Server 2000 - 8.00.760
(Intel X8
6)
Dec 17 2002 14:22:05
Copyright (c) 1988-2003 Microsoft Corporation
Desktop Engine on Windows NT 5.1 (Build 2600: Service Pack 1)
2003-12-19 15:51:28.20 server Copyright (C) 1988-2002 Microsoft
Corporation.
2003-12-19 15:51:28.20 server All rights reserved.
2003-12-19 15:51:28.20 server Server Process ID is 2992.
2003-12-19 15:51:28.21 server Logging SQL Server messages in file
'C:\Program
Files\Microsoft SQL Server\MSSQL\LOG\ERRORLOG'.
2003-12-19 15:51:28.28 server SQL Server is starting at priority class
'norma
l'(2 CPUs detected).
2003-12-19 15:51:28.56 server SQL Server configured for thread mode
processin
g.
2003-12-19 15:51:28.57 server Using dynamic lock allocation. [500] Lock
Block
s, [1000] Lock Owner Blocks.
2003-12-19 15:51:28.79 spid4 Starting up database 'master'.
2003-12-19 15:51:29.14 spid4 0 transactions rolled back in database
'master'
(1).
2003-12-19 15:51:29.14 spid4 Recovery is checkpointing database 'master'
(1)
2003-12-19 15:51:29.23 server Using 'SSNETLIB.DLL' version '8.0.766'.
2003-12-19 15:51:29.23 spid5 Starting up database 'model'.
2003-12-19 15:51:29.28 spid4 Server name is 'NJS'.
2003-12-19 15:51:29.28 spid4 Starting up database 'msdb'.
2003-12-19 15:51:29.59 spid5 Clearing tempdb database.
2003-12-19 15:51:30.15 spid5 Starting up database 'tempdb'.
2003-12-19 15:51:30.26 spid4 Recovery complete.
2003-12-19 15:51:30.28 spid4 SQL global counter collection task is
created.
2003-12-19 15:51:32.18 server SQL server listening on Shared Memory.
2003-12-19 15:51:32.20 server SQL Server is ready for client connections
When I go to Data Sources (ODBC) --> System DSN --> Configure I see the
following after choosing my settings:
Microsoft SQL Server ODBC Driver Version 03.81.9041
Data Source Name: NJS
Data Source Description:
Server: NJS
Database: (Default)
Language: (Default)
Translate Character Data: Yes
Log Long Running Queries: No
Log Driver Statistics: No
Use Integrated Security: Yes
Use Regional Settings: No
Prepared Statements Option: Do not create temporary procedures
Use Failover Server: No
Use ANSI Quoted Identifiers: Yes
Use ANSI Null, Paddings and Warnings: Yes
Data Encryption: No
And running Test Data Source... gives me the following:
Microsoft SQL Server ODBC Driver Version 03.81.9041
Running connectivity tests...
Attempting connection
Connection established
Verifying option settings
Disconnecting from server
TESTS COMPLETED SUCCESSFULLY!
My ASP code that is supposed to connect to the Database is:
Set conn=Server.CreateObject("ADODB.Connection")
connectstring="Provider=SQLOLEDB.1;Data Source=NJS;Initial
Catalog=pubs;Integrated Security=SSPI"
conn.Open connectstring
And the error I receive when I open the ASP page is:
Technical Information (for support personnel)
a.. Error Type:
Microsoft OLE DB Provider for SQL Server (0x80004005)
[DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access
denied.
/testdb.asp, line 25
b.. Browser Type:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; FunWebProducts; .NET
CLR 1.0.3705; .NET CLR 1.1.4322)
c.. Page:
GET /testdb.asp
d.. Time:
Friday, December 19, 2003, 3:49:59 PM
If anyone is able to help me or tell me specific instructions on how to give
XP Pro's IIS DB capabilities, I would GREATLY appreciate it. Thank you.
--
Nathan Sokalski
njsokalski@hotmail.com Tag: VBscript Training Tag: 150032
Change color of input control at runtime
Please forgive, I know this must be an easy one but I can't quite figure
it out. Based on the value selected in a listbox I want to change the
background color of an input control at runtime. Please tell me this is
an easy.....
SusanC
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it! Tag: VBscript Training Tag: 150030
Open TextStream on network drive
Is there some limitation using file system objects on a network drive? I'm
trying to execute the following code:
set tsInput = fso.OpenTextFile("\\shipping\c\workfolder\items.txt")
but keep getting an "Object not set" error. If I run the same code while
pointing to my local hard drive, it works fine. I've double checked and
have read/write permisson on the drive in question, so that doesn't seem to
be the problem. Anybody have any idea why this won't work?
Thanks in advance.
Jim Tag: VBscript Training Tag: 150026
WMI/WBEM remotely against Win9x
In Win9x machines with WBEM/WMI installed is it possible to access anything
from them remotely?
We have tried numerous vbscripts that work just fine against Win2K/XP
machines and query different information from them from another 2K/XP
machine on the network. But all the Win9x machines return an "RPC
unavailable" error.
What good is WBEM installed on win9x if it can't be used remotely?
If it can be, can someone please point me to resources with samples and
maybe explanation of items that are accessible in win9x.
TIA
Fred Tag: VBscript Training Tag: 150022
wscript or shell changes with Office 2003????
I had the script below running from an internal web page
that calls the script. There is other code to change
registry settings that has been stripped out. This
portion of the code was running fine with Office 2000.
We moved to Office 2003 and the script won't open the
spreadsheet now. Is there something new about the shell
command or wscript file in 2003 that would not allow this
to run???
dim direty1
direty1 = "T:\IncidentReporting\Reports\safety.xls"
Set shell = CreateObject("WScript.Shell")
shell.run direty1
Thanks in advance for any help!!
Gordon Cashmore Tag: VBscript Training Tag: 150008
Permission denied on CreateObject
I am getting an erorr #70 when executing this line in a
VBScript:
Set IE = CreateObject("InternetExplorer.Application")
It works fine on the same workstation under a different
user. Both users are part of the local administrators
group.
Any help?
TIA Tag: VBscript Training Tag: 150001
How do teh do this?
Hi.
I'm a bit curios about a thing that I saw a few days ago.
In a scripts, they hade the ability to write the following
to present the user with a very nice dialog box, with
progress bar and everything.
Set oStatusBox = CreateObject
("InternalScriptRuntime.StatusBox")
oStatusBox.Create
' Set's the titel of the dialog box
oStatusBox.SetTitle "Testbox"
' Adds the first message to the text box
oStatusBox.AddMessage "Yeay!!"&vbCRLF
' Moves the progress bar to 30%
oStatusBox.SetProgress 30
WScript.Sleep 1000
' Adds a second line to the textbox box
oStatusBox.AddMessage "This is very nice!"&vbCRLF
' Moves the progress bar to 70%
oStatusBox.SetProgress 70
WScript.Sleep 1000
' Closes the dialog box
oStatusBox.Destroy
How are they abel to do things like this? I want to be
abel to do this? I know that this must be some addedd
program or .dll file that give them this "ability", but
how do I do this! That's what I want to know...
/Johan Christensson Tag: VBscript Training Tag: 149998
vbscript and sending email
I need to use vbscript to send email:
I try to use CDO but don't know how to declare the CDOSYS.DLL . Is it a way
to declare it ?
I use the MAPI system to but have problems with it .
Did you have any idea about where i can find informations about this ?
THanks Tag: VBscript Training Tag: 149996
VBscript access to Printer location field.
I looked around and it seems nobody has needed to access the extended
attributes of a Printer, e.g. location,comments
I did track down the information as a GDI call to GetPrinter to
populate a PRINTER_INFO_2 structure. Looks like you can do this via
C++ or VB, but its not scriptable.
Will I have to write my own DLL to expose those attributes to
vbscript? Or is there a better way?
Thanks,
-Pete Tag: VBscript Training Tag: 149995
(FSO) is this posable?
I am looking for a VBScript that will change the file association of a file
type (accessing FSO=>type?) (example: JPG = Internet explorer but I want to
change it to JPG = Photoshop) Can it be done? I thought this would be right
up VBScript\WSH ally but I can not find a script that will accomplish this.
I have tried using a registry hack with out success.
Thanks Tag: VBscript Training Tag: 149994
Permission Denied with File.Copy
For a long time we have had a VBScript running on one
server that creates any necessary folders and copies a set
of files to these folders.
The script uses the Scripting.FileSystemObject object and
the File.Copy method to do this via share. The script is
run via the Task Scheduler under a specific account. This
account is an administrator on both the soruce and
destination servers. It also has full control on the share
and the folder underneath.
It still creates folders successfully, but we get
a "Permission Denied" on the file copy! Logging in to the
source server as this user and copy the file manually
works! I am thinking that this must be caused by one of
the latest security patches that does not allow the file-
copy from a remote script, but I cannot figure out where
to set access to allow this.
Any ideas?
Stig Tag: VBscript Training Tag: 149990
Page that will modify words
hello.
I am thinking of doing a page that could be used for joking with friends..
My thought was to let users create a little list of word that they want to
be
changed with some other words in a web page.
The page that will be changed will be of the users choice as well.
This all will work someting like a "form" but the function that takes
a certain homepage and replaces the selected words with other words
is the problem.
I think i can use this object:
HTTP = Server.CreateObject("Microsoft.XMLHTTP")
HTTP.Open "GET", sUrl, False
Does anyone know of a better way to put a webpage into a string
and then send it back to a "_blank" browser?
Br,
Chotie
chot@home.se Tag: VBscript Training Tag: 149986
how to : disable certain user login in logon script ?
Hello
I want to deny some login of terminal users if the name of client PC
is not in the list.
How to write the logon script to do this?
Plz help, i am an newbird.
Thank u very much.
max.
email: 2609@21cn.com Tag: VBscript Training Tag: 149983
VBScript (ASP) and Outlook
Hi There,
I have been trying to instantaite an object of
Outlook using the statement
Set objOutlk = server.createobject("Outlook.Application")
in an ASP page.
I am getting an error
Server object error ASP 0177 (0x80080005)
Server execution failed
Can you help me with this. I have tried executing
this statement on various other machine. I have tried
reinstalling MS Outlook. I have been struggling with
this problem for past 4 days.
The object gets created when creating in Visual Basic
Project, but does not get created in an ASP page.
I would be obliged if you can help me.
Regards,
Shashi Tag: VBscript Training Tag: 149982
Problem with disconnecting
Hi!
I want to disconnect a connection named "Local connection"
I'm doing it like this:
Dim objShare
Dim objEveryColl
Dim objNetConn
Dim objShareCfg
Dim objNCProps
set objShare = Wscript.CreateObject("HNetCfg.HNetShare.1")
if(IsObject(objShare) = False) then
Wscript.Quit
end if
set objEveryColl = objShare.EnumEveryConnection
if (IsObject(objEveryColl) = False) then
Wscript.Quit
end if
For each objNetConn in objEveryColl
set objNCProps = objShare.NetConnectionProps(objNetConn)
If objNCProps.Name = "Local connection" Then
objNetConn.Disconnect()
End if
Next
End Sub
And I get an error in the line with disconnect command:
"Object needed: objNetConn"
Why???
Can anyone help me with this
Most of the code is taken from MSDN:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ics/ics/ics_and_icf_start_page.asp Tag: VBscript Training Tag: 149979
CopyFile Method
Pardon the question from a newbie:
I need to feed the objFSO.copyFile method both src & dest as variables
instead of fixed strings in quotes. I get an error everytime I do but fixed
strings work. Anybody done this before. Tag: VBscript Training Tag: 149976
Programmatically lockout his own user account
http://support.microsoft.com/default.aspx?scid=kb;en-us;q250873
This KB explains how to read or reset account lockout flag. Is it possible
to programmatically lockout his own user account? I want this script to be
executed as "Logoff" script ?
Thanks in advance
J Justin Tag: VBscript Training Tag: 149975
Help with Service Watchdog Script
Hi! I need help with a script, if anyone is willing and able to. Here
is the scenario that is plaguing me:
On a Windows Server 2003 machine, I have a particular Service that is
prone to stopping. It does not *crash*, so Windows 2003 does not register
it as a failure - thus, the Recovery Tab for the Service does nothing to
recover it.
As a result, I need something that will monitor the Service in question
and if it should stop *for any reason*, I want to wait about 30 seconds, and
then start it up again.
It has been recommended to me that I consider a WMI Script to accomplish
this. Of course, I am not very adept at scripting, so this makes thing
difficult, needless to say. :)
The best I could find was code that would, in theory, Start the Service
in question:
'**********************************************************
' This should start the Service "ServiceName"
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colServiceList = objWMIService.ExecQuery _
("Select * from Win32_Service where Name='ServiceName'")
For each objService in colServiceList
errReturn = objService.StartService()
Next
'**********************************************************
However, assuming that this works properly - it does not address the
aspect of Monitoring the Service to see if it has stopped or not.
And thus, I am asking for help to fill in the functionality that I am
missing. I need to consider the following points:
1. Will the script above work as it should to start the Service
"ServiceName" on a Windows 2003 Server?
2. Should the Service be Monitored by the Script itself - and thus (I would
imagine), the script would simply be run once as a Startup item on the
Server?
3. Or, should the Script simply be set to examine once, upon running,
whether the Service is stopped or not (acting appropriately, if it is not) -
and then have the Script scheduled to run regularly via some other method
(such as the Windows Task Scheduler)?
4. Or, was this all some cruel joke, and in fact, I am completely on the
wrong track for what I need? :)
Oh, and as an aside, whatever solution I ultimately use, *must* be able
to function while the Server is running, but NOT logged in.
I would appreciate any help anyone feels like offering. Thanks! Tag: VBscript Training Tag: 149974
Dynamically embedding include file in ASP page
hello, i was wondering if anyone knew how to do the following:
in my ASP (VBScript) page, i have a variable that contains the name of
an include file i want to embed in the ASP script, server-side. reason
for this is i have multiple include files and do not want to have to
include all of them in each page. example:
current ASP code:
<!-- #include file="include/file1.asp" -->
<!-- #include file="include/file2.asp" -->
<%
if (Request("iFile") = "file1.asp") then
Response.Write(getMyData()) ' function in include/file1.asp
elseif (Request("iFile") = "file2.asp") then
Response.Write(getYourData()) ' function in include/file2.asp
end if
%>
i want to be able to do the following ....
<%
Embed("include/" & Request("iFile")) ' is there a function like
this?
if (Request("iFile") = "file1.asp") then
Response.Write(getMyData()) ' function in include/file1.asp
elseif (Request("iFile") = "file2.asp") then
Response.Write(getYourData()) ' function in include/file2.asp
end if
%>
the second scenerio with the "Embed" function is psuedo-code,
obviously, but i was wondering if anyone knew of a way to actually
implement it?
thank you in advance Tag: VBscript Training Tag: 149962
Learning Resources
>I am looking to learn vb script to interface with a program that already
>exists. Does there exist documentation for Vb script like there is for c++?
>For example using vc6.0 I can look up almost any standard function on msdn,
>however for vb script as I understand it there is no compiler so there is
no
>vb script entries in msdn that i can find. What resources does one use to
>learn?
Ask this in this group: microsoft.public.scripting.vbscript
-- Tag: VBscript Training Tag: 149959
Counting files
I am new to scripting and need some help on a script that returns the total
number of files in a folder (subfolders included). I looked in my Windows
2000 Scripting Guide and could not find the property in the Win32_Directory
class. Basically, I need the number that is shown next to "Contains:" on
the General tab of a folder's properties. Any help will be appreciated.
Thanks,
Anthony Tag: VBscript Training Tag: 149958
Script Needed - Identify Local Service Account
I need a script that I can run locally (across network would be nice but not
necessary) that will check the local system and report any accounts that
have the Log on as a service right. Can anyone help me out? Thanks.
MD Tag: VBscript Training Tag: 149955
best way to check for server availability.
I am running a vbsvript in task scheduler downloading stock.
Whats the best way to check that the server is there before downloading xml
file.
Don Tag: VBscript Training Tag: 149946
Logon Scripts
I have a problem recently after upgrading to windows 2003
the "boss" thought it would be kool to tighten passwords
and use complex passwords..... Think is i keep getting
calls to reset passwords constantly because people keep
forgetting and they are not willing to use less complex
passwords...... I was wondering if anyone knew how i can
get a login script that i can put on the clients pc to
automatically log them in i know its not secure but the
building is secure and this only logs them into the domain
with no sensitive information. It dawned on me installing
small business in a remote location that it had a feature
that automatically logged u in during the installation
anyone know how i can do it Thanks in advance Tag: VBscript Training Tag: 149943
snmp
Hi All,
Anyone familiar with vbs howto read out printer snmp properties ?
Or maybe where to look on the internet for some examples / information ?
( In Perl there is a module with a get function , but I like to do it with
vbs , maybe there is something simulair)
thx
Bas
Holland Tag: VBscript Training Tag: 149942
Avoiding dialog box while print script runs
I have the following script to run a saved report. I have the script
scheduled to run but the user must press enter on a Print confirmation
dialog box before the report prints. I want the report to print without any
intervention. Below is the code.
====================================
Dim App,Rept
set App = WScript.CreateObject ("Crystal.CRPE.Application")
Set Rept = App.OpenReport ("C:\Documents and Settings\rpar\My
Documents\Crystal Reports\PD30.RPT")
Rept.Printout
====================================
Thanks Tag: VBscript Training Tag: 149933
IIS 6.0 Recordset Problem
I'm working on moving an existing system from IIS 5.0 to IIS 6.0.
Most items have been extremely slick...however...I'm having great difficulty
with Recordsets and Retrieving Autonumbers.
I cannot update a recordset then retrieve the autonumber field. It doesn't
generate an error, it's just null. I've tried to use bookmarks and requery,
but that doesn't work either. Anybody have experience with this? I need a
solution asap!
I appreciate any help you can give.
-Beau
Code:
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.ConnectionTimeout = 20
oConn.Open "dsn=training;database=training;uid=;pw=;"
strSQL = "SELECT * FROM tblQuestion"
Set oQuestion = Server.CreateObject("adodb.recordset")
oQuestion.Open strSQL, oConn, adOpenDynamic, adLockOptimistic
oQuestion.AddNew
oQuestion("Question") = Request.Form("Question")
oQuestion("AnswerValue") = Request.Form("AV")
oQuestion("TestID") = Request.Form("TestID")
oQuestion.Update
'This is the Autonumber Field From Access. Primary Key
intQuestionID = oQuestion("QuestionID")
oQuestion.Close Tag: VBscript Training Tag: 149929
retrieving values from a script in VB6?
Im using a scripting control "sc" on a VB6 form to calculate the left
hand sides of a series of equations. what is the most efficient way
of setting and retrieving values in/from the scripting namespace?
For example for these two simple equations:
x=2
if (x>1) then y=10 else y=1
Im using sc.ExecuteStatement on each line then retrieving y using
sc.Eval("y")
Is there a more direct way of linking the names in the script with
variables in VB6. For example can I register VB6's y in the script so
I can read the values directly. Tag: VBscript Training Tag: 149928
Problems with Concatenation of strings.
Hi All,
I wrote a script which determines the MAC address of the machine,
computername of the machine and creates a folder at a remote PC with
that MAC address. Now i want to create a text file under the MAC
folder and write the computer name in that text file.
However I get an error in line 3 stating that invalid path.
when i tried getting the outpout of Path written to a text file i
found that it's writing ---\\Remote Share\00-04-aa-ss-dd@\name.txt.
where '@' is some unprintable character.How do i get rid of it, i'm
struggling with it for last two days, can anybody help me it's bugging
me and spoiling my Chirstmas mood !!!!! anyways thanks a lot and wish
u guys a "Merry Christmas"
Gaurav
Here goes my script ...
1 set ofso = createobject("scripting.filesystemobject")
2 path = "\\Remote Share\" & GetMACAddress & "\Name.txt"
3 Set Outfile = ofso.createtextfile (Path, true)
4 outfile .writeline getComputerName
5 Function getComputerName()
6 set objComputer = CreateObject("WScript.Network")
7 getComputerName = objComputer.ComputerName
9 End Function
10 Function GetMACAddress()
11 set net = createobject("wscript.network")
12 set sh = createobject("wscript.shell")
13 sh.run "%comspec% /c nbtstat -a " _
14 & net.computername & " > c:\nbtstat.txt",0,true
15 set sh = nothing
16 set fso = createobject("scripting.filesystemobject")
17 set ts = fso.opentextfile("c:\nbtstat.txt")
18 macaddress = null
19 do while not ts.AtEndOfStream
20 data = ucase(trim(ts.readline))
21 if instr(data,"MAC ADDRESS") then
22 macaddress = trim(split(data,"=")(1))
23 exit do
24 end if
25 loop
26 ts.close
27 set ts = nothing
28 fso.deletefile "c:\nbtstat.txt"
29 set fso = nothing
30 GetMACAddress = macaddress
31 End Function Tag: VBscript Training Tag: 149923
Running logon script with higher permisson
I'm trying to get a logon script to overwrite a file on the local client
machine. The problem is that the users only got read access to that file. Is
there anyway to run the script with admin rights. I'm currently using a
group policy to run the script at logon.
Kind regards
Ulf Mansson
Serina Consulting Tag: VBscript Training Tag: 149922
Extracting Data using "internetExplorer.application"
How can you extract table and other data values using the
IE object("internetExplorer.application") to be used for
data parsing?
Jack Tag: VBscript Training Tag: 149921
Server Execution Failed for Outlook Object
Hi There,
I have been trying to instantaite an object of
Outlook using the statement
Set objOutlk = server.createobject("Outlook.Application")
in an ASP page.
I am getting an error
Server object error ASP 0177 (0x80080005)
Server execution failed
Can you help me with this. I have tried executing
this statement on various other machine. I have tried
reinstalling MS Outlook. I have been struggling with
this problem for past 4 days.
The object gets created when creating in Visual Basic
Project, but does not get created in an ASP page.
I would be obliged if you can help me.
Regards,
Shashi Tag: VBscript Training Tag: 149915
Parsing CSV and the horrors of living...
Hi,
I´m trying to parse a Outlook CSV file into a XML document. Below you see a
first attempt which converts a CSV file like this:
"Firstname","Middle
name","Lastname","Company","Adress","Zip","Email","status"
"Steve","","Steel","Bike Inc","Astreet 18","345 67","steve@steve.com","ok"
"Bob","Buckaroo","Bobson","Car Inc","Bstreet 17","456 78","bob@bob.com","ok"
Into a XML document like this:
<?xml version="1.0" encoding="ISO-8859-15" ?>
<list>
<contact id="1">
<firstname>Steve</firstname>
<lastname>Steel</lastname>
<email>steve@steve.com</email>
<adressline1>Astreet 18</adressline1>
<zip>345 67</zip>
</contact>
<contact id="2">
<firstname>Bob</firstname>
<lastname>Bobson</lastname>
<email>bob@bob.com</email>
<adressline1>Bstreet 17</adressline1>
<zip>456 78</zip>
</contact>
</list>
(The user gets to match the data fields in the CSV file and the XML file,
(since the CSV file often have 100+ data fields and I´m only interested in a
few of them) - see below)
---------- import01.asp
start ----------------------------------------------------------------------
-------------
<%
'
****************************************************************************
********
' Read and present the csv headings so user can match with XML data fields
'
****************************************************************************
********
Const Filename = "mycsvfile.txt"
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
set FSO = server.createObject("Scripting.FileSystemObject")
Filepath = Server.MapPath(Filename)
if FSO.FileExists(Filepath) Then
set file = FSO.GetFile(Filepath)
Set TextStream = file.OpenAsTextStream(ForReading, TristateUseDefault)
' Read the first line where the headings are, remove all quotes and split
it into an array
Dim myHeadingArray
myHeadingArray=Split((replace(TextStream.readline,chr(34),"")),",")
Set TextStream = nothing
Else
Response.Write("File " & Filename & " does not exist")
End If
Set FSO = nothing
%>
<HTML>
<HEAD><TITLE>Document Title</TITLE></HEAD>
<BODY>
Match data fields<BR> <BR>
<FORM NAME="theForm" ACTION="import02.asp" METHOD="POST">
<!-- The user assigns the right datafields with each other with these drop
down menus -->
<SELECT NAME="firstname"><% PopulateDropDown %></SELECT>firstname<BR>
<SELECT NAME="lastname"><% PopulateDropDown %></SELECT>lastname<BR>
<SELECT NAME="email"><% PopulateDropDown %></SELECT>email<BR>
<SELECT NAME="adressline1"><% PopulateDropDown %></SELECT>adressline1<BR>
<SELECT NAME="zip"><% PopulateDropDown %></SELECT>zip<BR>
<!-- Send along the csv filename -->
<INPUT TYPE="hidden" NAME="csvfile" VALUE="<% = Filename %>">
<INPUT TYPE="submit" NAME="button" VALUE="Make XML">
</FORM>
</BODY>
</HTML>
<%
sub PopulateDropDown()
For i = LBound(myHeadingArray) To UBound(myHeadingArray)
Response.Write("<OPTION VALUE=""" & i & """>" & myHeadingArray(i))
Next
End Sub
%>
---------- import01.asp
end ------------------------------------------------------------------------
-----------
---------- import02.asp
start ----------------------------------------------------------------------
-------------
<%
'
****************************************************************************
********
' Make a XML document
'
****************************************************************************
********
' Get array-numbers from form
firstname = Request.Form("firstname")
lastname = Request.Form("lastname")
email = Request.Form("email")
adressline1 = Request.Form("adressline1")
zip = Request.Form("zip")
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
set FSO = server.createObject("Scripting.FileSystemObject")
Filepath = Server.MapPath(Request.Form("csvfile"))
set file = FSO.GetFile(Filepath)
Set TextStream = file.OpenAsTextStream(ForReading, TristateUseDefault)
' Start of xml document
Response.Write("<?xml version=""1.0"" encoding=""ISO-8859-15"" ?>")
Response.Write("<list>")
' Skip the first line where all headings are
TextStream.skipline
' set node counter
x = 0
' Read the rest of the file line by line
Do While Not TextStream.AtEndOfStream
x = x + 1
Response.Write("<contact id=""" & x & """>")
Dim myLineArray
myLineArray=Split(TextStream.readline,",")
' get array data
xfirstname = myLineArray(firstname)
xlastname = myLineArray(lastname)
xemail = myLineArray(email)
xadressline1 = myLineArray(adressline1)
xzip = myLineArray(zip)
' Output the XML formatted array data
MakeMyNode xfirstname,"firstname"
MakeMyNode xlastname,"lastname"
MakeMyNode xemail,"email"
MakeMyNode xadressline1,"adressline1"
MakeMyNode xzip,"zip"
Response.Write("</contact>")
Loop
Response.Write "</list>"
Set TextStream = nothing
Set FSO = nothing
%>
<%
sub MakeMyNode(strng,mynode)
' count numbers of characters in the string
Count = Len(strng)
' Remove right quote character
strng = Left(strng,(Count-1))
' Remove left quote character
strng = Right(strng,(Count-2))
Response.Write("<" & mynode & ">" & strng & "</" & mynode & ">")
End Sub
%>
---------- import02.asp
end ------------------------------------------------------------------------
-----------
Now, everything works like a charm... as long as the CSV file looks
something like my above example... a CSV data field can have quotes (Bobs
firstname could be "Bob "Bobster"" and everything still works since I only
remove the outer quote characters from the data fields.
But... and here´s my problem... if a data field have a comma - "Bike, Inc" -
then it all falls apart since I split with the comma sign :( So I guess I
have to rethink how to do this. I´ve googled like crazy for some other way,
but can´t seem to find anything. Surely this must be a common problem - to
which someone has a beautiful solution? :)
Any ideas/input/pointers?
/Mike Tag: VBscript Training Tag: 149913
Read Table values found in HTML
I'm able to download HTML web pages and read them in vbscript, but I'd
like to be able to get values from tables I find in those pages.
The scenario is that I'm reading a HTML page that I know about, and I
want to read values from a specific table in that page. The page will
also contain a lot of other tags, data, and maybe other tables besides
the desired table.
I get the Web page by doing something similar to:
set iWeb = CreateObject("MSXML2.XMLHTTP")
iWeb.open "GET", "http://my.yahoo.com", False
iWeb.send
WScript.Echo iWeb.responseText
At that point I can read the iWeb.responseText object and look for
strings, but I think that I should be able to access the tables
directly. I saw some examples on google, but I couldn't find
specifics on getting to the tables using the "iWeb" object I created
above. I also looked in MSDN, but there was more about creating
tables then about reading them.
I also tried using a RegExp, but I'm not that familiar with that
object, and it seemed to get me a long string, rather then something I
can pass to an array or recordset, and appears more of a text parser
then a table reader.
I don't think that I'm that far away from what I want to do, but
accessing the tables objects has me stumped, so any help would be
appreciated.
Swyck Tag: VBscript Training Tag: 149894
Microsoft VBScript compilation error: Expected statement
Hello,
I have a simple test.wsf. It is running on Windows 2000 server SP4/WSH5.6
and is fine.
But when it runs on XP/WSH5.6 I get the error:
C:\cscript test.wsf
test.wsff(1, 1) Microsoft VBScript compilation error: Expected statement.
Code 800A0400
**************
<package>
<job>
<script language=vbscript>
Wscript.echo "hello"
</script>
</job>
</package>
*******************
Thanks
Wensi Tag: VBscript Training Tag: 149892
vbScript Winamp Random MP3 Jukebox
option explicit
'********************************
'Happy Russ's Winamp MP3 Jukebox
'12-17-2003
'********************************
'set the number of tracks you wish to add
Const iNumberToAdd = 10
'Set the path you wish to search for music
Const MP3Path = "d:\my music"
'Set your winamp directory
Const winampPath = "c:\program files\winamp\winamp.exe"
'Global Variables used to generate random list
Dim iNumberOfFiles, cFileList
'This tells it to run
Main()
Sub Main
Set cFileList = CreateObject("Scripting.Dictionary")
iNumberOfFiles = 0
'Load the collection
FolderCrawl(MP3Path)
Dim ItemsArray
ItemsArray = cFileList.Items
Dim iRandomNumber
Dim oShell
Set oShell = CreateObject("WScript.shell")
Dim iCount, strShellCommand
For iCount = 1 to iNumberToAdd
'Pick a random MP3
iRandomNumber = RandomNumber(iNumberofFiles)
strShellCommand = """" & winampPath & """ /add """ &
cFileList(iRandomNumber) & """"
'MsgBox(strShellCommand)
oShell.Run(strShellCommand)
Next
End Sub
Sub FolderCrawl(strParentFolderPath)
Dim fso, oParentFolder, oSubFolders, oChildFolder
Set fso = CreateObject("Scripting.FileSystemObject")
Set oParentFolder = fso.GetFolder(strParentFolderPath)
Set oSubFolders = oParentFolder.SubFolders
AppendFilesToList strParentFolderPath
For Each oChildFolder in oSubFolders
AppendFilesToList strParentFolderPath & "\" & oChildFolder.name
FolderCrawl strParentFolderPath & "\" & oChildFolder.name
Next
Set oChildFolder = nothing
Set oParentFolder = nothing
Set oSubFolders = nothing
Set fso = nothing
End Sub
Sub AppendFilesToList(strFolderPath)
'MsgBox strFolderPath
Dim fso, oFolder, oFiles, oFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set oFolder = fso.GetFolder(strFolderPath)
Set oFiles = oFolder.Files
For Each oFile in oFiles
If LCase(Right(oFile.Name,4)) = ".mp3" Then
iNumberOfFiles = iNumberOfFiles + 1
cFileList(iNumberOfFiles) = strFolderPath & "\" & oFile.name
End If
Next
Set oFile = nothing
Set oFiles= nothing
Set oFolder = nothing
Set fso = nothing
End Sub
Function RandomNumber(intHighestNumber)
Randomize
RandomNumber = Int(Rnd * intHighestNumber) + 1
End Function Tag: VBscript Training Tag: 149890
VBScript and Word : How to use Mailing.CustomLabels
Hi,
I created a VB Script which open Word and Merge Data from a file.
To do this script, I used MS Kb article 285176
My code looks like this
code:-----------------------------------------------------------------------
-------
Function doReport()
Dim wrdApplication
Dim wrdDocument
Dim oMergedDoc
'msgbox "Ouverture de Word"
Set wrdApplication = CreateObject("Word.Application")
wrdApplication.DisplayAlerts = False
' Add a new document.
Set wrdDocument = wrdApplication.Documents.Add
With wrdDocument.MailMerge
'Police et Taille
wrdApplication.Selection.Font.Name = "Arial"
wrdApplication.Selection.Font.Size = 12
'Add our fields.
.Fields.Add wrdApplication.Selection.Range, "CORRESPONDANT"
wrdApplication.Selection.TypeParagraph
.Fields.Add wrdApplication.Selection.Range, "SOCIETE"
wrdApplication.Selection.TypeParagraph
.Fields.Add wrdApplication.Selection.Range, "ADRESSE"
wrdApplication.Selection.TypeParagraph
.Fields.Add wrdApplication.Selection.Range, "VILLE"
wrdApplication.Selection.TypeParagraph
.Fields.Add wrdApplication.Selection.Range, "PAYS"
wrdApplication.Selection.TypeParagraph
'Create an autotext entry.
Dim oAutoText
Set oAutoText =
wrdApplication.NormalTemplate.AutoTextEntries.Add("MyLabelLayout",
wrdDocument.Content)
wrdDocument.Content.Delete
.MainDocumentType = 1 ' 1 = wdMailingLabels
'Open the saved data source.
.OpenDataSource "F:\ASP\data.txt", ,False
'Create a new document.
wrdApplication.MailingLabel.CreateNewDocument "5163", "",
"MyLabelLayout", , 4 ' 4 = wdPrinterManualFeed
.Destination = 0 ' 0 = wdSendToNewDocument
'Execute the mail merge.
.Execute
oAutoText.Delete
End With
' Close the mail merge edit document.
wrdDocument.Close False
' Get the current document.
wrdApplication.Visible = True
Set oMergedDoc = wrdApplication.ActiveDocument
err.clear
Set wrdDocument = nothing
Set oAutoText = nothing
Set oMergedDoc = nothing
Set wrdApplication = nothing
doReport = True
End Function
----------------------------------------------------------------------------
--
I would like to use Mailing.CustomLabels properties to use my own labels
I think the code could be like this
code:-----------------------------------------------------------------------
-------
Set myLabel = wrdApplication.Mailing.CustomLabels.Add("MonEtiquette",
False)
With myLabel
.Height = CentimetersToPoints(5.2)
.Width = CentimetersToPoints(7)
.HorizontalPitch = CentimetersToPoints(7.62)
.VerticalPitch = CentimetersToPoints(5.93)
.NumberAcross= 2
.NumberDown = 4
.PageSize = 4
.SideMargin = CentimetersToPoints(3.19)
.TopMargin = CentimetersToPoints(3.36)
End With
----------------------------------------------------------------------------
--
and I replace "5163" by "MonEtiquette" in .CreateNewDocument action
But nothing append.
If someone have an idea.
Regards
Olivier Tag: VBscript Training Tag: 149889
Useful links
I found good informations, scripts and components in these sites.
www.borncity.de (I have read his book on wsh 2.0 and it's really well done)
http://home.att.net/~wshvbs/index.htm
http://www.myitforum.com/downloads/default.asp?srt=42&w=3&se=VB+Scripting&p=13
I started from http://users.skynet.be/vecelzo/ (tab windows, scripting, vbscript) where
you can find other links.
Giovanni.
--
Giovanni Cenati (Aosta, Italy)
Write to user "nnever" and domain "@katamail.com" Tag: VBscript Training Tag: 149886
error checking for file upload function
hi,
I have a file upload functionality on my site. I want to make sure that if a
user selects a file that doesn't exists (by entering the path manually), the
mistake is caught.
THe code looks like this:
*************
PostData = ""
Dim biData
biData = Request.BinaryRead(Request.TotalBytes)
if Request.TotalBytes = 0 then
Response.Redirect "displayFiles.asp?id_message=5&id_sort=0"
end if
if Request.TotalBytes > FILE_LIMIT then
Response.Redirect "displayFiles.asp?id_message=4&id_sort=0"
end if
************
If i check for TotalBytes = 0, it doesn't catch because when I test the
value of the totalbytes value, it's always between 6-700.
any ideas?
thanks Tag: VBscript Training Tag: 149879
returning error code from Stored Procedure
Hi,
I'm trying to catch the error with following code and my
code will stop executing before getting to on error resume
next. What is wrong with it?
'I'm executing a stored procedure
Set objRS = objCon.Execute(strQuery)
'I will not get to this line if there is an error like
'unique constraint in my SP
on error resume next
if Err.Number <> 0 then
response.Write(Err.Description)
else
Response.Redirect "mypage.asp"
end if
I'm checking for @@Error <> 0 after every SQL statement in
my SP and rolling back if there is an error.
Thanks, Tag: VBscript Training Tag: 149872
Hi,
will Microsoft be releasing any new Training for VBscipting and WMI ?