Parameters in quotes treated as one
Hello. I need to acomplish a task, but I have no idea how to do it.
My script has to pass some text into email.
Set collArg = WScript.Arguments
Dim mail
mail = collArg(0)
Dim topic
topic = collArg(1)
Dim body
body = collArg(2)
Set WshShell = WScript.CreateObject("WScript.Shell")
strCommand = "mailto:" & mail & "&subject=" & topic & "&body=" & body
WshShell.Run strcommand
The thing is that parameters like Subject and Body will have spaces.
Parameters then will be passed in "quotes" and they should be treated
as one parameter. How can I do it? Tag: please i want script to make ip assigned by dhcp Tag: 211403
Lopping delete row and remove CRLF
Hi all,
I've got 2 codes from previous message posts but need to combine them.
The first bit removes the last 2 characters but only does for one
line, how would I loop it to do many lines so no CRLF (and still
remains in it's orginal layout).
The section bit deletes rows beginning with 345.
I've tried to combine the two but no luck.
Thanks,
Ed
'removes carriage returns and line feeds
Const ForReading = 1
Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\abc.10", ForReading)
strFile = objFile.ReadAll
objFile.Close
intLength = Len(strFile)
strFile = Left(strFile, intLength - 2)
Set objFile = objFSO.OpenTextFile("C:\abc.10", ForWriting)
objFile.Write strFile
objFile.Close
'********************************************************************
'deletes line beginning with 345
strFileName = "C:\scripts\test.txt"
strCheckForString = UCase("345")
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objTS = objFS.OpenTextFile(strFileName, FOR_READING)
strContents = objTS.ReadAll
objTS.Close
arrLines = Split(strContents, vbNewLine)
Set objTS = objFS.OpenTextFile(strFileName, FOR_WRITING)
For Each strLine In arrLines
If Not(Left(UCase(LTrim(strLine)),Len(strCheckForString)) =
strCheckForString) Then
objTS.WriteLine strLine
End If
Next Tag: please i want script to make ip assigned by dhcp Tag: 211402
hello - and thanks to all that helped me!
This group, whether by me simply searching for answers for posting
looking for them, has been super super helpful in creating my campus-
wide inventory script. I now have a SQL database populating with
information as folks log in, getting everything from serial number to
model name to hard drive, etc. I want to post my full inventory
script here, so anyone who has been wanting to do something like this
can simply copy/paste and modify as needed! So thanks again, and
copy, modify and enjoy :-)
On Error Resume Next
Const HKEY_LOCAL_MACHINE = &H80000002
DIM strComputerName
strComputer = "."
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &
_
strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources"
strValueName = "Inventory"
strValue = "SQL Server"
objReg.SetStringValue
HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
strKeyPath = "SOFTWARE\ODBC\ODBC.INI\Inventory"
objReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath
strKeyPath = "SOFTWARE\ODBC\ODBC.INI\Inventory"
strValueName = "Database"
strValue = "Inventory"
objReg.SetStringValue
HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
strValueName = "Driver"
strValue = "C:\WINDOWS\System32\SQLSRV32.dll"
objReg.SetStringValue
HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
strValueName = "Server"
strValue = "CERBERUS"
objReg.SetStringValue
HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
strValueName = "Trusted_Connection"
strValue = "Yes"
objReg.SetStringValue
HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adUseClient = 3
Set objConnection = CreateObject("ADODB.Connection")
Set objRecordset = CreateObject("ADODB.Recordset")
objConnection.Open "DSN=Inventory;"
objRecordset.CursorLocation = adUseClient
objRecordset.Open "SELECT * FROM Hardware" , objConnection, _
adOpenStatic, adLockOptimistic
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer& "\root
\cimv2")
Set colSettings = objWMIService.ExecQuery _
("SELECT * FROM Win32_ComputerSystem")
For Each objComputer in colsettings
strComputerName = objComputer.Name
Next
strSearchCriteria = "CompName ='" & strComputerName & "'"
objRecordset.Find strSearchCriteria
IF objRecordset.EOF = True Then
Set colSettings = objWMIService.ExecQuery _
("SELECT * FROM Win32_ComputerSystem")
For Each objComputer in colsettings
objRecordset.AddNew
objRecordset("CompName") = objComputer.Name
objRecordset.Update
Next
call subwritedata
Else
call subwritedata
End If
objRecordset.Close
objConnection.Close
WScript.Quit
'
' Beneath here be Subroutines
'
Sub subwritedata
Set colSettings = objWMIService.ExecQuery _
("SELECT * FROM Win32_ComputerSystem")
For Each objComputer in colsettings
objRecordSet("Memory") = round(objComputer.TotalPhysicalMemory/1024)
& " MB"
objRecordset.Update
Next
Set colSettings = objWMIService.ExecQuery _
("SELECT * FROM Win32_OperatingSystem")
For Each objOperatingSystem in colSettings
objRecordset("OS") = objOperatingSystem.Caption
objRecordset.Update
Next
Set colSettings = objWMIService.ExecQuery _
("SELECT * FROM Win32_Processor")
For Each objCPU in colSettings
objRecordset("Processor") = trim(objCPU.Name)
objRecordset.Update
Next
Set colSettings = objWMIService.ExecQuery _
("SELECT * FROM Win32_DiskDrive")
For Each objDisk in colSettings
objRecordset("HardDrive") = round(objDisk.Size/1000000000) & " GB"
objRecordset.Update
Next
Set colSettings = objWMIService.ExecQuery _
("SELECT * FROM Win32_ComputerSystem")
For Each objComputer in colsettings
objRecordSet("CompType") = objComputer.Model
objRecordset.Update
Next
Set colsettings = objWMIService.ExecQuery _
("SELECT * FROM Win32_BIOS")
For Each ObjBIOS in colsettings
objRecordset("Serial") = objBios.SerialNumber
objRecordset.Update
Next
Set colChassis = objWMIService.ExecQuery _
("Select * from Win32_SystemEnclosure")
For Each objChassis in colChassis
For Each strChassisType in objChassis.ChassisTypes
If strChassisType = 8 THEN
objRecordset("Chassis") = "Laptop"
ElseIf strChassisType = 9 THEN
objRecordset("Chassis") = "Laptop"
ElseIf strChassisType = 10 THEN
objRecordset("Chassis") = "Laptop"
ElseIf strChassisType = 12 THEN
objRecordset("Chassis") = "Laptop"
ElseIf strChassisType = 13 THEN
objRecordset("Chassis") = "Laptop"
ELSE
objRecordset("Chassis") = "Desktop"
End If
objRecordset.Update
Next
Next
Set colsettings = objWMIService.ExecQuery _
("SELECT * FROM Win32_BIOS")
For Each ObjBIOS in colsettings
objRecordset("ReleaseDate") = left(objBios.ReleaseDate,8)
objRecordset.Update
Next
Set colSettings = objWMIService.ExecQuery _
("SELECT * FROM Win32_ComputerSystem")
For Each objItem in colSettings
arrName = Split(objItem.UserName, "\")
objRecordset("Login") = arrName(1)
objRecordset.Update
Next
Set colItems = objWMIService.ExecQuery _
("Select * From Win32_NetworkAdapterConfiguration " & _
"Where IPEnabled = True")
For Each objItem in colItems
For Each objAddress in objItem.IPAddress
objRecordset("IP") = objAddress
objRecordset.Update
Next
Next
Set colItems = objWMIService.ExecQuery _
("Select * From Win32_NetworkAdapterConfiguration " & _
"Where IPEnabled = True")
For Each objAdapter in colItems
objrecordset("Mac") = objAdapter.MacAddress
objRecordset.Update
Next
objRecordset("Date") = Date()
objRecordset.Update
objRecordset("Time") = Time()
objRecordset.Update
End Sub Tag: please i want script to make ip assigned by dhcp Tag: 211400
Defrag Hard Disks
I am using the following script to automate the defrag of all volumes
on a server, is it possible to make the script wait and not exit until
the defrag is complete. This is destined to become the last part of a
"first boot" script used in server deployment so I would like to have
the script initiate a reboot once this is finished.
'execute against the local computer
strComputer = "."
'connect to the WMI service on strComputer
Set objWMIService = GetObject("winmgmts:" &
"{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
'Defrag All Hard disks
Set colVolumes = objWMIService.ExecQuery ("Select * from
Win32_Volume")
For Each objVolume in colVolumes
errResult = objVolume.Defrag()
Next
Thanks,
Josh Tag: please i want script to make ip assigned by dhcp Tag: 211399
Install a printer in black and white
Hi.
How can I install a printer in black and white by default by means of a
script?
Regards Tag: please i want script to make ip assigned by dhcp Tag: 211392
Selecting current week in drop down
Hi All,
In a drop down box i am populating all the weeks from 1 to 52, but
whenever the page loads, i want it show the current week number as
selected value.
Below is what is did:
<option selected value="<% DatePart("ww", Now()) %>"> <% wkCnt %> </
option>
But when my page loads, the drop down box shows the last week in the
list (52), instead of current week which is 43.
please let me know i am missing something.
appreciate any ideas on this.
Thank you!!
Navin Tag: please i want script to make ip assigned by dhcp Tag: 211391
Do not support HTML in textarea - on server-side
Hi,
I have a textarea and I would like to prevent users from inserting
HTML tags. Only plain text is supported.
Which server-side vbscript regular expression is best for this?
Thanks, Gabi Tag: please i want script to make ip assigned by dhcp Tag: 211390
Help Splitting a String
Can anyone help me please.
I am trying to split a users homedrive which I input using the
following code, the problem is I get an error when trying to split the
name. I basically want to get the servername and the home drive share
name as two seperate values so I can then use them seperatly.
The Home drive is displayed as "\\Servername\Sharename$"
username = "HJSimpson"
Const ADS_PROPERTY_DELETE = 4
Const ADS_PROPERTY_APPEND = 3
'Open connection to AD using LDAP
Set objCommand = CreateObject("ADODB.Command")
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
objCommand.ActiveConnection = objConnection
strBase = "<LDAP://dc=name,dc=name>"
strFilter = "(&(objectCategory=person)(sAMAccountName=" & username &
"))"
strAttributes = "sAMAccountName,AdsPath,distinguishedName"
strQuery = strBase & ";" & strFilter & ";" & strAttributes
objCommand.CommandText = strQuery
Set ADSIRecordSet = objCommand.Execute
strName = ADSIRecordSet.Fields("sAMAccountName").Value
errorNum = err.number
errorDesc = err.description
strAdsPath = ADSIRecordSet.Fields("AdsPath").Value
strDN = ADSIRecordSet.Fields("distinguishedName").Value
Set objUser = GetObject("LDAP://" & strDN)
strDisplayName = objUser.displayname
strDescription = objUser.description
err.number = "0"
Set usr = GetObject(strAdsPath)
homedir = usr.homedirectory
MsgBox homedir - This bit is OK
a=Split(homedir,"\",-1,1) - This bit is not OK.
If InStr(a, "\\") Then
newservername = len(a,3)
Else
'Do Nothing
End If
MsgBox newservername
WScript.Quit:
Please help. Thanks Tag: please i want script to make ip assigned by dhcp Tag: 211389
Error 800A0046 with Shell.Run, but .Exec works
Hello,
I use VBScript to execute an application on a network drive.
The script looks like this:
<-----------------
const cFolder = "S:\Apps\MyProg"
const cPrg = "prg.exe"
set oShell = CreateObject("WScript.Shell")
with oShell
.CurrentDirectory = cFolder
call .Run(cFolder & "\" & cPrg)
end with
<-----------------
With some users, this script fails executing "call .Run()" with error
800A0046 - Permission denied.
If I replace "call .Run()" with "call .Exec()" using exact the same parameter,
the same user can run the script without any problems.
What is the difference between .Exec and .Run?
Why does .Run fail sometimes?
Thank you very much,
Josef Tag: please i want script to make ip assigned by dhcp Tag: 211385
Edit a txt file
Dear All,
Pls help, I have a text file which I need to edit. The script should
search for a particular text using readline and then append a certain
text to that line.
The text file looks like
blah blah
blah blha
blah
happyb'day=gaurav
blah blah
It should look like this after modification
blah blah
blah blha
blah
happyb'day=gaurav,thanks
blah blah
P.S - The line # where "Happy'bday=gaurav" is not fixed.
Pls help, I need to get going on this and even a little insight will
be very helpful.
Thanks in advance
Gaurav Tag: please i want script to make ip assigned by dhcp Tag: 211380
MS Office 2003 Author change
Is there a way to change the author of documents created by word, excel, etc,
so that it reflects the user that is logged in and not the organization? I
would like to create a script so this is done automatically but it seems that
UserInfo in the registry is encrypted. Is there a way around this or an
additional key that can be entered? This is to prevent students from copying
other student's work in an Office class. Tag: please i want script to make ip assigned by dhcp Tag: 211379
Win2k3 > SP2 - Anything that can/will affect LDAP queries?
Hi,
Is there anything in SP2 for Windows Server 2003 that could affect
LDAP queries that we currently have in place that anyone knows of?
Thanks in advance. Tag: please i want script to make ip assigned by dhcp Tag: 211377
Reading the + in Querystring
Hi All,
I have a querystring that contains the + sign as a separator, I need to read
these values individually in a select statement, for example.
&text=Single+205
where single is the type of room somebody wants and 205 is the user ID in
the Customer table.
Please help.
Regards
Simon Tag: please i want script to make ip assigned by dhcp Tag: 211373
netobj.GetSystemInfo() in ASP/VBScript
I am looking to find the IP address, MAC address, Windows Version etc. and
ideally I want to know if some specific components are installed such as our
plugin to WM Player. Is this possible in ASP? I know it is in
.Net and in Javascript there is this function netobj.GetSystemInfo()
How would I do this in plain ASP and/or ASP with vbscript?
Thanx,
--
Anil Gupte
www.keeninc.net
www.icinema.com Tag: please i want script to make ip assigned by dhcp Tag: 211372
Change value of "Logon script" for all users to nothing
Hi,
I'm relatively new to VBScript. I have successfully written a couple
of logon scripts for my company, with half-decent validation & program
flow. I now need to deploy this, and remove the old batch logon script
from users' account objects in AD.
Having read some posts, I've seen suggestions ranging from:
selecting multiple users in AD & selecting "Properties", then making
the change (this doesn't work on either WinXP SP2 or Win 2000)
to
using LDIFDE to export the desired information, make the change, then
re-import this data to update the schema. However, LDIFDE looks
extremely complex & bug-prone - see http://support.microsoft.com/kb/555634.
For example, this document suggests that blank values can't be used to
set attributes, which ruins my plans. It also contains lots of caveats
- by default, accounts are disabled, passwords set to NULL, "user must
change password at next logon", etc, making for a very complex series
of switches & arguements for performing any import.
Is there no way of simply using VBScript to build a collection of user
objects and loop through them, setting the desired value? Any
suggestions would be greatly appreciated.
Many thanks,
Stevie
"Normal is as normal does..." Tag: please i want script to make ip assigned by dhcp Tag: 211371
passing a WMI collection value as a property
Hi, Please Help !
I am trying to write a script that loads some counter details from a SQL
table, executes a WMI query and then writes the results back to a SQL table.
The script will loop through the counters that it loads. My problem is I run
my WMI query
set colsettings = objWMIService.ExecQuery("SELECT PercentProcessorTime FROM
Win32_PerFormattedData_PerfOS_Processor where name = '_Total'). The actual
query contains references to the recordsets returned from SQL server
containing the counter details. For example "PercentProcessorTime" above is
replaced with objCounterRecordSet.Fields.Item("WMIProperty") and also the WMI
Class is replaced with a reference to the recordeset.
I now have one element in the reurned collection which I have to loop
through. For testing I am only trying to retrieve the value.
For each objItem in colsettings
wscript.echo objitem.PercentProcessorTime
Next.
The problem is I have several counters in my SQL table and am looping
through them so I need to replace "PercentProcessorTime" above with which
ever WMIClass parameter I happen to be working with and I cannot get this to
work. I guess what I am trying to do is use the value in a recordset as a
property for an object.
Anybody got any ideas or am i trying to do something that cannot be achieved. Tag: please i want script to make ip assigned by dhcp Tag: 211369
Problems creating an exchange mailbox and setting permissions
Hi All,
I hope someone can help.
I am having problems accessing the Security Descriptor when creating a
New User. It errors telling me an object is required with error 424.
I have this working on other infrastructures the same as it is in this
code and therefore can not understand why it is not working.
The bit of the code which is failing is the Function to Create The
Exchange Mailbox the rest is working fine.
Here is the code
---------------------------------------------------------------------------------------------------------------------------------------------------------------------
<HTML>
<HEAD>
<TITLE>New User Creation Utility</TITLE>
<HTA:APPLICATION ID="oCreateAccount"
APPLICATIONNAME="AccountCreationScript"
BORDER="thin"
CAPTION="yes"
ICON="SETUP.ICO"
SHOWINTASKBAR="yes"
SINGLEINSTANCE="yes"
SCROLL="NO"
SYSMENU="yes"
WINDOWSTATE="normal"
MAXIMIZEBUTTON="no"
MINIMIZEBUTTON="yes">
</HEAD>
<style>
BODY
{
background-color: "#E4EAF6";
font-family: Helvetica;
font-size: 14pt;
color: "#000080";
margin-top: 5%;
margin-left: 5%;
margin-right: 5%;
margin-bottom: 5%;
}
</STYLE>
<SCRIPT LANGUAGE="VBScript">
<!--
'=================================================================================================================================================
'***When the Script window loads set the size and location of the
window.***
'=================================================================================================================================================
sub Window_Onload
self.focus()
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer &
"\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * From
Win32_DesktopMonitor")
For Each objItem in colItems
intHorizontal = objItem.ScreenWidth
intVertical = objItem.ScreenHeight
Next
intLeft = (intHorizontal - 800) / 2
intTop = (intVertical - 600) / 2
window.resizeTo 800,600
'window.moveTo intLeft, intTop
btnRunScript.disabled = false
btnReset.disabled = false
btnClose.disabled = false
end sub
'=================================================================================================================================================
'***Clear any stored Values from the entry fields.***
'=================================================================================================================================================
sub btnReset_Click
txtFirstname.value = ""
txtMiddlename.value = ""
txtLastname.value = ""
txtRefnumber.value = ""
txtRequestor.value = ""
ListAccType.value = "AccTypeStart"
btnRunScript.disabled = false
btnReset.disabled = false
btnClose.disabled = false
end sub
'=================================================================================================================================================
'***Collect information for new user entered by the Administrator.***
'=================================================================================================================================================
sub btnRunScript_click
firstname=txtFirstname.value
middlename=txtMiddlename.value
lastname=txtLastname.value
referencenumber=txtRefnumber.value
Requestor=txtRequestor.value
AccountType=ListAccType.value
'Formatting the text to make sure that the details are correct
firstname=UCASE(left(firstname,1))+LCASE(mid(firstname,2))
middlename=UCASE(left(middlename,1))+LCASE(mid(middlename,2))
If mid(lastname,2) = "'" Then
lastname=UCASE(left(lastname,3))+LCASE(mid(lastname,4))
Else
lastname=UCASE(left(lastname,1))+LCASE(mid(lastname,2))
End If
btnRunScript.disabled = true
btnReset.disabled = true
btnClose.disabled = true
if firstname="" then
msgbox "Please enter the users First Name"
btnRunScript.disabled = false
btnReset.disabled = false
btnClose.disabled = false
exit sub
elseif lastname = "" then
msgbox "Please enter the users Surname"
btnRunScript.disabled = false
btnReset.disabled = false
btnClose.disabled = false
exit sub
elseif referencenumber = "" then
msgbox "Please enter the Reference Number"
btnRunScript.disabled = false
btnReset.disabled = false
btnClose.disabled = false
exit sub
elseif Requestor = "" then
msgbox "Please enter the Requestor's Name"
btnRunScript.disabled = false
btnReset.disabled = false
btnClose.disabled = false
exit sub
elseif AccountType = "AccTypeStart" then
msgbox "Please select the Account Type"
btnRunScript.disabled = false
btnReset.disabled = false
btnClose.disabled = false
exit sub
else
'do nothing
end if
call
createAccount(firstname,middlename,lastname,referencenumber,Requestor,AccountType)
end sub
'=================================================================================================================================================
'***Collect information for new user entered by the Administrator,
then create the account.***
'=================================================================================================================================================
sub
createAccount(firstname,middlename,lastname,referencenumber,Requestor,AccountType)
'On error resume next
intAccValue = 544
inputdomain="Domain"
inputou="OU"
Set wshshell = CreateObject("wscript.shell")
username = wshshell.expandenvironmentstrings("%username%")
strDomain="Domain.Com"
CurrDateTime=now
firstinitial = UCASE(left(firstname,1))
strFile = "filepath"
strExServer = "Servername"
strProfPath = "\\Servername\User$\P"
strHomeDir = "\\Servername\User$\H"
strTempPath = strHomeDir & firstinitial & "\_Template\"
msgbox "Please verify the following details of the account to create"
& VBCRLF & "Firstname: " & firstname & VBCR & "Middlename: " &
middlename & VBCR & "Lastname: " & lastname & VBCR & "Reference
Number: " & referencenumber
MsgboxResult=msgbox("Is this information correct?",
259,"Confirmation")
if MsgboxResult = 7 then
txtFirstname.value = ""
txtMiddlename.value = ""
txtLastname.value = ""
txtRefnumber.value = ""
ListAccType.value = "AccTypeStart"
btnRunScript.disabled = false
btnReset.disabled = false
btnClose.disabled = false
exit sub
elseif MsgboxResult = 2 then
window_close
exit sub
else
'do nothing
end if
'Connect to the usersdatabase to get sitedetails and record the
transaction
set conn=createobject("adodb.connection")
conn.connectiontimeout = 30000
conn.commandtimeout=30000
set myset=createobject("adodb.recordset")
conn.open "Driver={Microsoft Access Driver
(*.mdb)};Dbq=UserAdmin.mdb;"
sql="select * from Exchange where exchangeserver='" & strExServer &
"'"
'Msgbox sql
set myset=conn.execute(sql)
exchangeserver=myset("exchangeServer")
storagegroup1=myset("storagegroup1")
storagegroup2=myset("storagegroup2")
informationstore1=myset("informationstore1")
informationstore2=myset("informationstore2")
informationstore3=myset("informationstore3")
informationstore4=myset("informationstore4")
informationstore5=myset("informationstore5")
informationstore6=myset("informationstore6")
informationstore7=myset("informationstore7")
informationstore8=myset("informationstore8")
informationstore9=myset("informationstore9")
'Create a temporary account name
testusername=UCASE(left(firstname,1) & left(middlename,1) &
left(lastname,1)) & LCASE(mid(lastname,2))
'Check if there is an account with this name already
nameok=testaccount(testusername)
if nameok=0 then
' The account name is already in use, need to alter the name used
msgbox "This Account name is already in use, there is a duplicate
entry." & VBCRLF & "Please verify the details entered, you will need
to start again once the details have been verified."
txtFirstname.value = ""
txtMiddlename.value = ""
txtLastname.value = ""
txtRefnumber.value = ""
txtRequestor.value = ""
ListAccType.value = "AccTypeStart"
btnRunScript.disabled = false
btnReset.disabled = false
btnClose.disabled = false
exit sub
else
' This name is free so use it
end if
'Now we create the base user account so that we can assign properties
to it
objectname="LDAP://ou=users,ou=" & inputou & ",dc=" & inputdomain &
",dc=COM"
'Now we create the new user account so that we can set its properties
Set ou = GetObject(objectname)
'Have to remember to escape the , by preceeding it with a \, so
smith, john becomes smith\, john this still shows as smith, john in
the gui though.
If middlename = "" Then
fullname="cn=" & firstname & " " & lastname
Else
fullname="cn=" & firstname & " " & middlename & " " & lastname
End If
Set usr = ou.Create("user", fullname)
usr.Put "samAccountName", testusername
usr.SetInfo
usr.lastname = lastname
usr.givenname = firstname
if len(middlename)>0 then
usr.initials=left(middlename,1)
end if
usr.setinfo
usr.userPrincipalName=testusername & "@" & inputdomain & ".co.uk"
If middlename = "" Then
usr.displayname=firstname & " " & lastname
Else
usr.displayname=firstname & " " & middlename & " " & lastname
End If
usr.description=AccountType
usr.setinfo
usr.profilepath=strProfPath & firstinitial & "\" & testusername
usr.homedrive="P:"
usr.homedirectory=strHomeDir & firstinitial & "\" & testusername
usr.SetInfo
usr.info="Created via script by " & username & " on " & now & " Ref:
" & referencenumber & VBTAB & "Requested by: " & Requestor
usr.SetInfo
usr.Put "userAccountControl", intAccValue
usr.setinfo
homedir = usr.homedirectory
profiledir = usr.profilepath
'Now we need to create the homedrive and profilepath for the account
set fso=createobject("scripting.filesystemobject")
if fso.folderexists(usr.homedirectory) then
msgbox "There is already a home directory for this user. Please
verify it is correct and with the correct permissions"
else
set f=fso.createfolder(usr.homedirectory)
end if
if fso.folderexists(usr.profilepath) then
msgbox "There is already a profile directory for this user. Please
verify it is correct and with the correct permissions"
else
set f=fso.createfolder(usr.profilepath)
end if
'And set the permissions
cmdline="cmd /c setacl.exe -on " & homedir & " -ot file -actn ace -
ace " & "n:" & inputdomain & "\" & testusername &
";p:full;s:n;i:sc,so;m:grant;w:dacl"
cmdline1="cmd /c setacl.exe -on " & profiledir & " -ot file -actn
ace -ace " & "n:" & inputdomain & "\" & testusername &
";p:full;s:n;i:sc,so;m:grant;w:dacl"
Set WshShell = CreateObject("WScript.Shell")
poi=wshshell.run(cmdline)
poi1=wshshell.run(cmdline1)
'Copy the _Template folder and it's contents to the Users Home Folder
fso.CopyFolder strTempPath & "*.*", homedir, True
'Now we enable the account
res=addgroups(inputdomain,testusername,AccountType)
strDate = now
'get numeric value for day of the week
myDayName = WeekDay(strDate)
'convert numeric value to day name
myDayName = WeekDayName(myDayName)
DayofWeek = LCASE(myDayName)
CurrentDay = Dayofweek
usr.Accountdisabled=0
strPassword=CurrentDay
usr.setpassword strPassword
usr.put "pwdLastSet", 0
usr.setinfo
'Now we create the mailbox
'***First convert the first character of the firstname into an ascii
code***
'***In order to sort the user into the correct Information
Store ***
FirstChar= "H"
FirstCharAsci=Asc(FirstChar)
AsciA=Asc("A")
AsciB=Asc("B")
AsciC=Asc("C")
AsciD=Asc("D")
AsciE=Asc("E")
AsciF=Asc("F")
AsciG=Asc("G")
AsciH=Asc("H")
AsciI=Asc("I")
AsciJ=Asc("J")
AsciK=Asc("K")
AsciL=Asc("L")
AsciM=Asc("M")
AsciN=Asc("N")
AsciO=Asc("o")
AsciP=Asc("P")
AsciQ=Asc("Q")
AsciR=Asc("R")
AsciS=Asc("S")
AsciT=Asc("T")
AsciU=Asc("U")
AsciV=Asc("V")
AsciW=Asc("W")
AsciX=Asc("X")
AsciY=Asc("Y")
AsciZ=Asc("Z")
Call RUS
strAlias=UCASE(Left(firstname,1) & left(middlename,1) & left(lastname,
1)) & LCASE(Left(lastname,2))
smtpok = testsmtp(firstname,middlename,lastname,inputdomain,strAlias)
If smtpok = 0 Then
strAlias=UCASE(Left(firstname,1) & left(middlename,1) &
left(lastname,1)) & LCASE(lastname,2) & "X"
smtpok =
testsmtp(firstname,middlename,lastname,inputdomain,strAlias)
If smtpok = 0 Then
strAlias=UCASE(Left(firstname,1) & left(middlename,1) &
left(lastname,1)) & LCASE(lastname,2) & "XX"
smtpok =
testsmtp(firstname,middlename,lastname,inputdomain,strAlias)
If smtpok = 0 Then
strAlias=UCASE(Left(firstname,1) & left(middlename,1) &
left(lastname,1)) & LCASE(lastname,2) & "XXX"
smtpok =
testsmtp(firstname,middlename,lastname,inputdomain,strAlias)
If smtpok = 0 Then
strAlias=UCASE(Left(firstname,1) & left(middlename,1) &
left(lastname,1)) & LCASE(lastname,2) & "XXXX"
Else
'Do Nothing
End If
Else
'Do Nothing
End If
Else
'Do Nothing
End If
Else
'Do Nothing
End If
'Call ChangeSmtpAddress(strAlias,fullname,site,inputdomain,inputou)
If FirstCharAsci >= AsciA AND FirstCharAsci <= AsciB then
storagegroup=storagegroup1
informationstore=informationstore1
ElseIf FirstCharAsci >= AsciC AND FirstCharAsci <= AsciD then
storagegroup=storagegroup1
informationstore=informationstore2
ElseIf FirstCharAsci >= AsciE AND FirstCharAsci <= AsciH then
storagegroup=storagegroup1
informationstore=informationstore3
ElseIf FirstCharAsci >= AsciI AND FirstCharAsci <= AsciK then
storagegroup=storagegroup1
informationstore=informationstore4
ElseIf FirstCharAsci >= AsciL AND FirstCharAsci <= AsciM then
storagegroup=storagegroup2
informationstore=informationstore5
ElseIf FirstCharAsci >= AsciN AND FirstCharAsci <= AsciP then
storagegroup=storagegroup2
informationstore=informationstore6
ElseIf FirstCharAsci >= AsciQ AND FirstCharAsci <= AsciS then
storagegroup=storagegroup2
informationstore=informationstore7
ElseIf FirstCharAsci >= AsciT AND FirstCharAsci <= AsciZ then
storagegroup=storagegroup2
informationstore=informationstore9
Else
storagegroup=storagegroup2
informationstore=informationstore8
End if
'***Build the LDAP url in order to create the mailbox'***
strLDAPUrl="LDAP://CN=" & informationstore & ",CN=" & storagegroup &
",CN=InformationStore,CN=" & _
exchangeserver & ",CN=Servers,CN=Admin Group,CN=Administrative
Groups,CN=" & inputdomain & _
",CN=Microsoft
Exchange,CN=Services,CN=Configuration,dc=Domain,dc=COM"
bContinue=CreateNewUserMailbox(usr, strLDAPUrl, inputdomain,
testusername)
If bContinue=True then
bContinue2=CreateMailboxFolders(exchangeserver, strAlias,
strPassword)
Else
msgbox "Failed to create Mailbox for this user, please create it
manually"
End If
'write out DB information
set dbupdaters=createobject("adodb.recordset")
dbupdaters.open "Users",conn,2,2,2
dbupdaters.addnew
dbupdaters("firstname")=firstname
dbupdaters("middlename")=middlename
dbupdaters("lastname")=lastname
dbupdaters("accounttype")=AccountType
dbupdaters("homeserver")=homedir
dbupdaters("storagegroup")=storagegroup
dbupdaters("informationstore")=informationstore
dbupdaters("UserID")=testusername
dbupdaters("creator")=username
dbupdaters("Domain")=inputdomain
dbupdaters("Creation Time")=now
dbupdaters.update
txtFirstname.value = ""
txtMiddlename.value = ""
txtLastname.value = ""
txtRefnumber.value = ""
txtRequestor.value = ""
ListAccType.value = "AccTypeStart"
msgbox "Account has been created successfully."
MsgBox "Account Username is: " & testusername & VBCRLF & "Account
Password is: " & strPassword & VBCRLF & "Home Server: " & _
homedir & VBCRLF & "Profile Directory: " & profiledir
set dbupdaters=nothing
set conn=nothing
Set strPassword=nothing
btnRunScript.disabled = false
btnReset.disabled = false
btnClose.disabled = false
end sub
'=================================================================================================================================================
'***Sub and Function to Initiate the Recipient Update Service and
force replication.***
'=================================================================================================================================================
Sub RUS
'This sample finds the first Exchange Organization and
'starts the server RUS. If you have multiple Exchange
'organizations you will want to modify the code.
'This sample does a serverless bind finding the first DC
'to respond. You may want to modify the code to specify
'a specific server in the Bind statement.
Dim RootDse
Set RootDse = GetObject("LDAP://RootDSE")
strdn = RootDse.Get("defaultNamingContext")
Set oConfig = GetObject("LDAP://" & strdn)
strDomainName = oConfig.Get("name")
strConfigurationNC = RootDse.Get("ConfigurationNamingContext")
strExchangeOrg = FindAnyOrg(strConfigurationNC)
strRUS = "CN=Recipient Update Service (" & strDomainName &
"),CN=Recipient Update Services," & "CN=Address Lists Container,CN=" &
strExchangeOrg & ",CN=Microsoft Exchange,CN=Services," &
"CN=Configuration," & strdn
Set objRUS = GetObject("LDAP://" & strRUS)
objRUS.Put "msExchReplicateNow", True
objRUS.SetInfo
End Sub
Function FindAnyOrg(strConfigurationNC)
Set oConnection = CreateObject("ADODB.Connection")
Set oCommand = CreateObject("ADODB.Command")
Set oRecordSet = CreateObject("ADODB.RecordSet")
Dim strQuery
'Open the Connection
oConnection.Provider = "ADsDSOObject"
oConnection.Open "ADs Provider"
'Build the query to find the private Exchange Organization
strQuery = "<LDAP://" & strConfigurationNC & ">;
(objectCategory=msExchOrganizationContainer);name,adspath;subtree"
oCommand.ActiveConnection = oConnection
oCommand.CommandText = strQuery
Set oRecordSet = oCommand.Execute
'If we have an Organization then return the first one
If Not oRecordSet.EOF Then
oRecordSet.MoveFirst
FindAnyOrg = CStr(oRecordSet.Fields("name").Value)
Else
FindAnyOrg = ""
End If
'Clean Up
oRecordSet.Close
oConnection.Close
Set oRecordSet = Nothing
Set oCommand = Nothing
Set oConnection = Nothing
End Function
'=================================================================================================================================================
'***Sub to change the smtp address.***
'=================================================================================================================================================
Sub ChangeSmtpAddress(strAlias,fullname,site,inputdomain,inputou)
Set objUser = GetObject("LDAP://" & fullname & ",OU=users,ou=" &
inputou & ",dc=" & inputdomain & ",dc=Local")
vProxyAddresses = objUser.proxyaddresses
sAddress = "SMTP:" & strAlias & "@" & inputdomain & ".co.uk"
nProxyAddresses = uBound(vProxyAddresses)
Do While (nProxyAddresses <> 2) or (IsNull(nProxyAddresses))
nProxyAddresses = uBound(vProxyAddresses)
vProxyAddresses = objUser.proxyaddresses
Loop
i = 0
Do While i <= nProxyAddresses
email = vProxyAddresses(i)
If Left (email,5) = "SMTP:" Then
ReDim Preserve vProxyAddresses(nProxyAddresses)
vProxyAddresses(nProxyAddresses) = sAddress
objUser.proxyaddresses = vProxyAddresses
objUser.SetInfo
End If
i = i + 1
Loop
objUser.Put "mail", strAlias & "@" & inputdomain & ".co.uk"
objUser.SetInfo
End Sub
'=================================================================================================================================================
'***Check SMTP Alias across the domain.***
'=================================================================================================================================================
function testsmtp(firstname,middlename,lastname,inputdomain,strAlias)
on error resume next
Set objCommand = CreateObject("ADODB.Command")
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
objCommand.ActiveConnection = objConnection
strBase = "<LDAP://ou=" & inputou & ",dc=" & inputdomain & ",dc=COM>"
strFilter = "(&(objectCategory=person)(proxyaddresses=SMTP:" &
strAlias & "@" & inputdomain & ".co.uk"))"
strAttributes = "proxyaddresses,AdsPath"
strQuery = strBase & ";" & strFilter & ";" & strAttributes
objCommand.CommandText = strQuery
Set ADSIRecordSet = objCommand.Execute
strProxy = ADSIRecordSet.Fields("proxyaddresses").Value
errorNum = err.number
errorDesc = err.description
if err.number = 0 then
testsmtp = 0
else
testsmtp = 1
end if
end function
'=================================================================================================================================================
'***Check User name across the domain.***
'=================================================================================================================================================
function testaccount(testusername)
on error resume next
'Check via the WinNT provider as we want the accounts to be unique
across the domain not the OU
set checkuser=getobject("WinNT://" & inputdomain & "/" & testusername
& ",User")
testaccount=err.number
end function
'=================================================================================================================================================
'***Add the user to the groups.***
'=================================================================================================================================================
function addgroups(inputdomain,testusername,AccountType)
On Error Resume Next
strGroup1 = "Group1"
strGroup2 = "Group2"
strGroup3 = "Group3"
strPermGroup = "Group4"
Set User = GetObject("WinNT://" & inputdomain & "/" & testusername &
",user")
Set Group = GetObject("WinNT://" & inputdomain & "/" & strGroup1 &
",group")
If Group.IsMember(User.AdsPath) = TRUE Then
'Do Nothing
Else
strMember = Group.Add(User.AdsPath)
End If
Set Group = GetObject("WinNT://" & inputdomain & "/" & strGroup2 &
",group")
If Group.IsMember(User.AdsPath) = TRUE Then
'Do Nothing
Else
strMember = Group.Add(User.AdsPath)
End If
Set Group = GetObject("WinNT://" & inputdomain & "/" & strGroup3 &
",group")
If Group.IsMember(User.AdsPath) = TRUE Then
'Do Nothing
Else
strMember = Group.Add(User.AdsPath)
End If
If AccountType = "Standard User Account" Then
Set Group = GetObject("WinNT://" & inputdomain & "/" & strPermGroup
& ",group")
If Group.IsMember(User.AdsPath) = TRUE Then
'Do Nothing
Else
strMember = Group.Add(User.AdsPath)
End If
Else
'Do Nothing
End If
end function
'=================================================================================================================================================
'***Create the new users exchange mailbox.***
'=================================================================================================================================================
Function CreateNewUserMailbox(usr, strLDAPUrl, inputdomain,
testusername)
usr.createmailbox strLDAPUrl
usr.setinfo
'Set the Delivery Size Limit for the User to 6Mb
usr.put "submissionContLength", "6144"
usr.SetInfo
Call RUS
sTrusteeName=inputdomain & "\" & testusername
'Get the copy Mailbox Security Descriptor (SD) stored on the
msExchMailboxSecurityDescriptor attribute
usr.GetInfoEx Array("msExchMailboxSecurityDescriptor"), 0
Set oSecurityDescriptor = usr.Get("msExchMailboxSecurityDescriptor")
'Extract the Discretionary Access Control List (ACL) using the
IADsSecurityDescriptor interface
Set dacl = oSecurityDescriptor.DiscretionaryAcl
MsgBox err.number & VBTAB & err.description
AddAce dacl, sTrusteeName, 131073, 0, 2, 0, 0, 0
'Add the modified DACL back onto the Security Descriptor
oSecurityDescriptor.DiscretionaryAcl = dacl
'Save New SD onto the user
usr.Put "msExchMailboxSecurityDescriptor", oSecurityDescriptor
'Commit changes from the property cache to the information store
usr.SetInfo
'MsgBox "Done viewing and modifying the copy of the Mailbox Security
Descriptor"
CreateNewUserMailbox = True
End Function
'=================================================================================================================================================
'***Create the mailbox folders.***
'=================================================================================================================================================
Function CreateMailboxFolders(exchangeserver, strAlias, strPassword)
CreateMailboxFolders = False
'Build the URL to the user's mailbox.
strMailboxURL = "http://" & exchangeserver & "/Exchange/" & strAlias
& "/"
'Build the Domain\Username string.
strUserDomain = inputdomain + "\" + testusername
'Create the XMLHTTP object.
Set oXMLHTTP = CreateObject("microsoft.xmlhttp")
'Open the request object with the GET method. Specify the source
URI,
'that it will run asynchronously, and the username/password of the
'new user.
oXMLHTTP.Open "GET", strMailboxURL, False, strUserDomain, strPassword
'Set the language in which the mailbox folders will be created.
oXMLHTTP.setRequestHeader "Accept-Language", "en-us"
oXMLHTTP.setRequestHeader "Connection", "Keep-Alive"
'Send the GET method request. If the mailbox folders
'have not yet been created, this method will have the side
'effect of forcing the Exchange server to create them in
'the language specified in the "Accept-Language" header.
oXMLHTTP.Send ("")
If (oXMLHTTP.Status >= 200) And (oXMLHTTP.Status < 300) Then
msgbox "Mailbox folders for " & strAlias & " successfully created."
CreateMailboxFolders = True
Else
'GET method did not successfully force creation of mailbox folders.
CreateMailboxFolders = False
End If
Set oXMLHTTP = Nothing
End Function
'=================================================================================================================================================
'***Set the permissions to the mailbox for the user.***
'=================================================================================================================================================
Function AddAce(dacl, TrusteeName, gAccessMask, gAceType, gAceFlags,
gFlags, gObjectType, gInheritedObjectType, inputdomain, testusername)
'Create a new ACE object
Set Ace1 = CreateObject("AccessControlEntry")
Ace1.AccessMask = gAccessMask
Ace1.AceType = gAceType
Ace1.AceFlags = gAceFlags
Ace1.Flags = gFlags
Ace1.Trustee = inputdomain & "\" & testusername
'Check to see if ObjectType needs to be set
If CStr(gObjectType) <> "0" Then
Ace1.ObjectType = gObjectType
End If
'Check to see if InheritedObjectType needs to be set
If CStr(gInheritedObjectType) <> "0" Then
Ace1.InheritedObjectType = gInheritedObjectType
End If
dacl.AddAce Ace1
'Destroy objects
Set Ace1 = Nothing
End Function
'=================================================================================================================================================
'***Close the Script Window.***
'=================================================================================================================================================
sub window_close
window.parent.close
end sub
'=================================================================================================================================================
'***End of the Script.***
'=================================================================================================================================================
-->
</SCRIPT>
<BODY>
<P ALIGN = center>
<img src="C4.jpg" alt="C4"></P>
<BR>
<P ALIGN = center><STRONG>Welcome to the Account Creation Script</
STRONG></P>
<table width="100%" border="0">
<tr><td><table width="100%" border="0">
<tr><th COLSPAN=2><hr>Users Details<hr></th></tr>
<tr><td>First Name:</td><td><input type="text" id="txtFirstname"
size="30"></td></tr>
<tr><td>Middlename:</td><td><input type="text" id="txtMiddlename"
size="30"></td></tr>
<tr><td>Lastname:</td><td><input type="text" id="txtLastname"
size="30"></td></tr>
<tr><td>Reference Number:</td><td><input type="text"
id="txtRefnumber" size="30"></td></tr>
<tr><td>Requestor:</td><td><input type="text" id="txtRequestor"
size="30"></td></tr>
<tr><td>Please select the Account Type for this user account:</
td><td>
<select name = "ListAccType">
<option value="AccTypeStart">Please Select</option>
<option value="Standard User Account">Standard</option>
<option value="Fixed Term Contract User Account">Fixed Term
Contract</option>
<option value="Non-Person User Account">Non-Person Account</
option>
</select>
</td></tr>
</table>
</td></tr>
<tr><td> </td><td> </td></tr>
<tr><td><P ALIGN = center><input type="button" id="btnRunScript"
value="Create Account" onclick="btnRunScript_click"><input
type="button" id="btnReset" value="Reset"
onclick="btnReset_Click"><input type="button" id="btnClose"
value="Close" onclick="window_close"></P></td></tr>
<tr><td></tr></td>
</table>
</BODY>
</HTML>
---------------------------------------------------------------------------------------------------------------------------------------------------------------------
Many Thanks In Advance Tag: please i want script to make ip assigned by dhcp Tag: 211368
kill process (I don't know the ID)
hello ng
how I can kill a process with a script.
I don't know the ID.
I know the name of the program: ttermpro.exe
thanks Tag: please i want script to make ip assigned by dhcp Tag: 211366
VBS for reading Message Table in dll file
Hi Scripting Guys!
I query the eventlog with the MS Log Parser. The output contains constants
like %%2048. These constants stands for entries in the responding message
table.
For example the msobjs.dll contains the message table for the security
eventlog.
Does anyone has an example how to get the messages from the table with a
vbscript?
Thx!
Marco Tag: please i want script to make ip assigned by dhcp Tag: 211365
Language Bar
Hello everybody,
If anybody can point me to a piece of documentation regarding scripting
language bar management (I need to add two languages (EN(Canada) and
FR(Canada) and remove EN(US) and change French keyboard layout).
Thanks in advance!
-Alex Tag: please i want script to make ip assigned by dhcp Tag: 211361
Script this - Configure ASP.NET to use specific version of .Net Fr
I was reading the IIS documentation and I noticed it's possible to configure
a website to use a specific version of the .Net framework.
For example I have websites that use .Net 2.0 and 1.1
However I want to upgrade the 1.1 websites to 2.0 but I would like to do it
via WMI or ADSI but I don't see any examples in the documentation, only a
reference to using Aspnet_regiis.exe
If anyone knows where I can find an example or if you would like to provide
an example feel free to do so. Thanks in advance
I am using Win2K3 servers Tag: please i want script to make ip assigned by dhcp Tag: 211358
Disable DLL has been successfully registered?
I am running a script to register a DLL and I was wondering if anyone knew a
way to disable the message that the DLL has been registered successfully...
does anyone know if there is a way to do that?
Thanks
Gavin... Tag: please i want script to make ip assigned by dhcp Tag: 211357
resize IFrames
How I can that? I use the following script:
function adjustFrame(){
window.frames.IFrame1.scrollBy(0,250);
currTop = window.frames.IFrame1.document.body.scrollHeight;
if (currTop > 0)
{
currHeight =
document.getElementById('dynFrame').getAttribute('height');
currHeight++;
document.getElementById('dynFrame').setAttribute('height',currHeight);
adjustFrame();
}
}
but the IE show error "Access Denied".... Tag: please i want script to make ip assigned by dhcp Tag: 211354
Remove CRLF while using writeline
Hi all,
>From other posts I've got the code below to delete lines beginning
with xyz (I've actually got about 5 different types so I loop it) and
I've added the line to remove carrigage return and line feeds. However
I can't remove the line feeds.
Does write line always produce a CR so I need another method?
Thanks,
Ed
strCheckForString5 = UCase("xyz")
'Remove line if begins with xyz
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objTS = objFS.OpenTextFile(strFileName,1)
strContents = objTS.ReadAll
objTS.Close
arrLines = Split(strContents, vbNewLine)
Set objTS = objFS.OpenTextFile(strFileName,2)
For Each strLine In arrLines
If Not(Left(UCase(LTrim(strLine)),Len(strCheckForString1)) =
strCheckForString1) Then
strline = Replace(strline, vbCrLf, " ")
objTS.WriteLine strLine
End If
Next Tag: please i want script to make ip assigned by dhcp Tag: 211353
LDAP Question
I am trying to create a script that will pull the logon user name then
perform a LDAP query to find users homedrive and other attribut information.
For example:
Set objNet = CreateObject("WScript.NetWork")
struser = ucase(objNet.username)
Set objUser = GetObject("LDAP://CN=" & struser & ",OU=Users,DC=test,DC=com")
strhdir = objUser.HomeDirectory
msgbox(strhdir)
But this does not work because the logon username is "JDDoe", but in order
to get this to work I have to use "Doe\, John" in the cn to get this to
work.
Is there any way to automaticall convert the logon username to the cn name.
Mike Tag: please i want script to make ip assigned by dhcp Tag: 211352
Remotely shutting down a Vista PC.
Is there a way to remotely shut down a Vista PC through a script?
I have two PCs on my network. I run Windows Small Business Server 2003 on
one PC and Vista Ultimate 64-bit on the other and the Vista PC is part of the
SBS domain. I have a UPS that's managed by SBS. When the UPS is about to
shutdown SBS when it's battery is low, the UPS management software has the
option to run a batch file on SBS. I would like to invoke a script from the
batch file to forcefully shutdown the Vista PC.
How do I do this?
Thanks. Tag: please i want script to make ip assigned by dhcp Tag: 211347
File Copy with FSO
I am doing a file copy using the FSO and have recently started seeing a
condition being met.
The copy job copies DB logfiles from one server to another but checks for
the LastModifiedDate and if it is the same as well as the size of the file
is the same, the script goes onto the next file.
If the sourcefile is newer than the target file, it copies the sourcefile to
the target location, overwriting the targetfile.
However, I am also catching if the targetfile is newer than the sourcefile
and this is where my problem is. I am finding a number of files where the
targetFile's LastModifiedDate is more recent by 1 second. The Month, Day and
Year are all the same, and not recent, but the time is 1 second newer.
If targetFile is being modified by my script, I would expect the modified
date to be more recent than it is -- the time of the copy.
This exact script is running on a number of log files copy processes but
this is the only one I am having this issue with.
Has anyone seen this issue happen when doing file copies?
Bart Perrier Tag: please i want script to make ip assigned by dhcp Tag: 211346
EML file parser script
does someone know how to make vbscript that will parse EML files stored in
one folder: just search for specific sender name in 'From:' field and store
this email separately.
Regards,
Santander Tag: please i want script to make ip assigned by dhcp Tag: 211343
Disabled Account - [WP]
I am looking for a vbscript.
When we run that script it should disable the AD user account and remove the
mailbox from it and if possible move the removed mailbox to a specific
Storage Group?
Any ideas.
Thank you. Tag: please i want script to make ip assigned by dhcp Tag: 211342
objComputer.UserName value is empty
When running this script the objComputer.UserName value is empty
Option Explicit
Dim objWMIService, objComputer, colComputer, strComputer
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colComputer = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")
For Each objComputer in colComputer
Wscript.Echo objComputer.UserName & " is logged on"
Next Tag: please i want script to make ip assigned by dhcp Tag: 211341
Error when creating user with mailbox in script
Hope someone can help here, and this is the right group :-)
I have a periodic problem when creating mail-enabled users using a
VBscript:
-2147467259 - There is no Connection Agreement configured to export this
recipient to the Exchange 5.5 server.
I'm creating using Microsoft best practicies, descriped in this article:
http://support.microsoft.com/kb/327079
If I try running the script several times it completes with sucess, but this
is not a valid solution.
The enviroment:
Windows Server 2003 AD
Exchange 2003 standard, SP2
Looking forward to hear from you, as this i a very critical issue for our
solution.
Best wishes
Bo Berggreen Tag: please i want script to make ip assigned by dhcp Tag: 211339
Why error 2147217904 expects parameter when parm is supplied?
I'm at a loss why my code supplies the input parm and yet upon
execution it complains about my first input parm called @AuditItem is
not supplied. Please throw some light. Thanks
Error: ado error 2147217904 expects parameter
My stored proc
PROCEDURE [dbo].[usp_Thresholds_GetStatus]
( @AuditItem varchar(50),
@Variable varchar(250),
@ServerValue varchar(250),
@FoundFlag varchar(10) output ,
@OutputStatusCode varchar(2) output,
@OutputPrecedingMessage varchar(250) output,
@OutputMessage varchar(250) output )
My vbs code:
Set objCon = CreateObject("ADODB.Connection")
Set objCom = CreateObject("ADODB.Command")
strConnection = "Provider=SQLOLEDB.1;Password=password@1;Persist
Security Info=false;User ID=xxxtReader;Initial Catalog=mydbt;Data
Source=mysqlserver"
On Error resume next
objCon.Open strConnection
If Err.Number <> 0 Then
Wscript.Echo " Attempt to open connection to database failed"
Wscript.Echo Err.Number & " " & Err.Description
Err.Clear
End If
'assigning the command object parameters
Set objCom.ActiveConnection = objCon
objCom.CommandText = "usp_Thresholds_GetStatus"
objCom.CommandType = adCmdStoredProc
'Create in/out parameters
Set objInputAuditItemParm = objCom.CreateParameter("@AuditItem",
adVarChar, adParamInput, 50, trim(InputAuditItem))
Set objInputVariableParm = objCom.CreateParameter("@variable",
adVarChar, adParamInput, 250, trim(InputVariable))
Set objInputServerValue = objCom.CreateParameter("@ServerValue",
adVarChar, adParamInput, 250, trim(InputServerValue))
Set objOutputFoundFlag = objCom.CreateParameter("@FoundFlag",
adVarChar, adParamOutput, 10)
Set objOutputStatusCode =
objCom.CreateParameter("@OutputStatusCode", advarChar, adParamOutput,
2)
Set objOutputPrecedingMessage =
objCom.CreateParameter("@OutputPrecedingMessage", adVarChar,
adParamOutput, 250)
Set objOutputMessage = objCom.CreateParameter("@OutputMessage",
adVarChar, adParamOutput, 250)
'Append the parameters to command object
objCom.Parameters.Append objInputAuditItemParm
objCom.Parameters.Append objInputVariableParm
objCom.Parameters.Append objInputServerValue
objCom.Parameters.Append objOutputFoundFlag
objCom.Parameters.Append objOutputStatusCode
objCom.Parameters.Append objOutputPrecedingMessage
objCom.Parameters.Append objOutputMessage
on error resume next
objCom.Execute
if err <> 0 then
Wscript.Echo "Attempt to execute stored proc
usp_Thresholds_GetStatus failed"
Wscript.Echo Err.Number & " " & Err.Description
Err.Clear
end if
'retrieve the Output parameters values
WScript.Echo "Output Found flag: " & objOutputFoundFlag.value
WScript.Echo "Output Me