VBScript – Demolish those broken print jobs!




Tagged Under : ,

Version: 13.1a
Revision: 32 Build 12

VBScript – Demolish those broken print jobs!

Introduction:
when I am at home, I was reading ‘PC magazine’. They are so boring! So, I decided to rip – them – up and dip them into the shredder. Soon, it gave me an idea to construct a little script, just to delete all ‘print jobs’ from a specific printer!

Pretty straightforward…

1.] Download “Notepad++” from this website and install it.

2.] Execute “Notepad++” and copy this script. After that, just save it as a ‘VBScript’ file.

Example: delete_printjob.vbs

'Version: 13.1
'Revision: 12 Build 6
'-----------------------
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colInstalledPrinters =  objWMIService.ExecQuery _
    ("Select * from Win32_Printer Where Name = 'Lexmark X6100 Series'")
For Each objPrinter in colInstalledPrinters
    objPrinter.CancelAllJobs()
Next

3.] Check your printer for any print jobs.

See anything?

Copyrighted By Lair360




VBScript – Memory capacity analyzer.




Tagged Under : , , ,

Version: 13.1b
Revision: 34 Build 12

VBScript – Memory capacity analyzer.

Introduction:
this VBScript was designed in college. Well… I was bored to death as I have to wait for my lecturer, just to unlock the door. So, what did I do on my break? I Sat on the floor with my beautiful laptop and write this article for everyone to read, study and enjoy!

Anyway, there is one thing that I need to tell you…

Since I am on a private server, I am hosting all of these articles for you to learn. Therefore, you have to support me in some way! This server is not free, you know it! It’s a lot faster than before because, my services is put to the edge, just for you to succeed – not to end as a FAILURE!! Finally, to sum it all up… I have to dish out (proximately) 169 pounds – every 2 years + SSL encryption (to keep your privacy safe) with a dedicated IP address for better response time. So, please understand that I am doing this for all of you! This money is not for me… PLEASE understand!

——————
This VBScript will generate a small notice – board about your memory capacity and for additional free slots.
So, instead of taking out your computer case, you can use this VBScript to check your motherboard for empty slots!

Pretty cool, Eh?

1.] Download Notepad++ (http://notepad-plus.sourceforge.net/) from the author’s website and install the application.

2.] Execute Notepad++ and copy this script. After that, you’ll need to save it as: “memory_analyzer.vbs”.

Extension: .vbs (vbs file)

———— Copy Text —————

'Version: 1.3a
'Revision: 11 Build: 23
'Author: Lair360 - 2009
------------------------
strComputer = "." ' Local computer
strMemory = ""
i = 1

set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
set colItems = objWMIService.ExecQuery("Select * from Win32_PhysicalMemory")

For Each objItem In colItems
'This area will identify your total memory.
  if strMemory <> "" then strMemory = strMemory & vbcrlf
  strMemory = strMemory &  "Bank" & i & " : " & (objItem.Capacity / 1048576) & " Mb"
  i = i + 1
Next
installedModules = i - 1
'This area will indentify free slots.
Set colItems = objWMIService.ExecQuery("Select * from Win32_PhysicalMemoryArray")
For Each objItem in colItems
  totalSlots = objItem.MemoryDevices
    Next
'Reports on your installed memory.
Wscript.echo "Total Slots: " & totalSlots & vbcrlf & _
       "Free Slots: " & (totalSlots - installedModules) & vbcrlf & _
       vbcrlf & "Installed Modules:" & vbcrlf & strMemory

———— End —————

3.] Execute the Script and wait for the dialogue box.

4.] Enjoy!

Copyrighted By Lair360




VBScript – redirect WSscript into any directory




Tagged Under : , , , ,

Version: 13.1a
Revision: 15 Build 16

VBScript – redirect WSscript into any directory

Introduction:
yesterday, from work, I was totally boiling! This made everyone in the department a little curious…they aren’t sure, what happened.
But, that is not the point about this article…

This article will help user and IT administrator handle “wscript output” into any directory.
So, the solution is pretty much…simple…plain stupid. All we need to do is use: “AddQuotes, StringInput and stringRun” to accomplish this process. However, this will only work on “Windows XP SP2 +”, and, to avoid confusion, please read VBScript for dummies…

Bah…here is the Script! I need to get on with my Novel. But, don’t panic and run off my blog, I am just stressed. That is all…

——————————————

Notes #1: the function “AddQuotes” takes care of the double quoting issues, by surrounding whatever input (using the “stringInput” argument of the AddQuotes function.), and redirect the commands, using the built in “Chr(34)” function.

Notes #2: for the “%compspec% /c syntax”. That is old school and it’s already shown in Microsoft KB Articles.

—Copy Source Code—

'Author: Lair360
'Version: 13,6a
'Revision: 14.1 Build 11
'---------------------------------
Set objShell = WScript.CreateObject("WScript.Shell")
'You can modify this line only. But, don't modify anything else below "StrRun".
'---------------------------------
strRun = "%comspec% /c ipconfig.exe > " & AddQuotes("C:\temp\ipconfig.txt")
'---------------------------------
objShell.Run strRun, 1, True
Function AddQuotes(strInput)
AddQuotes = Chr(34) & strInput & Chr(34)
End Function

