 |
VB Script regedit, regexp, Class, mapdrive, add user - 4/15/2008 6:55:41 AM
|
|
 |
|
| |
drawls
Posts: 4
Score: 0
Joined: 2/11/2008
Status: offline
|
I think these scripts are correct but I'm not sure about the last 2. Let me know if they are incorrect. option explicit dim x set x = wscript.createobject("wscript.shell") x.regwrite "HKLM\Software\Microsoft\CurrentDate", date() msgbox "The Key is created." -------------------------------------------------------------------------------------------------------------- option explicit dim x dim knum dim count on error resume next set x = wscript.createobject("wscript.shell") knum = x.regread("HKLM\SOFTWARE\Microsoft\MyNumber") if Err = 0 then count = knum count = cint(count) + 1 x.regwrite "HKLM\SOFTWARE\Microsoft\MyNumber" , count else x.regwrite "HKLM\SOFTWARE\Microsoft\MyNumber" , "1" end if ---------------------------------------------------------------------------------------------------- option explicit dim objRegExp, result set objRegExp = New RegExp objRegExp.Pattern = "review3" result = inputbox("Pls enter a string.") if objRegExp.test(result) = "True" then msgbox objRegExp.replace(result, "test3") else msgbox "review3 not found" end if ------------------------------------------------------------------------------------------------- option explicit dim result, objDoctor set objDoctor = new Doctor result = inputbox("Pls enter a specialty") objDoctor.Specialty = result objDoctor.StateSpecialty Class Doctor Private strName Public Property Let Specialty(strSpecialty) strName = strSpecialty End Property Function StateSpecialty msgbox "My Specialty is " & strName End Function End Class --------------------------------------------------------------------------------------------- Option Explicit On Error Resume Next Dim objWshNet Set objWshNet = WScript.CreateObject("WScript.Network") MapNetworkDrive "q:", "\\****\courses\cpt257", "****\*****", "*****" WScript.Quit() 'Terminate script execution Sub MapNetworkDrive(DriveLetter, NetworkPath, user, password) objWshNet.MapNetworkDrive DriveLetter, NetworkPath,,user,password End Sub --------------------------------------------------------------------------------------------------- Option Explicit On Error Resume Next Dim objFsoObject, objWshShl, strNewAccts, strAcctName, strUser strUser = inputbox("Enter a user.") Set objFsoObject = CreateObject("Scripting.FileSystemObject") Set objWshShl = WScript.CreateObject("WScript.Shell") Set strNewAccts = _ objFsoObject.OpenTextFile("c:\Temp\UserNames.txt", 1, "True") CreateNewAccts() WScript.Quit() Sub CreateNewAccts() 'This procedures creates new accounts Do while False = strNewAccts.AtEndOfStream strAcctName = strNewAccts.ReadLine() if strAcctName = strUser then msgbox "The user already exists." else objWshShl.Run strUser & " " & strAcctName & " " & strAcctName & _ " /add", 0 msgbox "The user has been added." end if Loop strNewAccts.Close End Sub
|
|
| |
|
|
|