Vbs: How To Read Variables From An external File?
hello
unfortunately i dont code in VBS nor any language from Microsoft, im
PHP , Perl programer, i know its verey easy to learn VBS, but i don
have much time to learn VBS, i manged to get a VBS code that execut
extrnel commands.
using this code i can code my scripts in PHP and run them from this VB
code (im forced to use VBS)
but the proplem is: i want the outpout that was created by PHP to b
available to VBS.
Example:
VBScript: test.vbs :
Code
-------------------
Option Explicit
Dim Command
Command = RunOutput( "%comspec% /C D:\bin\php\php.exe -f F:\DeskTop\test.php", 0)
MsgBox Command
'---------------------------------------------------------------------
'-- RunOutput Function ------------------------------------
'---------------------------------------------------------------------
Function RunOutput( cProgram, nWindowType )
'-- Obtain a Temporary File Name
Dim oFS
Set oFS = CreateObject("Scripting.FileSystemObject")
Dim cFile
cFile = oFS.GetSpecialFolder(2).Path & "\" & oFS.GetTempName
'-- Execute the command and redirect the output to the file
Dim oShell
Set oShell = CreateObject( "WScript.Shell" )
oShell.Run cProgram & " >" & cFile, nWindowType, True
Set oShell = Nothing
'-- Read output file and return
Dim oFile
Set oFile = oFS.OpenTextFile(cFile, 1, True)
RunOutput = oFile.ReadAll()
oFile.Close
'-- Delete Temporary File
oFS.DeleteFile cFile
Set oFS = Nothing
End Function
-------------------
PHPScript: test.php :
PHP code
-------------------
<?
$today = date("D M j G:i:s Y");
$Sec = md5("$today");
echo "
Dim today
today = \"$today\"
Dim Sec
Sec = \"$Sec\"
";
?>
-------------------
now when i run the file *test.vbs* i get this Msg Box:
[image: http://www.remal.com.sa/images/misc/VocieGuide_PHP_VBS.jpg]
what i want is to be able to access the two variables that was returne
by PHP "today and Sec" from the VBS script
-
Sale
-----------------------------------------------------------------------
Posted via http://www.codecomments.co
----------------------------------------------------------------------- Tag: Forwarding O.E. Tag: 162780
Net Share and VBScript
Hi all, this is my first time posting.
I've been away from VB programing for such a long time I seem to be
dumfounded when it comes to doing the easiest things.
Here's the situation:
Windows 2003 server and domain
I have loads of home directories on my school server.
With windows 9X's limitation of mapping to a share only the simple
thing to do is make a share out of the home directory. - (simple if
you like to right click a lot).
Rights are already assigned to the home folder when it was created.
I have a text file from Active Directory with the users name which
matches the users home folder (already created).
I would like to use this text file as a input file with a VBScript.
While in the Do loop I would like it to...
use the net share command to share the home folder as username + $ so
that all the shares are hidden (keeps it very clean this way)
That's it!
Very simple for the right person, which I am not.
Any help would be greatly appreaciated.
Michael Tag: Forwarding O.E. Tag: 162777
Rename a computer and computer accout
Hi,
I'm having problem to rename all the PCs in company.
I found the sample script here
http://www.microsoft.com/technet/community/scriptcenter/compmgmt/scrcm36.mspx
but it works only on XP or 2003.
My clients are running on 2K Pro on 2K Domain.
Please help me, give sample on how to write the script, i totally have no
idea, plsssssss.
Thanks in Advance...JJ Tag: Forwarding O.E. Tag: 162776
add user to group
Got this code to create user & add it to group. In the last part of
adding the user to a group I have a syntax problem. I want each
UserNo i created in the loop be added to a security group. cannot seem
to find the rihgt syntax.
please help.
TIA,
Ronen
Const ADS_PROPERTY_APPEND = 3
Set objRootDSE = GetObject("LDAP://rootDSE")
Set objContainer = GetObject("LDAP://OU=test,OU=Misc,OU=TAU," & _
objRootDSE.Get("defaultNamingContext"))
Set objGroup = GetObject _
("LDAP://CN=cn=Terminal Server User,OU=test,OU=Misc,OU=TAU")
For i = 1 To 5
Set objLeaf = objContainer.Create("User", "cn=UserNo" & i)
objLeaf.Put "sAMAccountName", "UserNo" & i
objLeaf.Put "userPrincipalName", "UserNo" & i
objLeaf.Put "givenName", "UserNo" & i
objLeaf.Put "displayName", "UserNo" & i
objLeaf.SetInfo
objLeaf.SetPassword "111111"
objLeaf.AccountDisabled = False
objLeaf.SetInfo
objGroup.PutEx ADS_PROPERTY_APPEND, _
"member", Array("cn=UserNo" & i "objContainer" )
objGroup.SetInfo
Next
WScript.Echo "5 Users created." Tag: Forwarding O.E. Tag: 162773
How to write the WMI Asset Tag
Hi there!
the code snippet
---
strComputerName = "."
strWinMgt = "winmgmts://" & strComputerName & ""
Set compsysset = GetObject(strWinMgt).ExecQuery("select * from
Win32_SystemEnclosure")
For Each CompSys In compsysset
MsgBox CompSys.SMBIOSAssetTag
Next
---
gives me the WMI Asset Tag.
Is there a way to (over)write this value? As far as I see it is built in in
the computer by the manufacturer, but I would like to use it to store the
Asset Number of the PC from our Asset Management Database... Tag: Forwarding O.E. Tag: 162771
Clearing cookies reloading?
Hi,
i am not into scripting at all, but i know VBA ok.
I' am trying to vote for my band on this web site:
http://www.bbc.co.uk/northamptonshire/content/articles/2004/08/04/weekender_chart_vote_feature.shtml
(the structure) -www.thestructure.co.uk!
each time i vote it set a cookie, and will not allow you to vote
agian.
what i need to do is write a script that will clear out my cookies,
relead the webpage.
If it could also vote aswell then theat would be ace, if this can be
done then i guess it can be looped.
Can this type of thing be done - anyone got some code of web ref
Many thanks,
Ross. Tag: Forwarding O.E. Tag: 162769
ADO Reference
Hi everybody,
Maybe thats not the right newsgroup, but i need a complete reference of ADO.
Where do i find this?
Thanks Tag: Forwarding O.E. Tag: 162758
a string within a string
Hi,
I need to use bcp, a command line utility installed with sqlserver, from my
script.
if I issue the following command at the command prompt it works:
bcp "SELECT * FROM pubs..authors" queryout c:\Authors.txt -c -T.
Note that the sql statment is quated.
I tried to use bcp in the same way as I do with other command lines programs
such as:
oShell.Run "cmd /C IPconfig/all > ........" I fell to do so as I do not
know how to address the fact that the sql statment is a string and the
entire parameter passed to the Run method is also a string so there is
actually a string inside a string.
Thanks,
Yaniv Tag: Forwarding O.E. Tag: 162757
Scripting DSMOVE DSQUERY and DSMOD help! (EASY?)
Hi all,
Im trying to create a batch file/vbs or whatever script that allows me to
run these commands.
Objective of script:
To search the whole Active Directory for objects that are duplicated (search
condition $DUPLICATES*), mark them as disabled and move them to an OU.
If i put these following commands into command prompt one by one it works,
but not when i put it into .cmd or .bat (due to the for loop and the
variables)
for /F "usebackq delims=""" %i in (`dsquery * domainroot -filter
"(&(objectCategory=*)(objectClass=*) (sAMAccountName=$DUPLICATE*))"`) do
dsmod user %i -disabled yes
for /F "usebackq delims=""" %i in (`dsquery * domainroot -filter
"(&(objectCategory=*)(objectClass=*) (sAMAccountName=$DUPLICATE*))"`) do
dsmove %i -newparent ou=scheduled,dc=YOURDOMAIN,dc=com
if I use the default piping for dsquery and dsmod it works fine however if i
use dsquery piping with DSMOVE (if there are more than 1 objects to be
moved) it failed! (crap)
dsquery * domainroot -filter "(&(objectCategory=*)(objectClass=*)
(sAMAccountName=$DUPLICATE*))" | dsmod user -disabled yes
dsquery * domainroot -filter "(&(objectCategory=*)(objectClass=*)
(sAMAccountName=$DUPLICATE*))" | dsmove -newparent
ou=scheduled,dc=YOURDOMAIN,dc=com
Anyone kind enough to mod this? :)
Cheers!
Kind Regards,
Freddy Hartono Tag: Forwarding O.E. Tag: 162750
Loading an image within an asp page
I have had a lot of trouble with this, and I was wondering if anyone
had any ideas as to where I am going wrong.
My asp is a simple image viewer, it lists all the photos in the
directory, (1 for each astff member), has the facility to search, and
when you click on the link corresponding to the staff member it should
load the image in that page. Here are the code snips of what I have so
far:
**** Code Removed for viewing ******
<form method="GET" name="SearchPicture" action="default.asp">
<p style="margin-left: 0in; margin-right: 0in; margin-top: 0in;
margin-bottom: .0001pt">
<input type="text" name="SearchString"
value="<%=Request("SearchString")%>" size="45%">
<input type="image" name="staffImage" style="visibility: hidden;
display: none" src="" border="0" align="right" width="32%"
height="32%"></p>
<p style="margin-left: 0in; margin-right: 0in; margin-top: 0in;
margin-bottom: .0001pt">
<input type="submit" value="Search" name="B1">
<input type="submit" value="List All Staff"
onclick="SearchString.value='';" name="B2">
<input type="button" value="Clear" onclick="SearchString.value='';"
name="B3"></p><!--webbot bot="SaveAsASP" CLIENTSIDE SuggestedExt="asp"
PREVIEW=" " startspan --><!--webbot bot="SaveAsASP" endspan -->
</form>
<%
Dim strPath 'Path of directory to show
Dim objFSO 'FileSystemObject variable
Dim objFolder 'Folder variable
Dim objItem 'Variable used to loop through the contents of the
folder
strPath = "../Photos/"
set objFSO = server.CreateObject("Scripting.FileSystemObject")
' Get a handle on our folder
Set objFolder = objFSO.GetFolder(Server.MapPath(strPath))
' Loop through the files!
For Each objItem In objFolder.Files
my_ex = objFSO.GetExtensionName(objItem)
my_name = objFSO.GetFileName(objItem)
If InStr(1, my_ex, "JPEG", 1) = 1 or InStr(1, my_ex, "jpg",1) = 1
Then
If InStr(1, my_name, Request("SearchString"), 1) > 0 Then
%>
<tr><TD vallign="left" width="30%" ><A href=""
onclick="ShowImage('my_name & my_ex')" ><%= left(my_name,len(my_name)
- len(my_ex) - 1) %></A></TD></tr>
<%
End If
End If
Next 'objItem
Sub ShowImage(fileName)
staffImage.src='strPath & fileName'
staffImage.style.visibility='visible'
End Sub
' All done! Kill off our object variables.
Set objItem = Nothing
Set objFolder = Nothing
Set objFSO = Nothing
Set my_name = Nothing
Set my_ex = Nothing
%>
</td>
</tr>
</table>
</div>
</p>
</body>
</html>
The problems appear to be with the ShowImage() sub, (passing variables
into it, as well as displaying the image. Thanks for any help you can
offer Tag: Forwarding O.E. Tag: 162747
vb script to join domain
I am trying to write a script that will open the computer name changes
window in the system control panel. A friend gave the following:
Option Explicit
Dim oWS
Set oWS = WScript.CreateObject("WScript.Shell")
WScript.Sleep 5500
'Bring up the System Properties window
oWS.run "rundll32.exe shell32.dll,Control_RunDLL sysdm.cpl,,1"
WScript.Sleep 1000
'Bring up the computer name changes window
oWS.SendKeys "%c"
WScript.Sleep 1000
oWS.SendKeys "%d"
WScript.Sleep 1000
oWS.SendKeys "{Tab}"
WScript.Sleep 500
oWS.SendKeys "test.local"
WScript.Sleep 500
oWS.SendKeys "{ENTER}"
Set oWS = nothing
The problem is the system properties window loses focus and the rest of the
commands don't register. Is there a way to directly bring up the computer
name changes window? Or is there a way to make the System Properties window
the focus?
Thanks,
Jason Tag: Forwarding O.E. Tag: 162744
script to determine display mode
Is there a way for a script to determine whether or not the video
display is in clone mode? Tag: Forwarding O.E. Tag: 162743
Changing IE Proxy Settings
Hi
Can anyone give me a sample script to change IE proxy settings from one IP
address to another which will apply to all users in XP and Win2k?
Gordon Tag: Forwarding O.E. Tag: 162740
Unintentional ascii 0 (nulls) when creating file with FSO?
I'm creating files on an IIS 5.0 web server, and when I create files with
the FileSystemObject, it creates files that have ASCII 0's as every other
character.
For example, if I TextStream.Write("Hello"), the resulting file has:
(gibberish) H (null) e (null) l (null) l (null) o (null)
In a text editor, the output looks fine, like "Hello".
In a hex editor, the file looks like this:
FF FE 48 00 65 00 6C 00 6C 00 6F 00
Anyone have an idea what's going on? It's driving me nuts... I'm not sure
where the "FF FE" comes from either.
Thanks,
Dan
www.dantan.net Tag: Forwarding O.E. Tag: 162739
Kill processes and services
I'd like to creating a small vbs file to kill a short list of processes/tasks and services
before installing other software.
There are a lot of third party utilities (ie. exes) that do this, but I hoping I could do
it without calling a batch/command-prompt process and do it all in a single file.
Any feedback is appreciated.
Thanks,
--
Tony Pedretti
TransUnion LLC Tag: Forwarding O.E. Tag: 162736
regular expressions
I'm back with something that makes no sense to me .... as far as I can see
the three if statements are identical except for the input. One is the
regular phone, then cell phone and then the fax .....
function validForm( passform) {
<< other validation skipped >>
re = /^\(?(\d{3})\)?[\.\-\/ ]?(\d{3})[\.\-\/ ]?(\d{4})$/
validPhone = re.exec(passForm.fldPhone.value);
if ( validPhone ) {
passForm.fldPhone.value = "(" + validPhone[1] + ") " + validPhone[2] +
"-" + validPhone[3];
}
else {
errList += " a valid phone number\n";
if (!hasError) {
passForm.fldPhone.focus();
hasError = true;
}
}
if ( passForm.fldCell.length > 0) {
recell = /^\(?(\d{3})\)?[\.\-\/ ]?(\d{3})[\.\-\/ ]?(\d{4})$/
validCell = recell.exec(passForm.fldCell.value);
if ( validCell ) {
passForm.fldCell.value = "(" + validCell[1] + ") " + validCell[2] + "-"
+ validCell[3];
}
else {
errList += " if entered the cell must be a valid phone number\n";
if (!hasError) {
passForm.fldCell.focus();
hasError = true;
}
}
}
if ( passForm.fldFax.length > 0) {
refax = /^\(?(\d{3})\)?[\.\-\/ ]?(\d{3})[\.\-\/ ]?(\d{4})$/
validFax = refax.exec(passForm.fldFax.value);
if ( validFax ) {
passForm.fldFax.value = "(" + validFax[1] + ") " + validFax[2] + "-" +
validFax[3];
}
else {
errList += " if entered the fax must be a valid phone number\n";
if (!hasError) {
passForm.fldFax.focus();
hasError = true;
}
}
}
<< handle the error and redirect to the next form >>
}
THey shouldbe identical since I copied the first one and made the requisit
changes for the cell and fax. However the output (as show in the session
variables into which they are stashed)
Session("svPersonPhone") = Request.Form("fldPhone")
Session("svPersonCell") = Request.Form("fldCell")
Session("svPersonFax") = Request.Form("fldFax")
show up as follows:
SVPERSONZIPCODE - 123451234
SVPERSONPHONE - (123) 123-1234
SVPERSONCELL - 4564564567 <<== notice not formatted ...
SVPERSONFAX - 7897987890
SVPERSONEMAIL -
initially the regular expressions were all just 're' then when I started
looking at this I changed them to 'recell' and 'refax' on the off chance
that there might be a funny in re-using a regular expression.
as always other comments are appreciated, but please also address this
issue. ((I know "picky, picky....")) Tag: Forwarding O.E. Tag: 162733
Convert DWORD Value to dotted IP Address
does anybody have any code to convert a dword value to a dotted ip
address....
I know that DWORD Value 167788830 converts to 10.0.65.30 but i have no idea
how to do it Tag: Forwarding O.E. Tag: 162731
Convert from bat to vbs
Hope someone can help, I want to convert this bat file to vbs. Anyone have
any input on how to do this.
@echo off
if not exist alttiff.ocx goto bad
start regsvr32 alttiff.ocx
goto end
:bad
echo Error: Cannot find alttiff.ocx.
echo Note: Do not run install.bat directly from your unzip program.
echo You must create a folder and unzip everything into it.
echo Note: The current directory is:
cd
pause
:end
Thanks
Gavin... Tag: Forwarding O.E. Tag: 162729
Editing an Access table from VBscript?
I'm looking for a way to read from and write to a table within an MS-Access
database.
I'll explain why I need this.
In my company, I want to keep a logfile of the computers that have logged
into the network. If the computername is not in a list, I want the user to
enter some information on a popup screen, about the location of the computer
(room-number).
Once the computername is in the list, the script should continue without the
user noticing. It should then only write the current date and time.
Would this be possible with Vbscript?
Wouter. Tag: Forwarding O.E. Tag: 162713
Windows.Status throws error on some pages
I have a series of ASP pages that have some fairly heavy client-side VB
script in them. Recently I have noticed that a few of these pages don't
like setting the window.status property. The ones that complain will throw
an error with the following message:
error: Illegal assignment: 'Windows.status'
I can see no significant difference between the pages where the
window.status works and those where it doesn't. Can anyone suggest where
the problem may be for me?
TIA
Ron L Tag: Forwarding O.E. Tag: 162712
Setting Computer Description Field with UserName
Does anyone know how I can set the Computer Description Fields with the name
of the user (better current logged in user)? Thanks everyone! Tag: Forwarding O.E. Tag: 162710
vbscript and IIS
Hi,
I've got the following task to do: I need to check various settings of a
website files on IIS. This mainly involves type of access (anonymous, basic
authentication etc.) Up to now I've done it manually, I opened inetmgr,
browsed to my website and than I manually checked file by file, security
settings.
Now, since the task is rather tedious, I thought about a script which
would do this for me, but I'm not really sure how. I am dimly aware of
things like ADSI, but I don't have any experience with it.
Could anyone provide any example, how for instance I can check if the
anonymous access has been set for given aspx file?!
Thanks,
Piotrek Tag: Forwarding O.E. Tag: 162703
Help for my unused methods please
Does anybody know a tool that could help me finding unused functions
on my VB applications?
Thanks for your help.
Bernard Davest Tag: Forwarding O.E. Tag: 162701
VBS & Stored Procedure
Hi all,
I have a stored proc that write a string in a var. I want to get this
string in my vbscript and I don't succeed. here is my code :
(don't forget to modify connection string)
In SQL Server :
==========================================
CREATE PROCEDURE SP3 AS
DECLARE @toto varchar(255)
SELECT @toto = 'Voici le retour de ma proc'
GO
==========================================
In my vbscript i would like to get "toto" :
---------------------------------------------------
Option Explicit
Const adCmdStoredProc = &H0004
Const adParamOutput = &H0002
Const adVarChar = 200
Dim strData
Dim res
res = ExecuteStoreProc ("SP3")
MsgBox "res : " & res
'******************* Execute the stored proc ****************
Public function ExecuteStoreProc(ProcStocName)
Dim oConn, strSQL, oRs
Dim pbiz_op
Set oConn = CreateObject("ADODB.Connection")
oConn.Open "DRIVER={SQL
Server};SERVER=XXXXXXXXXXXXX;UID=XXXXXX;PWD=XXXXX;DATABASE=XXXXX"
Dim oAdoCommand
Set oAdoCommand = CreateObject("ADODB.Command")
oAdoCommand.ActiveConnection = oConn
oAdoCommand.CommandText = ProcStocName
oAdoCommand.CommandType = adCmdStoredProc
oAdoCommand.Parameters.Refresh
dim lngRecordsAffected
dim retour
Set oRs = oAdoCommand.Execute(lngRecordsAffected, , adCmdStoredProc)
ExecuteStoreProc = oRs.Parameters 0
End function
--------------------------------------------------- Tag: Forwarding O.E. Tag: 162695
OU's + Sub OU's enumerations
Hello,
How can I in an ASP page (with a VBScript) enumerate all the OU's (sub ou's
included) in a drop down list. I would like to do the same for the Storage
Grouops and Mailboxes Stores on my 2 EX2K.
Any Idea ???
Thanks
Oli Tag: Forwarding O.E. Tag: 162688
Text File
Hi
I am trying to open a file and file the last line in the file.
I then want to access text in the last line.
Once I know the number of the last line, I am trying to access. The code
errors and says I am trying read past the end of the file.
I guess I need to reset the AtEndOfStream.
Is there a function for doing this or do I have to close and reopen the
file?
Cheers
Geoff
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\FSO\daily.txt", 1)
Dim strMaxLineNumber
Dim LastLine
Do Until objFile.AtEndOfStream
strLine = objFile.ReadLine
strMaxLineNumber = strMaxLineNumber + 1
Loop
Wscript.Echo strMaxLineNumber Tag: Forwarding O.E. Tag: 162684
Windows XP Wallpapers
Hi!!
Is there a way to change the windows xp wallpaper when a user logs on??
I have used the following script in windows 2000 and works fine however it
does not work in Windows XP
any Ideas???
Is there any other way to do that??
I hava a DC running windows 2000 AS and all the clientes are XP
thanx =)
Option Explicit
Dim CompleteImagesFolderPath
Dim ImageFileTypes
CompleteImagesFolderPath = \\path
ImageFileTypes = "jpg"
Dim WshShell
Set WshShell = Wscript.CreateObject("Wscript.Shell")
Dim ImageFiles
Dim Final
Dim strDesktop
Set ImageFiles = CreateObject("Scripting.Dictionary")
strDesktop = WSHShell.SpecialFolders("Desktop")
call RandomImage(CompleteImagesFolderPath,ImageFileTypes)
Function RandomImage(CompleteImagesFolderPath, ImageFileTypes)
'Declare variables
Dim FileSystemObject
Dim ImageFolder
Dim Files
Dim i
Dim File
Dim FileName
Dim FileExtension
Dim RandomNumber
Set FileSystemObject = CreateObject("Scripting.FileSystemObject")
If Not FileSystemObject.FolderExists(CompleteImagesFolderPath) Then
RandomImage = "Error 0: Cannot find requested folder"
Set FileSystemObject = nothing
Exit Function
End If
Set ImageFolder = FileSystemObject.GetFolder(CompleteImagesFolderPath)
Set Files = ImageFolder.Files
i = 1
For Each File in Files
FileName = File.Name
FileExtension = Right(FileName, Len(FileName) - (InStrRev(FileName, ".")))
If InStr(1,ImageFileTypes,FileExtension,vbTextCompare) > 0 then
ImageFiles.Add i, FileName
i = i + 1
End If
Next
Set ImageFolder = nothing
Set Files = nothing
Set FileSystemObject = nothing
Randomize
If ImageFiles.Count = 0 Then
RandomImage = "Error 1: Folder no existe"
Exit Function
End If
RandomNumber = Int((ImageFiles.Count) * Rnd + 1)
Final = CompleteImagesFolderPath&"\"&ImageFiles.Item(RandomNumber)
WshShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Internet
Explorer\Desktop\General\Wallpaper",Final,"REG_SZ"
WshShell.RegWrite "HKEY_CURRENT_USER\Control
Panel\Desktop\Wallpaper",Final,"REG_SZ"
'CompleteImagesFolderPath&"\"&ImageFiles.Item(RandomNumber)
Set ImageFiles = nothing
WSHShell.AppActivate strDesktop
WSHShell.SendKeys "{F5}"
End Function Tag: Forwarding O.E. Tag: 162675
Declaration order & onchange event referencing dialog box in asp page
Hello
I'm a novice vbs'er, but old hand (now rusty) coder, which is what makes this more frustrating. I'm trying to construct an .as page with a list box to call a new page. Lots of googling has not led me to solve this problem:
I can't get the onchange event of the list box to open a url with a query string containing reference to the listbox selected item (a simple task I'm sure)
1. populates list box (lbselect) from DB which works
2. attempts to call newpage with the selected index
This won't run as it says an "object is expected", when I reference lbselect in the onchange event
- i've noticed different behavour between mozilla (which i normally use) and opening in IE sometimes, but hoping that is not the major issue
- i've made something work using an additional button in the form, but then the user has to lclick
hope somecan can point me in the correct direction
many thanks
Oz
Code below
<form name="form1" method="post" action="">
<select name="lbselect" style="width:150px;" class="CountryListBoxContent" onChange="OpenNewWindow('Newpage.asp?Id='<%=lbselect.selectedindex%>)">
<%
While (NOT rs_CountryList.EOF)
%>
.. populates from DB - this works!!!
%>
</select>
</form>
**********************************************************************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources... Tag: Forwarding O.E. Tag: 162673
setting SRC in iFRAME
Probably a pretty basic question...how do I set the SRC property of an IFRAME in script? I''ve tried the following but don''t see an SRC property:
document.frames("myFrame").SRC = "abc.htm" <--this property doesn''t exist but where is it???
-----------------------------
This message is posted by http://asp.forumszone.com Tag: Forwarding O.E. Tag: 162672
Run ASP Script as Scheduled Job
Hi All,
I want to perform the simple task of running an ASP script as a scheduled
job.
Previously I've always either run a .vbs script via windows Scheduler, or
put some logic in my global.asa, both of which have worked fine.
Unfortunately there are technical reasons (too complicated to go into here)
which mean I can't use either the global.asa or a standalone vbs script for
this job. It really does have to be an .asp script running in the
application space.
Running a scheduled job that runs the command "explorer
http://www.mydomain.com/myscript.asp" does the job, but will leave a new
window open every day, which will cause problems when sat on a remote
server. (self.close() at the end of the script just gives the "app trying
to close window" message and leaves window open)
Does anyone have any suggestions as to how to achieve this on a W2K server ?
Some kind of opening IE, running script, closing IE via VBS maybe ?
Any help much appreciated,
Regards,
Larry. Tag: Forwarding O.E. Tag: 162664
vbscript library
I have about 20 scripts that do different tasks for me. These scripts share
a lot of the same procedures and functions. Is there any easy way to create
a libary of vbscript functions and procedures that I can then call from any
vbscript? Tag: Forwarding O.E. Tag: 162662
Using HTML Help
I have a vbscript that is used at the command line by several users. When a
user makes an error I want to launch a HTML Help file (*.chm) and have it
already browed to the correct page (context sensitive help). How would I do
this from the vbscript? How do you launch the help file? and how do you get
the help file to nagivate to particular pages? Tag: Forwarding O.E. Tag: 162661
Please help : Object Required Error
Why does the following sub in IE 6.0 returns :
Object Required : 'window.parent.frames(...).document.forms(...)
Isn't frm an object?
Sub btnSave_onClick()
Dim nRepID 'Report ID if existing
Dim sRepName 'Report Name
set frm = window.parent.frames(0).document.forms(0)
alert(window.parent.frames(0).document.forms(0).name)
'More code her like
if len(sRepName) > 0 then
SaveReport frm, nRepID, sRepName, ptable.XMLData, IsEmpty(nRepID)
end if
End Sub Tag: Forwarding O.E. Tag: 162657
net send across domains
Does anyone know if it is possible for a machine (application) on one domain
to do a NET SEND to a machine or user on another domain? Tag: Forwarding O.E. Tag: 162656
RecordCount Property
Hi:
I have code that does two separate queries via ADO and then prints out the
results. The first query is standard and if no records are returned it
prints nothing as expected. The second query contains a SUM function in the
query and if there are zero records I get the following error:
Error Type:
(0x80020009)
Exception occurred.
I tried using the RecordCount property which is returning -1. I've seen
articles about this but didn't want to test it because I didn't feel I
should need to test for zero records.
BTW, I am using Access and we're only talking about 30 records at the most
at a time here.
Thanks,
Blair Tag: Forwarding O.E. Tag: 162654
VBScript to fix file names of downloaded web page
Friends,
I usually download any interesting web page I come upon. I do not expect to
be able to find it a second time and I do want to make sure I can get at it
when I have enough time to read it. With my current financial condition I
never know how long I will have an Internet connection.
I usually save the downloaded pages and files to a CD-ROM. This presents a
problem because the CD-ROM has file name length limits that are often
exceeded by page names. This is accerbated by the need for associated files
from a like named folder.
This program allows the user to modify the page name. The program will
create a new page with the new name, a new folder with the correct name and
references in the new page pointing to files in the new folder. It does not
affect the current page or folder.
This is my first version. I expect to create a new version which will be
easier to use and overcome the limitations of this version. Until then you
may find this unteresting if not useful.
Phil Rist - prist@innernet.net - http://www.innernet.net/prist
' ----------------------------------------------
' Name: FixHTML.vbs
' Description:
' Fix Downloaded HTML File Names
'
' Author: Philip S. Rist
' Date:
' Copyright 2004 by St. Thomas Software
' ----------------------------------------------
' This program is freeware. It may be used
' for any moral purpose. You use it at your
' risk. St. Thomas Software makes no
' guarantees to its fitness to do anything.
'
' If you feel you must pay for it. Please
' send one million dollars to
'
' The International Rescue Committee
' 122 East 42nd Street
' New York, N.Y. 10168-1289
'
' Ok, it is only a demo. So make it a half
' million.
' ---------------------------------------------
' Purpose:
' This program renames downloaded HTML pages with
' excessively long names. It also finds and renames the
' associated directory and all references to that directory.
' Use:
' This program should be associated with an explorer verb
' allowing it to be executed from the context menu for
' a selected HTML file.
' Problem:
' 1) It only fixes one page at a time. Hopefully I will find the time
' to create a version that will fix a complete folder.
'
' 2) Sub-folders to the folder containing associated image files and
' other files are not automatically copied to the new folder. This
' must be done mannually.
'
' Syntax:
' c:\windows\WScript.exe ...\FixHTML.vbs "%1"
' ---------------------------------------------
Dim fso
' ---------------------------------------------
Dim WshShell
Dim WSHPath
Dim WSHName
Dim WSHVersion
Dim WSHScriptPathName
Dim MyScript
Dim MyScriptName
Dim MyApp
' ---------------------------------------------
Dim lProgram ' Name of program
Dim lOldName
Dim lOldFolder
Dim lPath
Dim lNewProgram
Dim lNewName
Dim lNewFolder
Dim lNewPath
Dim lPos ' Position of right most '.' in program name
Dim lNotes ' Name of notes file, same as file name
' except extension has been removed and
' _Notes.txt has been added
Dim lTestStream
Dim lText
' ------------------------------- Create objects
set WshShell = WScript.CreateObject("WScript.Shell")
set fso = CreateObject("Scripting.FileSystemObject")
MyApp = WScript.Application
WSHPath = WScript.FullName
WSHName = WScript.Name
WSHVersion = WScript.Version
WSHScriptPathName = WScript.Path
' WScript.echo WSHName + " Ver. " + WSHVersion
MyScript = WScript.ScriptFullName
MyScriptName = WScript.ScriptName
' --------------------------------- Get file name
set objArgs = WScript.Arguments
if objArgs.count > 0 Then
' ----------------------------- Get file name
lProgram = objArgs(0)
' ----------------------------- Get directory path
lOldFolder = vbnullstring
lPos = instrrev(lProgram,".")
if lPos > 0 then
lPath = left(lProgram,lPos-1)
lPos = instrrev(lPath,"\")
if lPos > 0 then
lOldName = mid(lPath,lPos+1)
lOldFolder = lOldName & "_Files"
lPath = left(lPath,lPos) & lOldFolder
end if
else
lPath = ""
end if
' ----------------------------- Get new name
lNewName = inputBox("Enter new name(No extension):","Input",lOldName)
lNewFolder = lNewName & "_Files"
lPos = instrrev(lPath,"\")
lNewProgram = left(lPath,lPos)
lNewPath = lNewProgram + lNewFolder
lNewProgram = lNewProgram & lNewName & ".html"
' ----------------------------- Create new folder with new names and
' copy contained files. Sub-folders to
' this folder must be mannually copied.
set lN = fso.CreateFolder(lNewPath)
fso.CopyFile lPath & "\*.*",lNewPath
set lTextStream = fso.OpenTextFile(lProgram)
lText = lTextStream.ReadAll()
lTextStream.Close()
' ---------------------------- fix references to sub-folder
lPos = instr(1,lText,lOldFolder,1)
lLen = len(lOldFolder)
do while (lPos > 0)
lText = left(lText,lPos-1) + lNewFolder + mid(lText,lPos+lLen)
lPos = instr(lPos+1,lText,lOldFolder,1)
loop
lPos = instrrev(lPath,"\")
lPath = left(lPath,lPos)
msgbox lNewProgram
' ---------------------------- Create page with new name
set lTextStream = fso.CreateTextFile(lNewProgram)
lTextStream.Write lText
lTextStream.Close
end if Tag: Forwarding O.E. Tag: 162653
Runbox written in VBScript
Friends,
Here is a simple runbox written in VBScript which can be run under Windows
Scripting Host.
Phil Rist - prist@innernet.net - http://www.innernet.net/prist
Option Explicit
' ----------------------------------------------
' Name: Runbox.vbs
' Description:
' Simple Runbox
'
' Author: Philip S. Rist
' Date:
' Copyright 2003 by St. Thomas Software
' ----------------------------------------------
' This program is freeware. It may be used
' for any moral purpose. You use it at your
' risk. St. Thomas Software makes no
' guarantees to its fitness to do anything.
'
' If you feel you need to pay for it. Please
' send one million dollars to
'
' The International Rescue Committee
' 122 East 42nd Street
' New York, N.Y. 10168-1289
'
' Ok, it is only a demo. So make it a half
' million.
' ---------------------------------------------
' Purpose:
' Windows runbox clone
' Use:
' This program should be associated with an explorer verb
' allowing it to be executed from the context menu for
' a selected file.
' Syntax:
' c:\windows\WScript.exe ...\Runbox.vbs "%1"
' ---------------------------------------------
Dim WshShell ' WSH Shell object
Dim objArgs ' Arguments passed to this script
Dim lFilePath ' Path to selected file
Dim lCommandLine ' Command line to be shelled to
Dim lRC ' returned from running command
Set WshShell = WScript.CreateObject("WScript.Shell")
' ------------------------------------------- Get name of file
Set objArgs = WScript.Arguments
lFilePath = objargs(0)
' ------------------------------------------- Allow user to modify command
line
lCommandLine = inputbox("Complete command:","My run box",lFilePath & " ")
' ------------------------------------------- If user has pressed Ok then
' execute program
if len(lCommandLine) > 0 then
lRC = WshShell.run (lCommandLine)
end if Tag: Forwarding O.E. Tag: 162652
STRING: Missing characters
I have a string named "email" that contains a new registering user email
address. My CSR receives an account request with the information that was
stored in a SQL table. Upon verifying the users profile, my CSR activates the
new user account and in the process, my script sends an account activation
message to the user (as stored in the "email" variable). The outgoing message
is simple and the "email" variable is correct in the "to" address. But, in
the body of the message, I have placed a link which allows the user to login
to their account that contains the "email" address variable (the same one
used in the "to" field) and it is somehow different. The difference being
ONLY when the email address contains a period "." in the name section.
Example; "first.last@myweb.com" ...produces "firstlast@myweb.com".
The period between "first" and "last" just drops off? Of course, the email
address is incorrect and when the user clicks the link and supplies their
password, logging in is unsuccessful. Any ideas? Tag: Forwarding O.E. Tag: 162648
Windows Script 5.6
I see that there is a new release of Windows Script (vbscript shows version
5.6.0.8825). I see downloads for XP, 2000, (and earlier OSes), but do not see
anything for Windows 2003.
I'd like to know how to get this on Windows 2003 as well so that I can test
it before deploying on a collection of Windows 2000/2003 servers.
Here's the XP/2000 release
http://www.microsoft.com/downloads/details.aspx?FamilyID=c717d943-7e4b-4622-86eb-95a22b832caa&displaylang=en Tag: Forwarding O.E. Tag: 162647
date less than current date.
Hey, I'm trying to compare a VAR "LastcommDate" to the current system
date. If that date is < current date then write that response to a
file Maintenance_Summary. I keep getting all records written to the
file no matter what the date is? Thanks. Tag: Forwarding O.E. Tag: 162646
fso and writeline
Hi,
I have an issue with the writeline function in the File System Object.
I am reading a field off a record in a SQL server db. If there is a carriage
return anywhere in the string of the field being pulled out to the writeline
will write it out as 2 lines. I need this to be written as 1 line. Is there
anyway I can do this?
Eg Data in field = "testesttestetsttes <CR> tewsttst"
tf.WriteLine("fieldname")
Data displayed as:
testesttestetsttes
tewsttst
Thanks In Advance,
Kevin. Tag: Forwarding O.E. Tag: 162637
Remote Lock Workstation for entire network
Hi guys 'n' gals...
I've found this script to remotely lock workstations specified in the
array:
dim RemoteProcess
dim arRemote, RemotePC
RemoteProcess = "rundll32.exe user32.dll,LockWorkStation"
arRemotePCs = array
(
"machinea",
"machineb",
"machinec",
"machinez"
)
for each RemotePC in arRemotePCs
StartProcess RemoteProcess, RemotePC
next
sub StartProcess (process, computername)
dim proc
set proc = getobject("winmgmts://" & computername
& "/root/cimv2").get("win32 process")
proc.create process
end sub
Now, what I want to do is populate the array with a list of all the
computers on the network (probably by using the NET VIEW)...
Is this possible and can anyone write the script I need to populate
it?
Thanks in advance
Adam Tag: Forwarding O.E. Tag: 162631
Calculating elapsed time
I am attempting to write a function that calculates the elapsed time to
download a page from the server.
I use the MSXML2.XMLHTTP object to GET a web page (in synchronous mode) and
note the time before and afterwards. However, the difference between these
values is generally = 0 which obviously can't be quite right. The web page
has instructions not to be cached.
The VBScript code is as follows - please point out where you think that I've
gone wrong. Thanks in advance.
Griff
----------
Private Function serverResponseTime(ByVal IPAddressOfServer)
Dim dStart
Dim dFinish
Dim oHTTP
Set oHTTP = CreateObject("MSXML2.XMLHTTP")
With oHTTP
' Start time
dStart = cdbl(Time)
' Set the connection synchronously
.open "GET", "http://" & IPAddressOfServer & "/default.htm", False
' Query site to download the page
.send
' Finish time
dFinish = CDbl(Time) 'Now()
' Determine response (in seconds)
serverResponseTime = ((dFinish - dStart) * 86400)
End With
Set oHTTP = Nothing
End Function Tag: Forwarding O.E. Tag: 162626
Class within a class
Hello out there,
Question: Set up a class in an class is not allowed in VBSCRIPT?
<!--#include file="classlib.asp"-->
class test
private Class_two
set Class= NEW class_lib ->> this line generates a syntax error why?
end class Tag: Forwarding O.E. Tag: 162619
session variables
((This is a repeat of a message I wrote earlier which seems to not have made
its way out -- it will, of course propogate its way across the net while I'm
typing this one .... ))
This is probably in the wrong group, but since you all have been so helpful,
here goes anyway.
the following code is the end of a routine which stashes data from one form
off to session variables and then redirects itself to the proper form /
procedure depending upon the state of two checkboxes. It work properly as
it stands.
Session("svPersoncbBoats") = Request.Form("cbBoats")
Session("svPersoncbFlood") = Request.Form("cbFlood")
if (Session("svPersoncbAuto") = "checkbox" ) then ' if cbAuto is schecked
this infact contains 'checkbox' ???
Response.Redirect("auto.asp") ' it appears
to since this works right
else
if (Session("svPersoncbHomeOwner") = "checkbox") then
Response.Redirect("HomeOwner.asp")
end if
Response.Redirect("PersonMail.asp")
end if
however, I get to the following code where I'm preparing the email to the
office:
Body = Body & "They have indicated interest in the following coverage:" &
vbcrlf
' the next two lines are displays so I can see what's really in the session
variables .... not!
Body = Body & "Session(svcbHomeOwner) [" & Session("svcbHomeOwner") & "]" &
vbcrlf
Body = Body & "Session(svcbAuto) [" & Session("svcbAuto") & "]" & vbcrlf
if Session("svcbHomeOwner") = "checkbox" then Body = Body & "
Homeowner coverage (see below)" & vbcrlf
if Session("svcbAuto") = "checkbox" then Body = Body & "
Automotive (see below)" & vbcrlf
if Session("svcbTenants") = "checkbox" then Body = Body & " Tenant
coverage" & vbcrlf
the out put from this looks like:
They have indicated interest in the following coverage:
Session(svcbHomeOwner) []
Session(svcbAuto) []
Notice nothing between the brackets which would seem to indicate they are
empty or non-literal - after I compared them to the literal 'checkbox'
above. How should I really be handling this?? What is the default value
returned by a checked / unchecked checkbox (using dreamweaver, btw) the
'value' clause says 'checkbox' and I've been operating under the assumption
that if the box is checked it will return that value, if not a null <???>.
Final comment, the timing factor for a session variable <default of 20
minutes ??> should not be a factor as I filled out the two pages I chose in
less than 10 minutes by thee computer clock.
Comments / suggestions ..... please
(( AL )) Tag: Forwarding O.E. Tag: 162617
Share deletions
Hi everyone;
I searched thru the site for a script that can stop and delete the
share and then delete the folder the share is associated with. Iwould
like the script to pull the information from a text file Tag: Forwarding O.E. Tag: 162615
hello, world
i have a need to practice some vbscript and would like to do it 'old style',
by running simple scripts at the dos command line. i can't figure out a way
to launch it. "cscript myCode.vbs" doesn't work.
what is the basic syntac to launch a script from the command line?
also, can someone jot down a "hello, world" code, along with how to launch
it form the command line.
many thanks,
JCR Tag: Forwarding O.E. Tag: 162611
inline 'if'
Since you all are so quick on the draw (thank you) :)
does VBScript have an inline 'if'?? I'm trying to do the followig:
txt = txt & "It " & if(fireplace) : "has" ? "does not have" & "a fireplace."
If it does, I can't find a reference to it (what's the proper name for it)
and I'm obviously doing something wrong with it.
Or do I have to build this as an if / then / else combination??
(( AL ))
(Make you happy /Al :) )) Tag: Forwarding O.E. Tag: 162610
How can I forward an email message without adding any header or initial
character (i.e. > sign) in the body text?