Scripting and Programming
Discussions about everything related to scripting and programming no matter of the programming language you're using.
70 topics in this forum
-
Introduction to Stopping Processes with WMI If ever you wish to stop or terminate a Windows process, then this is the page for you. Before you begin killing processes, you may wish to list processes running on a the Windows Server 2003 or XP computer. Task Manager is a great utility to match the names of the programs with their processes, you would not want to inadvertently kill the wrong process! Scenario - Why you would want to Terminate a Process? Perhaps you wish to restart a process, if so, then obviously you need to stop the process before you can start it again. Before the WMI script, can stop the program you need to know the precise name of the corresponding pr…
-
- 0 replies
- 10k views
-
-
Const ADS_PROPERTY_APPEND = 3 Set objGroup = GetObject _ ("LDAP://cn=Sea-Users,cn=Users,dc=NA,dc=fabrikam,dc=com") objGroup.PutEx ADS_PROPERTY_APPEND, "member", _ Array("cn=Scientists,ou=R&D,dc=NA,dc=fabrikam,dc=com", _ "cn=Executives,ou=Management,dc=NA,dc=fabrikam,dc=com", _ "cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com") objGroup.SetInfo
-
- 0 replies
- 3.5k views
-
-
On Error Resume Next Const E_ADS_PROPERTY_NOT_FOUND = &h8000500D Set objUser = GetObject _ ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com") intPrimaryGroupID = objUser.Get("primaryGroupID") arrMemberOf = objUser.GetEx("memberOf") If Err.Number = E_ADS_PROPERTY_NOT_FOUND Then WScript.Echo "The memberOf attribute is not set." Else WScript.Echo "Member of: " For Each Group in arrMemberOf WScript.Echo Group Next End If Set objConnection = CreateObject("ADODB.Connection") objConnection.Open "Provider=ADsDSOObject;" Set objCommand = CreateObject("ADODB.Command") objCommand.ActiveConnection = objConnection objCommand.CommandText …
-
- 0 replies
- 6.4k views
-
-
On Error Resume Next Set objGroup = GetObject _ ("LDAP://cn=Scientists,ou=R&D,dc=NA,dc=fabrikam,dc=com") objGroup.GetInfo arrMemberOf = objGroup.GetEx("member") WScript.Echo "Members:" For Each strMember in arrMemberOf WScript.echo strMember Next
-
- 0 replies
- 3.5k views
-
-
Dim objWMIService, objProcess, colProcess, fso, objFSO1, objFile, objFolder Dim strComputer, strList, strWritePath, textFile, strFile, strDirectory, i Const OPEN_FILE_FOR_WRITING = 2 strComputer = inputbox("Enter Computer Name Here.") strFile = strComputer &".txt" strWritePath = "\\SERVER\files\Scripts\" & strFile strDirectory = "\\SERVER\files\Scripts\" i = 0 '######### Set objFSO1 = CreateObject("Scripting.FileSystemObject") If objFSO1.FileExists("\\SERVER\files\Scripts\" & strFile) Then Set objFolder = objFSO1.GetFile("\\SERVER\files\Scripts\" & strFile) Else Set objFile = objFSO1.CreateTextFile(strDirectory & strFile) 'Wscript.Echo "Just cre…
-
- 0 replies
- 4k views
-
-
On error resume next Dim objADO Dim objContainer Dim objChild Dim User Wscript.Echo "The output will be written to C:\oldComputers.txt" set objADO = GetObject("LDAP://ou=workstations,ou=liverpool,dc=contoso,dc=local") set WshShell = WScript.CreateObject("WScript.Shell") Set fso = CreateObject("Scripting.FileSystemObject") fso.DeleteFile ("C:\oldComputers.txt") set txtStream = fso.OpenTextFile("C:\oldComputers.txt", 8, True) txtStream.WriteLine vbCrLf set objContainer = objADO For each objChild in objContainer user = MID(objChild.Name,4) If DateDiff ("d",objChild.LastLogin, Now) > 180 then txtStream.WriteLine user & " ---> " & DateDiff ("d",objChild.Las…
-
- 0 replies
- 2.9k views
-
-
On error resume next strComputer = InputBox("Type in the name of the computer you want to query.") If strComputer > "" Then 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 Next Else Wscript.Quit End If Wscript.Quit
-
- 0 replies
- 5.4k views
-
-
'Changes Windows NT clients from using static IP address's to use DHCP. Could be called from the logon script. Combined with the use of the SU utility this could be added to a logon script to perform a hands off migration. 'All variables declared Option Explicit Dim oWSHShell Dim sNIC, sMan Dim iCount Set oWSHShell = Wscript.CreateObject("Wscript.Shell") ' Set the DCHP service to autostart oWSHShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Services\DHCP\Start", 2 ' Get Network card On Error Resume Next iCount = 1 Do sNIC = oWSHShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards\" & iCount & "\ServiceName") sMan = oWSHShell.RegRe…
-
- 0 replies
- 8k views
-
-
DomainName = InputBox("Enter domain name") ServerName = InputBox("Enter server name") ShareName = InputBox("Enter share name to be deleted") Set cont = GetObject("WinNT://"& DomainName &"/"& ServerName &"/LanmanServer,FileService") cont.Delete "FileShare", ""& ShareName &""
-
- 0 replies
- 6k views
-
-
Dim oFSO, oFolder, oFiles, oFile Set oFSO = CreateObject("Scripting.FileSystemObject") Set oFolder = oFSO.GetFolder("C:\TEST") Set oFiles = oFolder.Files for each oFile in oFiles if oFile.DateLastModified > DateAdd("d", -14, Now()) then if MsgBox("Delete " & oFile.Path, vbYesNo) = vbYes then ' Omit 'True' in the next line if ReadOnly should be respected oFile.Delete True end if end if next
-
- 0 replies
- 11.2k views
-
-
decNum = Inputbox("Enter the Decimal Value you want to convert:") hexNum = hex(decNum) MsgBox "Decimal Value You Entered: " & decNum & vbCRLF & "Hex Value Conversion: " & hexNum
-
- 0 replies
- 5.3k views
-
-
Dim Container Dim ContainerName Dim User Dim NewUser ContainerName = InputBox("Enter the Domain Name:") Newuser = InputBox("Enter the new user name:") Set Container = GetObject("WinNT://" & ContainerName) Set User = Container.Create("User", NewUser) User.SetInfo
-
- 0 replies
- 7.1k views
-
-
DomainName = InputBox("Enter domain name") ServerName = InputBox("Enter server name") ShareName = InputBox("Enter share name to be created") PathName = InputBox("Enter the full path of the new share") Set cont = GetObject("WinNT://"& DomainName &"/"& ServerName &"/LanmanServer,FileService") Set fs = cont.Create("FileShare", ""& ShareName &"") fs.Path = ""& PathName &"" fs.MaxUserCount = -1 fs.SetInfo
-
- 0 replies
- 9.2k views
-
-
If err.number = 0 Then Set FSO = CreateObject("Scripting.FileSystemObject") FSO.CreateTextFile "c:\MSO2000.TXT" Else End if
-
- 0 replies
- 12.9k views
-
-
Set fso = CreateObject("Scripting.FileSystemObject") fso.copyFile "c:\mytext.txt" , "c:\temp\"
-
- 0 replies
- 6.6k views
-
-
Dim UserName Dim UserDomain UserDomain = InputBox("Enter the user's login domain name") UserName = InputBox("Enter the user's login name") Set User = GetObject("WinNT://"& UserDomain &"/"& UserName &"",user) Dim NewPassword NewPassword = InputBox("Enter new password") Call User.SetPassword(NewPassword) If err.number = 0 Then Wscript.Echo "The password change was successful." Else Wscript.Echo "The password change failed!" End if
-
- 0 replies
- 13k views
-
-
Set SNSet = GetObject("winmgmts:").InstancesOf ("Win32_BIOS") for each SN in SNSet MsgBox "The serial number for this PC is: " & SN.SerialNumber Next
-
- 0 replies
- 6.9k views
-
-
Dim p p = InputBox("Enter the network path to the printer you want to install:", "Add Printer", "\\Server\PrinterName") If p <> "" Then Dim cmd cmd = "rundll32 printui,PrintUIEntry /in /n" & p WScript.CreateObject("WScript.Shell").Run cmd End If
-
- 0 replies
- 13.1k views
-
-
UserName = InputBox("Enter the user's login name that you want to unlock:") DomainName = InputBox("Enter the domain name in which the user account exists:") Set UserObj = GetObject("WinNT://"& DomainName &"/"& UserName &"") If UserObj.IsAccountLocked = -1 then UserObj.IsAccountLocked = 0 UserObj.SetInfo If err.number = 0 Then Wscript.Echo "The Account Unlock Failed. Check that the account is, in fact, locked-out." Else Wscript.Echo "The Account Unlock was Successful" End if
-
- 0 replies
- 8.7k views
-
-
Option Explicit Dim NetworkAdapter, AdapterConfiguration 'Objects Dim IPAddress, SubnetMask, Gateway, DNS 'String Arrays Dim RetVal 'Integers For Each NetworkAdapter In GetObject("winmgmts:").InstancesOf("Win32_NetworkAdapter") If NetworkAdapter.AdapterType = "Ethernet 802.3" Then For Each AdapterConfiguration In GetObject("winmgmts:").InstancesOf("Win32_NetworkAdapterConfiguration") If UCase(AdapterConfiguration.ServiceName) = UCase(NetworkAdapter.ServiceName) Then IPAddress = Array("192.168.0.10") SubnetMask = Array("255.255.255.0") Gateway = Array("192.168.0.1") DNS = Array("35.8.2.41") RetVal = AdapterConfiguration.EnableStatic(IPAddres…
-
- 0 replies
- 16.9k views
-