—End Source Code—

Here is another version for you to analyze. But, don’t get too confuse about it…

—Copy Source Code—

'Author: Lair360
'Version: 13,6a
'Revision: 14.1 Build 11
'---------------------------------
On Error Resume Next
Set objShell = WScript.CreateObject("WScript.Shell")
'You can modify this line only. But, don't modify anything else below "StrRun".
'---------------------------------
strRun = "%comspec% /k c: & ipconfig /displaydns > " & AddQuotes("I:\vbs project\ipconfig.txt")
'---------------------------------
objShell.Run strRun, 1, True
Function AddQuotes(strInput)
AddQuotes = Chr(34) & strInput & Chr(34)
End Function

—End Source Code—

Copyrighted By Lair360




VBScript – reboot & shutdown computer systems




Tagged Under : , , , , ,

Version: 13.2
Revision: 44 Build 11

VBScript – reboot & shutdown computer systems

Introduction:
many users had asked me to create a VBScript, so that they can shutdown their computer, when they are in an airport or other areas. After two days, I’ve managed to complete my script. However, it’s a pain in the neck to construct one! But, that road is not for you to worry about.

I take the risk and testing. But, the rest is for you to enjoy!

1.] Download notepad++ from the original author or from another source.
——————————-

http://sourceforge.net/projects/notepad-plus/

http://filehippo.com/download_notepad/

——————————-

2.] Copy this ‘VBScript’ source code and save it as a “.vbs” extension.

VBScript – Reboot Computer Systems
—Copy Source Code—

'Version: 12.2
'Revision: 44 Build 22
'Copyrighted by Lair360
'*******************************
Set OpSysSet = GetObject("winmgmts:{(Shutdown)}!\\.\root\cimv2").ExecQuery _
("select * from Win32_OperatingSystem where Primary=true")

for each OpSys in OpSysSet
OpSys.Reboot()
next

—End Source Code—

VBScript – Shutdown Computer Systems
—Copy Source Code—

'Version: 12.2
'Revision: 44 Build 22
'Copyrighted by Lair360
'*******************************
Set OpSysSet = GetObject("winmgmts:{(Shutdown)}!\\.\root\cimv2").ExecQuery _
("select * from Win32_OperatingSystem where Primary=true")

for each OpSys in OpSysSet
OpSys.Shutdown()
next

—End Source Code—

3.] Activate the script and enjoy it!

Copyright By Lair360




Eject USB – Terminate Application




Tagged Under : , , , , ,

Version: 11.1
Revision: 32 Build 15

Eject USB – Terminate Application

Introduction:
when I was working on my project and exit, I would like to eject my external drive. However, there is a problem.

If you close an application, most of the memory in that particular application is not freed, so you’ll have to terminate a process which is / are running inside your USB drive. After that, you can safely eject without rebooting your computer and wasting your time!

1.] Download notepad++ from the original author or from another source.
——————————-

http://sourceforge.net/projects/notepad-plus/

http://filehippo.com/download_notepad/

——————————-

2.] Copy this ‘VBScript’ source code and save it as “process_terminate.vbs” [without the quotes]. But, you can use other names if you want and keep the extension intact.

Advice: please put this script on your desktop or system tray.
But, don’t save this script into your external drive! If you do this, there will be conflicts and errors…

Terminate a process application & Eject USB
—Copy Source Code—

'Version: 34.1
'Revision: 44 Build 22
'Copyrighted by Lair360
'*******************************
Dim arrDrives()
intCount = 0
strComputer = "."
'*******************************
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
'Finds all removable drives - USB port.
Set colDrives = objWMIService.ExecQuery _
    ("Select * From Win32_LogicalDisk Where DriveType = 2")

For Each objDrive in colDrives
	ReDim Preserve arrDrives(intCount)
	arrDrives(intCount) = objDrive.DeviceID
	intCount = intCount + 1
Next
'*******************************
'Finds all processes from a specific removable drives
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Process")
For Each objItem in colItems
	For Each strDrive in arrDrives
		If LCase(Left(objItem.ExecutablePath, 2)) = LCase(strDrive) Then
			set objWMI = GetObject("winmgmts://" & strComputer)
			set objRootProcess = _
				objWMI.get("Win32_Process.Handle=" & objItem.ProcessId)
			KillProcessTree objRootProcess
		End If
	Next
Next
'*******************************
Sub KillProcessTree(objProcess)
	'Kills the process and any child processes
	objWQL = "Select * from Win32_Process " _
	& "where ParentProcessID=" & objProcess.Handle
	Set colResults = objWMI.ExecQuery(objWQL)
	For Each ChildProcess in colResults
		KillProcessTree childProcess
	Next
objProcess.Terminate
End Sub

—End Source Code—
Copyright 2001-2009 Lair360


4.] Execute the script!

5.] Done!