VBScript Samples
What is the URL to get to all of the samples for vbscript tasks? I saw it
mentioned the other day but didn't save it. Tag: Smart Tags to call vbscript? Tag: 177824
Need Help Adding First Name and Last Name to "Display Name:" field
I'm new to scripting and am trying to automate new users set ups. I'm
using this great script and testing with a user name of John A Smith.
The "First Name:" and "Last Name:" fields populate as expected. The
"Display Name:" field populates as JASmith. I need the name to popluate
this field like this John A Smith. Is this possible? This is the
script I'm using from Mr. Muellers site. Thanks
' CreateUsers.vbs
' VBScript program to create users according to the information in a
' Microsoft Excel spreadsheet.
'
'
----------------------------------------------------------------------
' Copyright (c) 2003 Richard L. Mueller
' Hilltop Lab web site - http://www.rlmueller.net
' Version 1.0 - September 8, 2003
' Version 1.1 - January 25, 2004 - Modify error trapping.
' Version 1.2 - March 18, 2004 - Modify NameTranslate constants.
'
' You have a royalty-free right to use, modify, reproduce, and
' distribute this script file in any way you find useful, provided that
' you agree that the copyright owner above has no warranty,
obligations,
' or liability for such use.
Option Explicit
Dim objExcel, strExcelPath, objSheet
Dim strLast, strFirst, strMiddle, strPW, intRow, intCol
Dim strGroupDN, objUser, objGroup, objContainer
Dim strCN, strNTName, strContainerDN
Dim strHomeFolder, strHomeDrive, objFSO, objShell
Dim intRunError, strNetBIOSDomain, strDNSDomain
Dim objRootDSE, objTrans, strLogonScript, strUPN
' Constants for the NameTranslate object.
Const ADS_NAME_INITTYPE_GC = 3
Const ADS_NAME_TYPE_NT4 = 3
Const ADS_NAME_TYPE_1779 = 1
' Specify spreadsheet.
strExcelPath = "c:\NewUserFolder\NewUsers.xls"
' Specify DN of container where users created.
'strContainerDN = "ou=user,ou=ho,ou=ccmc service
centers,Sales,dc=ccmc,dc=com"
strContainerDN = "ou=test gpos,ou=xyc service centers,dc=ccmc,dc=com"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("Wscript.Shell")
' Determine DNS domain name from RootDSE object.
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("DefaultNamingContext")
' Use the NameTranslate object to find the NetBIOS domain name
' from the DNS domain name.
Set objTrans = CreateObject("NameTranslate")
objTrans.Init ADS_NAME_INITTYPE_GC, ""
objTrans.Set ADS_NAME_TYPE_1779, strDNSDomain
strNetBIOSDomain = objTrans.Get(ADS_NAME_TYPE_NT4)
' Remove trailing backslash.
strNetBIOSdomain = Left(strNetBIOSDomain, Len(strNetBIOSDomain) - 1)
' Open spreadsheet.
Set objExcel = CreateObject("Excel.Application")
On Error Resume Next
objExcel.Workbooks.Open strExcelPath
If Err.Number <> 0 Then
On Error GoTo 0
Wscript.Echo "Unable to open spreadsheet " & strExcelPath
Wscript.Quit
End If
On Error GoTo 0
Set objSheet = objExcel.ActiveWorkbook.Worksheets(1)
' Bind to container where users to be created.
On Error Resume Next
Set objContainer = GetObject("LDAP://" & strContainerDN)
If Err.Number <> 0 Then
On Error GoTo 0
Wscript.Echo "Unable to bind to container: " & strContainerDN
Wscript.Quit
End If
On Error GoTo 0
' Start with row 2 of spreadsheet.
' Assume first row has column headings.
intRow = 2
' Read each row of spreadsheet until a blank value
' encountered in column 5 (the column for cn).
' For each row, create user and set attribute values.
Do While objSheet.Cells(intRow, 5).Value <> ""
' Read values from spreadsheet for this user.
strFirst = Trim(objSheet.Cells(intRow, 1).Value)
strMiddle = Trim(objSheet.Cells(intRow, 2).Value)
strLast = Trim(objSheet.Cells(intRow, 3).Value)
strPW = Trim(objSheet.Cells(intRow, 4).Value)
strCN = Trim(objSheet.Cells(intRow, 5).Value)
strNTName = Trim(objSheet.Cells(intRow, 6).Value)
strUPN = Trim(objSheet.Cells(intRow, 7).Value)
strHomeFolder = Trim(objSheet.Cells(intRow, 8).Value) & strCN
strHomeDrive = Trim(objSheet.Cells(intRow, 9).Value)
strLogonScript = Trim(objSheet.Cells(intRow, 10).Value)
' Create user object.
On Error Resume Next
Set objUser = objContainer.Create("user", "cn=" & strCN)
If Err.Number <> 0 Then
On Error GoTo 0
Wscript.Echo "Unable to create user with cn: " & strCN
Else
On Error GoTo 0
' Assign mandatory attributes and save user object.
If strNTName = "" Then
strNTName = strCN
End If
objUser.sAMAccountName = strNTName
On Error Resume Next
objUser.SetInfo
'WScript.Echo Err.Number
'WScript.Echo Err.Description
If Err.Number <> 0 Then
If Err.Number = -2147019886 Then
Wscript.Echo strNTName & " User already exists."
Else
Wscript.Echo "Unable to create user with NT name: " &
strNTName
End If
On Error GoTo 0
Else
' Set password for user.
objUser.SetPassword strPW
If Err.Number <> 0 Then
On Error GoTo 0
Wscript.Echo "Unable to set password for user " & strNTName
End If
On Error GoTo 0
' Enable the user account.
objUser.AccountDisabled = False
If strFirst <> "" Then
objUser.givenName = strFirst
End If
' Assign values to remaining attributes.
If strMiddle <> "" Then
objUser.initials = strMiddle
End If
If strLast <> "" Then
objUser.sn = strLast
End If
If strUPN <> "" Then
objUser.userPrincipalName = strUPN
End If
If strHomeDrive <> "" Then
objUser.homeDrive = strHomeDrive
End If
If strHomeFolder <> "" Then
objUser.homeDirectory = strHomeFolder
End If
If strLogonScript <> "" Then
objUser.scriptPath = strLogonScript
End If
' Set password expired. Must be changed on next logon.
objUser.pwdLastSet = 0
' Save changes.
On Error Resume Next
objUser.SetInfo
If Err.Number <> 0 Then
On Error GoTo 0
Wscript.Echo "Unable to set attributes for user with NT name: "
_
& strNTName
End If
On Error GoTo 0
' Create home folder.
If strHomeFolder <> "" Then
If Not objFSO.FolderExists(strHomeFolder) Then
On Error Resume Next
objFSO.CreateFolder strHomeFolder
If Err.Number <> 0 Then
On Error GoTo 0
Wscript.Echo "Unable to create home folder: " &
strHomeFolder
End If
On Error GoTo 0
End If
If objFSO.FolderExists(strHomeFolder) Then
' Assign user permission to home folder.
intRunError = objShell.Run("%COMSPEC% /c Echo Y| cacls " _
& strHomeFolder & " /T /E /C /G " & strNetBIOSDomain _
& "\" & strNTName & ":F", 2, True)
If intRunError <> 0 Then
Wscript.Echo "Error assigning permissions for user " _
& strNTName & " to home folder " & strHomeFolder
End If
End If
End If
' Dim ObjNet
' Set ObjNet = CreateObject("Wscript.Network")
' ObjNet.MapNetworkDrive "u:", strHomeFolder
' Set ObjNet = nothing
Dim oMailBox
Set oMailBox = objUser
oMailbox.CreateMailbox Trim(objSheet.Cells(intRow, 11).Value)
'WScript.Echo FindAnyMDB()
objUser.setInfo
Set oMailBox = Nothing
' Group DN's start in column 11.
intCol = 12
Do While objSheet.Cells(intRow, intCol).Value <> ""
strGroupDN = Trim(objSheet.Cells(intRow, intCol).Value)
On Error Resume Next
Set objGroup = GetObject("LDAP://" & strGroupDN)
If Err.Number <> 0 Then
On Error GoTo 0
Wscript.Echo "Unable to bind to group " & strGroupDN
Else
objGroup.Add objUser.AdsPath
If Err.Number <> 0 Then
On Error GoTo 0
Wscript.Echo "Unable to add user " & strNTName _
& " to group " & strGroupDN
End If
End If
On Error GoTo 0
' Increment to next group DN.
intCol = intCol + 1
Loop
End If
End If
Set objUser = nothing
' Increment to next user.
intRow = intRow + 1
Loop
Wscript.Echo "Done"
' Clean up.
objExcel.ActiveWorkbook.Close
objExcel.Application.Quit
Set objUser = Nothing
Set objGroup = Nothing
Set objContainer = Nothing
Set objSheet = Nothing
Set objExcel = Nothing
Set objFSO = Nothing
Set objShell = Nothing
Set objTrans = Nothing
Set objRootDSE = Nothing Tag: Smart Tags to call vbscript? Tag: 177823
script to enable Wakeup on NIC
Hello all,
I'm trying to write a script to enable the power management features for a
NIC, specifically to enable:
allow the computer to turn off this device to save power
allow this device to bring the computer out of standby
Only allow management stations to bring the computer out of standby
I have had a look thru WMI and cannot locate a value I can manipulate. This
needs to be changed on 1000's of computers... Can it be scripted?
Thanks in advance,
John Tag: Smart Tags to call vbscript? Tag: 177820
Compare text files for duplicates
Hi. I have two text files that are actually exports of user and computers
accounts from two domains. I would like to be able to compare the two files
for duplicate names and spit out a "report" of the unique names and duplicate
names.
Of course, I can't do a line-by-line comparison because the files don't
match up that way. It is more of a comparison of the entire contents of the
files.
Maybe logparser would do this?
Thanks! Tag: Smart Tags to call vbscript? Tag: 177818
Detecting the OS Language
Does anyone have a good way to detect the OS Language Windows is using with
VBScript?
Thanks
Tom Tag: Smart Tags to call vbscript? Tag: 177817
WE INVITE YOU
--WebTV-Mail-19411-12917
Content-Type: Text/Plain; Charset=US-ASCII
Content-Transfer-Encoding: 7Bit
Hello My friends hope everyone doing well.
We have a new News Group for people to discuss topics of there concern..
Please take the time to stop by and say hello...Yes it's Docextreme.
This group was formed for all TOPIC'S
WEBTV, PC, related questions if you would like to start a TOPIC by all
means do so.
The WEBTV world is changing so much we now have TNB...as well I have not
yet use one but I hear alot of things about it not all good.
let us know what you know about TNB..
You think if Microsoft came out with a new box it would better then what
we have now after we are the one making them rich...
TOOL'S I think this is a good topic seeing we use web tools each and
everyday. What are some of your favorite tools to use? and offen do you
use them. I have already started a TOOL topic you can follow it with
your coments I would really like to know what are your favorites.
Thank you all so much for the support you have giving me over the past
years I thank you so much....Hope to see some of the nics I am use to
seeing....
P.S. PLEASE read charter before post
Server Extreme News Group
news:alt.discuss.clubs.public.website.promotion.serverextreme
--WebTV-Mail-19411-12917
Content-Description: signature
Content-Disposition: Inline
Content-Type: Text/HTML; Charset=US-ASCII
Content-Transfer-Encoding: 7Bit
<html><body bgcolor="#ffffff"text="000066"><br><br><font
size="3"color="#000066"><u><b>Affordable Hosting</b></u></font>
<p><font size="2"color="#000066"><b>Server Extreme Hosting</b></font>
<a href="http://serverextremehosting.com"><br><font
color="darkgoldenrod">http://serverextremehosting.com</font></a>
<p><font size="2"color="#000066"><b>Server Extreme News Group</b></font>
<a
href="news:alt.discuss.clubs.public.website.promotion.serverextreme"><br><font
color="darkgoldenrod">news:alt.discuss.clubs.public.website.promotion.serverextreme</font></a>
<p>
<font size="2"color="#000066"><b>ServerExtreme Forum</b></font><a
href="http://www.serverextremehosting.com/Support/"><br><font
color="darkgoldenrod">http://serverextremehosting.com/Support/</font></a>
<center><p><br><br><font size="2"color="#000066"><u>Powered By: Server
Extreme Hosting</u></font></center><bgsound
src="http://tabledoc.serverextremehosting.com/ExtremeMod/SEA.mod"loop="5">
</body></html>
--WebTV-Mail-19411-12917-- Tag: Smart Tags to call vbscript? Tag: 177816
Running a script using VB6 ScriptControl
First I apoligize for cross posting this also on the vb.controls newsgroup,
I just wasn't quite sure which group would be better suited to handle my
question...
I'm running a script (set up as a string) internal in my VB6 program and
feeding it into the MS ScriptControl. All works well except that I need the
script to
"sleep" for a few seconds. If I wrote the script as a standard .vbs script
file outside of VB I would add a line like this - WScript.Sleep(3000) -
With the WScript object being the intrinsic built in object of the scripting
engine. However, adding that line to my script string in the VB6 program
throws rt error 424 "Object Required: WScript".
So it seems the intrinsic object WScript is not recognized when you run a
script using the VB ScriptControl.
Anybody know how to get around this problem so that the WScript object can
be used, or at least how to make the script "Sleep"
TIA
Ron Tag: Smart Tags to call vbscript? Tag: 177815
vb script to run a desktop shortcut
what would be the way in VBS to run a desktop shortcut... I can't just call
the program exe as there are parameters I need that are in the
shortcut....mainly start in
thx. Tag: Smart Tags to call vbscript? Tag: 177812
Error Handling
Good morning,
I have the following script (feel free to improve/comments so I can learn).
My problem is that it uses a text file to give it a series of computername to
run the script against. The issue is that when a computer is turned off, the
script returns an error. I would like to trap that error and then move on to
the next computer in the text file. Could someone guide me as to why my
error handler does not work.
'*********************VBS Code starts here*******************
On Error GoTo ErrHandler
ForReading = 1
strNewFile = "PCListing01.txt"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(strNewFile, ForReading)
Do Until objFile.AtEndOfStream
strComputer = objFile.ReadLine
'Set objOption = Document.createElement("OPTION")
'objOption.Text = strLine
'objOption.value = strLine
'CmptName.add(objOption)
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery("Select * from
Win32_OperatingSystem")
For Each objOS in colOperatingSystems
dtmBootup = objOS.LastBootUpTime
dtmLastBootupTime = WMIDateStringToDate(dtmBootup)
dtmSystemUptime = DateDiff("h", dtmLastBootUpTime, Now())
strHTML = strHTML & strComputer & " has been up for " &
dtmSystemUptime & " hrs" & vbcrlf
'Wscript.Echo strComputer
'Wscript.Echo dtmBootup
'Wscript.Echo dtmLastBootupTime
'Wscript.Echo dtmSystemUptime
Next
Loop
objFile.Close
Wscript.Echo strHTML
Function WMIDateStringToDate(dtmBootup)
WMIDateStringToDate = CDate(Mid(dtmBootup, 5, 2) & "/" & Mid(dtmBootup,
7, 2) & "/" & Left(dtmBootup, 4) _
& " " & Mid (dtmBootup, 9, 2) & ":" & Mid(dtmBootup, 11, 2) & ":" &
Mid(dtmBootup, 13, 2))
End Function
ErrHandler: ' this is a named range called ErrHandler
' If there was an error raised by the function we would wind up in here 'so
display a message to the user to 'show what went wrong
if err.number=0x80041003 then
strHTML = strHTML & "Unable to reach " & strComputer
Next ObjFile
Resume Next
else
'MsgBox "An error happened here!" & vbCrLf & _
'"Error number: " & Err.Number & vbCrLf & _
'"Error Description" & Err.Description & vbCrLf & _
'"Error Help Context ID" & Err.HelpContext & vbCrLf & _
'"Error Help File" & Err.HelpFile, vbCritical, "ERROR MESSAGE"
'Err.Clear ' destroy the error andâ?¦
' â?¦ this resumes in the last known position.
' in this case, since its not more than a file opening occurring,
' it will simply exit the function for you.
Resume Next
end if
'*********************VBS Code ends here*******************
Thanks,
Daniel Tag: Smart Tags to call vbscript? Tag: 177807
Setting Terminal Server settings in AD
HI all:
Does anyone have any code that will allow me to change a users terminal
server settings in AD? I used to use TSCMD.exe on W2K terminal servers but
now its has stopped working and is giving an error 1317 cannot set user
settings. The script that I was using before without problems no longer
works and I am looking for something new! any suggestions would be great! Tag: Smart Tags to call vbscript? Tag: 177796
What does this permission indicate...
I run a vbs script on several machines. All has worked except for one
machine. The script essentially performs a backup via WinZip and places the
result in a shared folder.
When I then try to copy the script from the master station, this one
workstation gives me an 'access denied' message. I am running as
administrator on all machines. By the way, I'm running XP Home /SP2 with
Norton AV , and I run SptBot-Search & Destroy. No indicated problems.
I looked at the permissions on the shared folder and I noticed something on
this workstation that I have never seen on the other workstations on our
private lan:
NT AUTHORITY\NETWORK SERVICE:(special access:)
DELETE
SYNCHRONIZE
FILE_READ_DATA
If I remove file sharing on this folder and then re-apply file sharing, this
entry disappears (and my network copy works fine). Furthermore, if I go
into safe-mode and look at the permissions, it says that this item is an
'unknown user'.
What is Win XP trying to tell me? I have never seen this type of permission
before.
Dick Tag: Smart Tags to call vbscript? Tag: 177794
How to send log file via email
This is a multi-part message in MIME format.
------=_NextPart_000_00D7_01C58BAC.DA457CF0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
How do I send a log or text file over e-mail as a service. The unit in =
question will not be logged in???
--=20
SHANE CLARK
------=_NextPart_000_00D7_01C58BAC.DA457CF0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1499" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>How do I send a log or text file over =
e-mail as a=20
service. The unit in question will not be logged in???</FONT></DIV>
<DIV><FONT face=3DArial size=3D2><BR>-- <BR>SHANE =
CLARK</FONT></DIV></BODY></HTML>
------=_NextPart_000_00D7_01C58BAC.DA457CF0-- Tag: Smart Tags to call vbscript? Tag: 177788
Show jpeg in a VBS dialog (message) box????
Hello,
Is there a way to show a thumbnail of a jpeg file in a VBS dialog (message) box?
TIA,
Bill
bill@2burkes.com Tag: Smart Tags to call vbscript? Tag: 177784
getting script to paste text into Word AND to trigger AutoOpen macro
I have an .htm file, which is run from a button I installed on the
Internet Explorer shortcut menu, which contains Windows script that does
the following:
1. copies the selected text on the current web page and assigns the url
of the web page to a variable;
2. opens a special Word document created for this purpose;
3. pastes the selection and inserts the url into the Word document.
However, I also have an AutoOpen macro in the Word document which is
intended to perform further steps on the pasted material. The problem
is that the actions initiated by the script, such as the pasting of the
text, seem to prevent the AutoOpen macro from running.
Here's my question: Is it possible both to have the script open the
Word document and paste stuff into it, AND to have an AutoOpen macro
proceed to do further actions on the pasted text? If not, is there some
other way that the script could automatically run a macro in the Word
document?
Thanks,
Larry Tag: Smart Tags to call vbscript? Tag: 177781
Script to add IPP printer connection
I'm trying to use AddWindowsPrinterConnection. I need to connected to an IPP
printer. Which command should I use?
Thank you Tag: Smart Tags to call vbscript? Tag: 177780
using a text file as source for strcomputer in vbs script.
I have the following VBS script for ending a process on a remote pc.
as follows
strComputer = "COMPUTERNAME"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer &
"\root\cimv2")
Set colProcessList = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = 'PROCESSNAME'")
For Each objProcess in colProcessList
objProcess.Terminate()
Next
However if I want to run this on the whole of an OU how should I go
about this? I can get a list of pcs into a text file, but how do I
have it so that the computer name is sourced from this list?
Thanks
Dan Tag: Smart Tags to call vbscript? Tag: 177777
WshController error
Hello all,
I've been doing some research on WshController, and I read recently
that one hang up that WshController has is that it can't be used with
UI. I'm trying to execute a vbscript that uses WshController from a
jsp page. According to an article I read it says: "the script passed
to the WshController object's CreateScript method doesn't interact with
the UI. In other words, you need to avoid using WScript.Echo, STDIO,
WshShell::Popup, MsgBox, InputBox, and other UI functions in the script
that the target remote computer will run." Is this true? Has anyone
been able to interact with WshController from a jsp? Tag: Smart Tags to call vbscript? Tag: 177776
How to create a variable of type Long
Hi,
VBScript has a lot of predefined constants with predefined data types. For
example, vbYellow is type long and has the value &h00FFFF (65535). How can
I create constant myYellow of type long, given a hex string of the format
&h00FFFF?
The following obviously doesn't work:
---
const myYellow = &h00FFFF
MsgBox "(vbYellow = &h00FFFF) is " & (vbYellow = &h00FFFF) & vbCrLf & _
"(vbYellow = 65535) is " & (vbYellow = 65535) & vbCrLf & vbCrLf & _
"(myYellow = &h00FFFF) is " & (myYellow = &h00FFFF) & vbCrLf & _
"(myYellow = 65535) is " & (myYellow = 65535)
---
The script gives me:
(vbYellow = &h00FFFF) is False
(vbYellow = 65535) is True
(myYellow = &h00FFFF) is True
(myYellow = 65535) is False
Thanks,
-Paul Randall Tag: Smart Tags to call vbscript? Tag: 177775
How to define a function launched only at the end of script
My script runs from CRT application (telnet, ssh, serial, ...
application). In the script, I create a temporary file who contains
instructions to push to CRT window and log information are pushed in an
history log file.
Now, i would like to remove temporary file and close history file when
the script is finished (on error, on abort or at the end on script)
Any idea ?
Thanks Tag: Smart Tags to call vbscript? Tag: 177766
How to get usable screen size (maybe WMI?)
Hi all,
I am trying to determine the usable screen size of desktop computers. I
found WMI classes that would return the desktop resolution BUT I need:
[screen height] - [taskbar height] = [usable screen size]
Is there a way to determine if the auto-hide is enabled? Can I determine the
height of the taskbar?
I use the "Win32_DesktopMonitor" WMI class at the moment but this only
returns the set screen resolution.
Any idea on how to do this via WMI or maybe read values out of the registry.
I looked into some TechNet articles but I didn't find anything helpful yet.
Regards,
Hadi Tag: Smart Tags to call vbscript? Tag: 177765
File download
How can I use vbscript to download a file from web server?
... or should I use other means to do the task? (The web server
is general one.)
TIA
Milos Tag: Smart Tags to call vbscript? Tag: 177763
Newbie - How to fill forms without a button click
Hi,
1. Automatically filling in a form from a database.
When the user logs in, it should take the user to something like the
Registration page
and automatically fill in the fields from a database. I know to do
document.Register.FirstName.value = "Hello World"
but I need to fill in the fields before a button is pressed.
I am not sure how I can fill in the fields before a button is pressed?
Perhaps somehow getting a message from the login.asp page that clicks the
button?
P.S. I just started monkeying around with ASP pages. I am not sure what the
difference is between VBScript, JavaScript, C#, XML.
I noticed in a tutorial that VBScript is not supported in all browsers. Does
that go for JavaScript?
Is C# supposed to be better than Java or VB?
Thanks,
--
Christopher J. Holland
Holland Projects
8444 Capricorn Way Suite 2
San Diego, CA 92126
web: http://home.san.rr.com/webmain
email: chollan2@san.rr.com
phone: (858) 530-0122
cell: N/A
Fax: N/A Tag: Smart Tags to call vbscript? Tag: 177762
Change Machine group policy with vbscript
Hi,
I need to change local machine group policy to set the security
level for .js extensions to "Unrestricted"
This will not be overwritten by domain gp.
Can this be done by vb script. I've tried with caspol .bat but without
any luck.
any ideas much appreciated.
Cheers
Matt Tag: Smart Tags to call vbscript? Tag: 177761
Write data to and read data from RS232C
Hello,
I´m looking for a Sample-Script (VBScript or JScript), which is able to
write data to the Com1-Port (RS232C) and read data from this port. I don't
have MSCOMM32 on my system. I think, there should be some other solutions
(e.g. with use command-line functionality via RUN or an Active-X-Object,
that can use with CreateObject.
Thanks for helpful hints.--
V.Schmidt Tag: Smart Tags to call vbscript? Tag: 177755
ASP SQL Update Query
I am trying to update a field in an Access DB using ASP, but I get the
following error.
Microsoft JET Database Engine error '80004005'
Operation must use an updateable query.
If I put the same code into a VBS file the update works file (See below)
*******************************************************************
DatabaseFile = """C:\web\changes.mdb"""
Set adoCon = CreateObject("ADODB.Connection")
adoCon.open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DatabaseFile)
strReason = "Work Damn you"
SQLQuery = "UPDATE Table SET Table.Reason='" & strReason & "' Where id=54"
adoCon.execute(SQLQuery)
********************************************************************
Does anyone know why the exact same code wont work in ASP? Tag: Smart Tags to call vbscript? Tag: 177754
email
Any good utilties or built in objects with Windows 2000 that will allow me
to send email via vbscript and attaching a file. Tag: Smart Tags to call vbscript? Tag: 177753
Standardize screensaver and wallpaper
Hi,
I need to manage 100 desktops which are Win98, WinNT, Win2K and WinXP. I
want to standardize the screensaver and wallpaper. I know this can be done
by group policy but I need to do it by executing script from a server.
Thank for your attention and advice.
Best Regards,
Boteasy Tag: Smart Tags to call vbscript? Tag: 177748
Can I script a IE session
Hi
I'm looking for a way to control which JAVA JRE to use in a IE session.
Is there a way to control this?
When installing Java JRE it looks like it should be possible to use a
specific Java JRE version when opening IE, anyway I need this possibility,
I've got two application and they don't support the same Sun Java JRE.
Hoping for the best
Kjell Liljegren Tag: Smart Tags to call vbscript? Tag: 177741
copy files
hello ng,
i will copy all files (exclude my vbscript file copy.vbs) to a folder...
in vb there was a app.path parameter... is there something in vbscript
so i can copy files from a "unknown" Folder (there is my copy.vbs)
to a defined location???
thanks for help
manfred büttner Tag: Smart Tags to call vbscript? Tag: 177729
How to get long filename from short filename?
This demonstration script is not yet successful.
I would like to get the long name from the short name of a file (in
this case, given as a command-line argument).
I was hoping that either the name or the path property of the file
object would do it, but no joy. The name property = the same short
name given. The path property (default) also just gives the short name
after the subdirectory. There is no "longname" property.
So how is it done?
----------------------------------------------
dim oArgs, oFi, oFS
set oArgs = Wscript.Arguments
if oArgs.count=0 then
wscript.echo "No argument given"
wscript.quit
end if
set oFS = CreateObject("Scripting.FileSystemObject")
set oFi = oFS.GetFile(oArgs.item(0))
wscript.echo oFi.name
wscript.echo oFi Tag: Smart Tags to call vbscript? Tag: 177723
Writing a text file from within a script only if a candition is th
I've write a VB script that retrive all error events from Event Logs on the
local machine (by Win32_NTLogEvent) and write it to an output text file.
The script is scheduled to run every day at a specified time and retrive
only events occurred in the previous 24 hours.
Actually it open and write the output text file always, even if no error
events logs occurred (in this case the output text file is, obviously, empty).
The question is:
is there a way to open and write the output text file only if it is no empty
(if an error occurred) and in wich mode?
In this way, in fact, every day I'll check the local machine and only if
there was errors in the event logs in the previous day I'll find the output
text file without the needs to check and read an empty output text file.
Thanks in advance.
Cosimo MERCURO Tag: Smart Tags to call vbscript? Tag: 177722
Difference Between Two Pages
Hi,
I have content for a 'Live' page in one cell in Table_A and content for
an 'edited' page in anotehr cell in Table_B.
How do I track differences? Hihlight additions, changes and deletions?
Ideally I'd show the two pages (frames maybe) and show the differences
between the two.
Any ideas? Any scripts floating about already?
Thanks Tag: Smart Tags to call vbscript? Tag: 177721
Change permission remotely
Hi,
I would like to change security permission for everyone from "no access" to
"read only" on each temp folder. I have about 200 computers to reset. Is it
a way to do it by VBscript?
Thanks Tag: Smart Tags to call vbscript? Tag: 177719
Query IP Addresses from DHCP
I have an SBS03 Server and I would like to be able to look up the IP address
from an Computer Name. The application is a script to turn on a group of
computers every morning. These are workstations in the exam rooms of a
doctor's office. The staff is always forgetting to turn all of them on in
the morning and the doctor then has to wait for the computer to boot while
the patient is sitting there. It would also fit well for turning them on
early and letting them load their updates before business hours.
My concern is if their lease runs out and DHCP issues them a new IP, then
the WOL magic packet will end up at the wrong computer.
Thanks,
Bernie Tag: Smart Tags to call vbscript? Tag: 177717
How to change current directory?
I have an application I need to run, however, it needs to execute in a
specific directory.
This directory it needs to run in is different to the one that my .vbs
script is running in.
How can I change the current directory so that the program executes from
within that directory.
eg.
I have C:\script.vbs which must run C:\foo\bar.exe. Modifying bar.exe is
beyond my control, and it must run in C:\foo.
The down side is that script.vbs must run from c:\
I have tried using the .Run method on the Shell object to run DOS commands,
but I keep getting the error:
C:\script.vbs(283, 10) (null): The system cannot find the file specified.
This would be where line 283 is something like:
oShell.run "dir"
Thanks. Tag: Smart Tags to call vbscript? Tag: 177707
cannot execute my vbscript in a batch file called from a jsp
Hello all,
I'm trying to execute my vbscript through a batch file. I can run it
if by double clicking, but I want to attach the execution of the button
to a button click on a jsp page. I have the code setup for that, but
it looks like when I click the button in the jsp page, my vbscript
errors out. my code is pasted below:
strEssbaseServer = "someserver"
strStartupScript = "test.vbs"
filLog.WriteLine "Setting vars worked"
Set objWshController = WScript.CreateObject("WshController")
filLog.WriteLine "setting objWshController worked"
Set objRemoteScript = objWshController.CreateScript(strStartupScript,
strEssbaseServer)
filLog.WriteLine "Setting objRemoteScript worked"
Wscript.ConnectObject objRemoteScript, "Remote_"
filLog.WriteLine "Setting wscript.connectobject worked"
If Err.Number <> 0 Then
filLog.WriteLine "Error creating remote script."
Err.Clear
End If
objRemoteScript.Execute
It looks like it's erroring out at this line: Set objRemoteScript =
objWshController.CreateScript(strStartupScript, strEssbaseServer)
Any thoughts? Do I have to follow a different syntax since I'm
executing this from a bat file which is called by a jsp page? Thanks
in advance.
Ian Tag: Smart Tags to call vbscript? Tag: 177706
ASP error traping problem
I am unable to trap and handle errors in ASP. I am running function which
returns value. When in the function and error is raised (ADO or VBscript
related) the function simply ends. NO error handling or whatever code after
line where error arouse gets executed. Function just returns with no return
value. Is that normal and what can i do? Tag: Smart Tags to call vbscript? Tag: 177704
Reading From and Writing To text files
Greetings,
I posted earlier on my project which is to create vbscript to take a
text file that has spaces between columns of data and convert it so
that the field are separate by semi-colons instead of a block of
spaces. I have figured out most of the code I'm going to need for this
project, but there is one area where I'm still hanging.
I need to know how to:
select a text file by name
Open it
Read characters from it into a variable or array
after processing I need to:
Write the converted to anothe text file
Name that file (save it) and close it
I've read up on this at a couple of sites, but I'm still confused.
Does anyone know of a good tutorial on this or could someone post this
information. Any help at all would be greatly appreciated.
Thanks,
Tammy Tag: Smart Tags to call vbscript? Tag: 177695
Net Send script help
I've created a user interface in VBScript that compliments the NET SEND
command. It allows the user to input any number of computer names seperated
by a comma (,), then input the message that they want to send. Finally, It
displays a summary of what message was sent and the computer names.
This thing is that I'd like for it to display all the computer names on the
same message box. The way I have it now, it displays each PC in it's own
popup box.
How can I modify my script to display a list of all the PCs that got the
message using the msgbox function?
Dim arrPCnames()
intSize = 0
Set objShell = Wscript.CreateObject("WScript.Shell")
'Get computer names
PC2Reach = InputBox("Please enter the computer name. For additional
computers, separate each with a comma (,)"
'Get message
Message2Send = InputBox("Type your message.", "Send a message")
arrStations = Split(PC2Reach, ",")
'Send message
For Each PC2Reach In arrStations
objShell.Run "net send " & PC2Reach & " " & Message2Send
ReDim Preserve arrPCnames(intSize)
arrPCnames(intSize) = PC2Reach
intSize = intSize + 1
Next
'Summary of command
MsgBox "Here's you message:" & vbCrLf & _
vbCrLf & _
Message2Send & vbCrLf & _
vbCrLf & _
"Computers that got the message:"
For Each strName in arrPCNames
Wscript.Echo strName
Next Tag: Smart Tags to call vbscript? Tag: 177692
Kill process based on a user who started it
I am using this script to kill all java.exe on my system:
set wmi = getobject("winmgmts:")
wql = "select * from Win32_Process " _
& " where name='java.exe'"
set results = wmi.execquery(wql)
for each app in results
app.terminate
next
I need to be more specific and kill only java.exe processes that had been
started by a particular user.
How can I do this?
Thx
YuriW Tag: Smart Tags to call vbscript? Tag: 177689
Drive Map Script not Reading User Groups
We recently moved to W2K servers from NT and therefore have not used scripts
on the servers before. I have in the past, but I am a bit rusty. Anyway, I
have written a script to map network drives based upon a user's group. I know
the script works in regard to mapping since I've included a test mapping at
the end by making the Group set to NULL. What I can't figure out is why the
User Groups are not being properly pulled into the script by the code I have
written. Any help will be appreciated greatly. Tech@HillCenter
------------------------------------------------------------------------------
'All actual server names have been removed from the script.
On Error Resume Next
'PC User Logon Script to Automate Drive Mappings"
Const ADMIN_GROUP = "cn=Admin"
Const ADMISSIONS_GROUP = "cn=Admissions"
Const DEVELOPMENT_GROUP = "cn=Development"
Const FACULTY_GROUP = "cn=Faculty"
Const FINANCE_GROUP = "cn=Finance"
Const MARKETING_GROUP = "cn=Marketing"
Const PROF_DEV_GROUP = "cn=ProfDev"
Const SPOC_GROUP = "cn=SPOC"
Set wshNetwork = CreateObject("WScript.Network")
Set ADSysInfo = CreateObject("ADSystemInfo")
Set CurrentUser = GetObject("LDAP://" & ADSysInfo.UserName)
strGroups = LCase(Join(CurrentUser.MemberOf))
If InStr(strGroups, ADMIN_GROUP) Then
wshNetwork.MapNetworkDrive "U:", "\\FILESERVER\ADMIN\"
wshNetwork.MapNetworkDrive "I:", "\\FILESERVER\IMAGES\"
wshNetwork.MapNetworkDrive "L:", "\\FILESERVER\FORMS\"
ElseIf InStr(strGroups, ADMISSIONS_GROUP) Then
wshNetwork.MapNetworkDrive "W:", "\\FILESERVER\ADMISSIONS\"
ElseIf InStr(strGroups, DEVELOPMENT_GROUP) Then
wshNetwork.MapNetworkDrive "G:", "\\FILESERVER\DEVELOPMENT\"
ElseIf InStr(strGroups, FACULTY_GROUP) Then
wshNetwork.MapNetworkDrive "H:", "\\FILESERVER\FACULTY\"
ElseIf InStr(strGroups, FINANCE_GROUP) Then
wshNetwork.MapNetworkDrive "F:", "\\FILESERVER\FINANCE\"
ElseIf InStr(strGroups, MARKETING_GROUP) Then
wshNetwork.MapNetworkDrive "M:", "\\FILESERVER\MARKETING\"
ElseIf InStr(strGroups, PROF_DEV_GROUP) Then
wshNetwork.MapNetworkDrive "P:", "\\FILESERVER\PROFDEV\"
ElseIf InStr(strGroups, SPOC_GROUP) Then
wshNetwork.MapNetworkDrive "S:", "\\FILESERVER\SPOC\"
ElseIf InStr(strGroups, " ") Then
wshNetwork.MapNetworkDrive "T:", "\\FILESERVER\FACULTY"
End If Tag: Smart Tags to call vbscript? Tag: 177687
Determining whether the Word window is minimized
Gary Terhune created this handy vbs code for me a while back. It
activates the already open (but not activated) Word window. I run it
with a Winkey combo and it works fine, though there is a slight pause
(which I can probably address with more memory). .
However, I'm wondering if I might also speed it up by checking to see
ifWord is minimized, and then only run the SendKeys statement if the
window is minimized. That might help the code work faster. So how
would I determine if Word is minimized?
Option Explicit
dim w
With WScript.CreateObject("WScript.Shell")
w = .AppActivate("Microsoft Word")
' restores Word if Word is minimized
.SendKeys ("% r")
End With
Thanks,
Larry Tag: Smart Tags to call vbscript? Tag: 177685
Null Error in my Script, HELP!!
I keep getting this error when I attempt to run a vbscript (logon script) on
my users computers that has some numbers and source is just (null). The part
of the code is as follows:
Const G_MCEDENDrAccess = "cn=mc_eden_drive_access"
Dim oNetwork
Dim oADSysinfo
Dim oUser
Dim sGroups
'Defining values and querying AD for user information
Set oNetwork = CreateObject("WScript.Network")
Set oADSysInfo = CreateObject("ADSystemInfo")
Set oUser = GetObject("LDAP://" & oADSysInfo.UserName)
sGroups = LCase(Join(oUser.MemberOf))
I get the error at Set oUser = GetObject.........
Its almost like an LDAP problem query for group membership in Active
Directory. Now it works on my account, which I am a domain admin, which
should not matter because everyone cannot be a domain admin.
someone please help.
Thanks Tag: Smart Tags to call vbscript? Tag: 177680
excel object
I am working on a script to automate merging excel files but I think I ran
into a snag. In order to crete an excel object do I have to have excel on
the server? My guess is yes but I can't move yet to a server for testing.
Set xlApp = CreateObject("Excel.Application")
Set xlOutBook = xlApp.Workbooks.Add
Thanks
Mike Tag: Smart Tags to call vbscript? Tag: 177670
How to get first element in a collection of items?
For a logon script I would like to retrieve the screen resolution of our
desktops. The following script is working fine on single monitor desktops.
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer &
"\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from
Win32_DesktopMonitor",,48)
For Each objItem in colItems
Wscript.Echo "ScreenHeight: " & objItem.ScreenHeight
Wscript.Echo "ScreenWidth: " & objItem.ScreenWidth
Next
But if more monitors are connected I am interested only in the first one.
How do I get that information? I tried:
Wscript.Echo "ScreenHeight: " & colItem(0).ScreenHeight
... but it doesn't work.
What am I doing wrong?
Thank you for looking into this!
Hadi Tag: Smart Tags to call vbscript? Tag: 177666
Win32_NetworkConnection on Remote Computer
How to extract Win32_NetworkConnection from Remote Computer? If know next info
Win32_LogonSession.LogonId = <AnyID>, Win32_LogonSession.LogonType = 2
(interactive) Tag: Smart Tags to call vbscript? Tag: 177663
Script help!!
Can some one help me out with this. I created this script and I am trying
to apply it to a group policy that I created for AD.
'
' Printers.vbs - Windows Logon Script.
Set objNetwork = CreateObject("WScript.Network")
objNetwork.AddWindowsPrinterConnection "\\recwarehouse\label_printer."
The ending for the printer share name is label_printer. I have placed the
script in
\\hh.hrm.lan\SysVol\hh.hrm.lan\Policies\{97F3974A-8BEC-42E7-A663-C229A972637A}\User\Scripts\Logon.
When the user that I applied the GP to his OU logs in he gets this error on
his screen. Windows Script Error - Line: 4 Char: 1 Error: The specified
module could not be found. Code: 8007007E Source: (null). This is my first
attempt at using scripts so if some one knows and can explain in detail that
would be helpful.
Thanks!
--
Scott Micale
Director of IT
330-877-3631 Tag: Smart Tags to call vbscript? Tag: 177659
Script help!!!!
Can some one help me out with this. I created this script and I am trying
to apply it to a group policy that I created for AD.
'
' Printers.vbs - Windows Logon Script.
Set objNetwork = CreateObject("WScript.Network")
objNetwork.AddWindowsPrinterConnection "\\recwarehouse\label_printer."
The ending for the printer share name is label_printer. I have placed the
script in
\\hh.hrm.lan\SysVol\hh.hrm.lan\Policies\{97F3974A-8BEC-42E7-A663-C229A972637A}\User\Scripts\Logon.
When the user that I applied the GP to his OU logs in he gets this error on
his screen. Windows Script Error - Line: 4 Char: 1 Error: The specified
module could not be found. Code: 8007007E Source: (null). This is my first
attempt at using scripts so if some one knows and can explain in detail that
would be helpful.
Thanks!
--
Scott Micale
Director of IT
330-877-3631 Tag: Smart Tags to call vbscript? Tag: 177657
GetObject("LDAP:// error 8007200a
Hi, first post, wahooo
I had an IIS5 ASP web running on a Win2k DC the web connected to AD no
problems at all, it goes and gets users...
I have moved the web to a member server win2k3 IIS6 now getting AD
connection errors
error '8007200a'
/core.inc, line 60
Here is Line 59 & 60
Set RootDSE = GetObject("LDAP://RootDSE")
Set PeopleRoot = GetObject("LDAP://OU=People, " &
RootDSE.Get("DefaultNamingContext"))
if I fire up the old DC and run the web the same code works!
any help, please
Thanks in advance. Tag: Smart Tags to call vbscript? Tag: 177653
Anyone know if its possible to use smart tags to call a
vbscript...without having to write a custom dll or use the sdk? Just
wondering if its possible via a simple xml file.