<?xml version="1.0" encoding="iso-8859-1"?>
<rss version="2.0">
  <channel>
    <title>The Jar</title>
    <link>http://jar.yosephine.com/</link>
    <description>Scripts and stuff I</description>
    <language>en-us</language>           
    <generator>Nucleus CMS v3.32</generator>
    <copyright>Ã¯Â¿Â½</copyright>             
    <category>Weblog</category>
    <docs>http://backend.userland.com/rss</docs>
    <image>
      <url>http://jar.yosephine.com//nucleus/nucleus2.gif</url>
      <title>The Jar</title>
      <link>http://jar.yosephine.com/</link>
    </image>
    <item>
 <title>The problem with Java Runtime Environment...</title>
 <link>http://jar.yosephine.com/index.php?itemid=20</link>
<description><![CDATA[The problem with Java Runtime Environment is that security holes and flaws are constantly found and new patched versions and updates pop up way too often. This causes a lot of work for the person(s) in charge of keeping the Java up to date on the computers. This is especially true if the company has business critical applications that rely on JRE and if the company therefore does not allow the JRE on the workstations to update themselves automatically or if the level of permissions granted to the users is too low for using JRE's autoupdate feature.<br />
I happen to work at such a place. As we have about 1500 computers, most of which need to have JRE installed, there's a lot of work keeping the JRE's on the workstations up to date. Even though we have a workstation management system for deploying the new Java it's a lot of work. To ease the burden of keeping the JRE environment up to date I made a simple script to remove all old versions of Java and install the new veresion.<br />
The script checks what version(s) of Java is installed. It then removes all versions, except the most recent version. If the most recent version isn't installed it will install it. Furthermore, the script will copy the deployment.config file to the workstation. This file points the Java installation on the workstation to use settings from a central settings file. This might be useful in a corporate environment. <br />
Please click on "Read more..." to read more :)The script will need administrative privileges to work. Also, the location of the JRE installer file must be a trusted location (in Internet Options). Otherwise the client will get the annoying "Open file security warning" dialog box.<br />
<br />
The script looks somewhat like this:<br />
*----CUT HERE---*<br />
Option Explicit<br />
Dim msiObject, msiProduct, strProdList, strProdInfo, msiProdVersion,appName1, appName2, InstallerPath<br />
Dim CommandShell, cmdline, strDontUninstallThis, boolNewJavaExists, fso, objShell, variable, newfolder, ConfigFile<br />
Const msiInstallStateDefault = 5<br />
    <br />
appName1 = "java"                                           'Application name (or part of name) to search for and uninstall.<br />
appName2 = "j2se"                                           'Name of another application to search for and uninstall (some old java versions are shown in Add/remove programs as j2se)<br />
strDontUninstallThis = "java(tm) 6 update 18"    'Here we put the name of the version that should NOT be uninstalled.<br />
InstallerPath = "\\Servername\sharename\jre-6u18-windows-i586-s.exe"    'Change this to reflect the path where you have saved the JRE installer file.<br />
ConfigFile = "\\servername\sharename\deployment.config"                        'Change this to reflect the path where you have saved the deployment.config file.<br />
boolNewJavaExists = False<br />
<br />
strProdList = ""<br />
Set msiObject = Wscript.CreateObject("WindowsInstaller.Installer")<br />
<br />
For Each msiProduct In msiObject.Products<br />
     If InStr(LCase(msiObject.ProductInfo(msiProduct, "ProductName")), LCase(appName1)) Then                  <br />
	If not (LCase(msiObject.ProductInfo(msiProduct, "ProductName")) = LCase(strDontUninstallThis)) Then<br />
	        set CommandShell = createobject("wscript.shell")<br />
	        cmdline = "msiexec /X " & msiProduct & " /qn"<br />
	        CommandShell.run cmdline, 1, true<br />
	Else<br />
		boolNewJavaExists = True<br />
	End If<br />
     ElseIf InStr(LCase(msiObject.ProductInfo(msiProduct, "ProductName")), LCase(appName2)) Then<br />
	If not (LCase(msiObject.ProductInfo(msiProduct, "ProductName")) = LCase(strDontUninstallThis)) Then<br />
	        set CommandShell = createobject("wscript.shell")<br />
	        cmdline = "msiexec /X " & msiProduct & " /qn"<br />
	        CommandShell.run cmdline, 1, true<br />
	Else<br />
		boolNewJavaExists = True<br />
	End If<br />
	<br />
     End If<br />
Next<br />
<br />
If (boolNewJavaExists = False) Then<br />
	set CommandShell = createobject("wscript.shell")<br />
	cmdline = Chr(34) & InstallerPath & Chr(34) & " /s AgreeToLicense=YES IEXPLORER=1 MOZILLA=1 REBOOT=Suppress JAVAUPDATE=0"<br />
	CommandShell.run cmdline, 1, true<br />
End If<br />
<br />
set fso=CreateObject("Scripting.FileSystemObject")<br />
If fso.FileExists(ConfigFile) Then<br />
	If not fso.FolderExists(EnvString("windir") & "\sun\") Then<br />
		newfolder = fso.CreateFolder(EnvString("windir") & "\sun\")<br />
	End IF<br />
	If not fso.FolderExists(EnvString("windir") & "\sun\java\") Then<br />
		newfolder = fso.CreateFolder(EnvString("windir") & "\sun\java\")<br />
	End IF<br />
	If not fso.FolderExists(EnvString("windir") & "\sun\java\deployment\") Then<br />
		newfolder = fso.CreateFolder(EnvString("windir") & "\sun\java\deployment\")<br />
	End IF<br />
	fso.CopyFile ConfigFile, EnvString("windir") & "\sun\java\deployment\"<br />
End If<br />
<br />
Function EnvString(variable)<br />
'This function returns a particular environment variable’s value.<br />
' for example, if you use EnvString("username"), it would return<br />
' the value of %username%.<br />
    set objShell = WScript.CreateObject( "WScript.Shell" )<br />
    variable = "%" & variable & "%"<br />
    EnvString = objShell.ExpandEnvironmentStrings(variable)    <br />
    Set objShell = Nothing    <br />
End Function<br />
*----CUT HERE---*<br />
<br />
In addition to the script you will need the JRE installer, which can be downloaded from <A href="http://www.java.com/getjava/"> Sun's </A> website.<br />
<br />
Also, you will need to create a deployment.config file, which could look somewhat like this:<br />
<br />
*----CUT HERE---*<br />
deployment.system.config=file:\\\\Servername\\sharename\\deployment.properties<br />
deployment.system.config.mandatory=FALSE<br />
*----CUT HERE---*<br />
<br />
Finally you will need a deployment.properties file, which you should save on some server share. The file might look something like this:<br />
<br />
*----CUT HERE---*<br />
deployment.javaws.shortcut=NEVER<br />
deployment.javaws.autodownload=NEVER<br />
deployment.javaws.autodownload.locked<br />
deployment.cache.max.size = 200<br />
*----CUT HERE---*<br />
<br />
You may save all files in the same network share. Just make sure it's readable from the computers. The script can be run locally on each workstation e.g. using some workstation management system. You can also run it remotely e.g. using psexec.exe.]]></description>
 <category>General</category>
<comments>http://jar.yosephine.com/index.php?itemid=20</comments>
 <pubDate>Mon, 1 Feb 2010 02:53:35 -0500</pubDate>
</item><item>
 <title>Monitoring e-mail service availability</title>
 <link>http://jar.yosephine.com/index.php?itemid=18</link>
<description><![CDATA[I just found a bunch of scripts from way back in time. One of them is particularly interesting. It is a script that monitors the availability of the e-mail service. This might be useful for some of you, so I decided to share it here. The script monitors the availability of the e-mail service by sending an e-mail message, and then making sure that the message arrived in the mailbox it was sent to. If the message doesn't arrive within a predefined time, an SMS will be sent using Microsoft's SMS sender program. This means that you need to have a mobile phone connected to your computer, but the script could be modified to start any program if the message didn't arrive on time. I wouldn't recommend sending an e-mail though...<br />
<br />
The script uses w3sockets (socketreg.exe & socket.dll) from http://www.dimac.net. I won't post those files here, but you can download them from <A href="http://www.dimac.net">here</A>.<br />
<br />
Also, the script uses Microsoft's SMS sender for sending the SMS messages using a mobile phone connected to the computer that runs the script. The SMS sender program can be found <A href="http://www.microsoft.com/downloads/details.aspx?FamilyID=06a4f997-7f69-4891-8929-37b9041924a2&displaylang=en">here</A>.<br />
<br />
The SMS sender program is kind of problematic. When you send an SMS it will throw a notification on the screen. I've used pskill.exe (part of the pstools, available <A href="http://technet.microsoft.com/en-us/sysinternals/bb896683.aspx">here</A>) to kill the SMS sender program and its notifications.<br />
<br />
And finally, the script itself is shown below...<br />
<br />
'This script sends e-mail using SMTP, and then checks that the messages have arrived in the Excgange server mailbox using POP3.<br />
'The purpose of the script is to monitor SMTP mail flow and alert if there is a problem in the mail flow.<br />
'The script is dependent upon the socket.dll, which should be registered on the server (by running SocketReg.exe).<br />
'The required files should be kept in the same dir as this script, in order to be available.<br />
'This script also utilizes Microsoft's free smssender.exe to send alerts using a mobile phone connected to the computer.<br />
'Also pskill.exe is used to kill the smssender.exe's notification.<br />
<br />
'The following variables may be changed:<br />
arrSMTPServers = array("SERVER1", "SERVER2")				'Put your servers here<br />
intSMTPPort = 25							'Set the port to use for sending SMTP mail<br />
strFromAddr = "youraddress@yourdomain.com"				'Set the sender address for the messages<br />
strToAddr = "destinationaddress@yourdomain.com"				'Set the recipient address for the messages<br />
strPOPServer = "popserver.yourdomain.com"						'Set the POP server<br />
intPOPPort = 110							'Set the POP server port<br />
strSMSSender = "c:\Program files\Microsoft SMS Sender\smssender.exe"	'Path to smssender.exe<br />
strPhoneNumber = "5551234"						'Phone number to send alert messages to<br />
strPSKill = "c:\temp\pskill.exe"					'Path to pskill.exe<br />
strExpectedGreeting = "Microsoft Exchange"               'Expected greeting text of POP server<br />
strPOPUser = "username"                                          'Username for the POP mailbox<br />
strPOPPass = "password"                                       'Password for the POP mailbox<br />
<br />
'Do not change anything below this line!<br />
'---------------------------------------<br />
<br />
Dim arrID() 						'Array, containing the ID's for the messages to send.<br />
On Error Resume Next<br />
arrPath = Split(strSMSSender, "\")<br />
strSMSexe = arrPath(Ubound(arrPath))<br />
<br />
For i=0 to Ubound(arrSMTPServers)<br />
	'Generate ID's for the messages to send:<br />
	ReDim Preserve arrID(i) <br />
	arrID(i) = fGenerateID<br />
	'Send message:<br />
	subSendMail arrSMTPServers(i), intSMTPPort, strFromAddr, strToAddr, arrID(i), arrID(i)<br />
Next<br />
<br />
'Sleep for a while to allow time for the messages to be scanned and delivered:<br />
Wscript.sleep 20000<br />
<br />
For i=0 to Ubound(arrSMTPServers)<br />
	'Read mailbox, and search for our messages:<br />
	If fReadPOPMsgs (arrID(i), strPOPServer, intPOPPort, strExpectedGreeting, strPOPUser, strPOPPass) = 1 Then<br />
		Wscript.echo "Inbound SMTP route through " & arrSMTPServers(i) & " is OK!"<br />
	Else<br />
		Wscript.echo "Inbound SMTP route through " & arrSMTPServers(i) & " is DOWN!"<br />
		Set objShell = WScript.CreateObject("WScript.Shell")<br />
		objShell.Run (Chr(34) & strSMSSender & Chr(34) & " /p:" & strPhoneNumber & " /m:" & Chr(34) & "Inbound SMTP route through " & arrSMTPServers(i) & " is DOWN!" & Chr(34)),0<br />
		wscript.sleep 30000<br />
		objShell.Run (Chr(34) & strPSKill & Chr(34) & " " & strSMSexe)<br />
	End If<br />
Next	<br />
<br />
fDelPOPMsgs strPOPServer, intPOPPort, strExpectedGreeting, strPOPUser, strPOPPass<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
'***************** subSendMail() **********************<br />
Sub subSendMail(server, port, sender, recipient, subject, body)<br />
Set objEmail = CreateObject("CDO.Message")<br />
objEmail.From = sender<br />
objEmail.To = recipient<br />
objEmail.Subject = subject<br />
objEmail.Textbody = body<br />
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2<br />
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = server<br />
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = port<br />
objEmail.Configuration.Fields.Update<br />
objEmail.Send<br />
End Sub<br />
<br />
'***************** fGenerateID() **********************<br />
Function fGenerateID()<br />
Randomize<br />
b = 0<br />
ID = ""<br />
Do while b <= 40<br />
	ID = ID & Int(10 * Rnd)<br />
	b = b + 1<br />
Loop<br />
fGenerateID = ID<br />
End Function<br />
<br />
<br />
<br />
'***************** fReadPOPMsgs() **********************<br />
Function fReadPOPMsgs(identifier, strPOPServer, intPOPPort, strExpectedGreeting, strPOPUser, strPOPPass)<br />
Dim oSocket, iErr, sSocketText<br />
sSocketText = ""<br />
a = 1<br />
strStat = ""<br />
Set oSocket = CreateObject("Socket.TCP")<br />
oSocket.DoTelnetEmulation = True<br />
oSocket.TelnetEmulation = "TTY"<br />
oSocket.Host = strPOPServer & ":" & intPOPPort<br />
On Error Resume Next <br />
oSocket.Open<br />
iErr = Err.Number<br />
 If iErr <> 0 Then <br />
  fReadPOPMsgs = 0<br />
  Exit Function <br />
 End If <br />
sSocketText = oSocket.GetLine<br />
If InStr(sSocketText, strExpectedGreeting) = 0 Then WScript.Echo sSocketText<br />
<br />
oSocket.SendLine "user " & strPOPUser<br />
sSocketText = oSocket.GetLine<br />
If InStr(sSocketText,"OK") = 0 Then WScript.Echo sSocketText<br />
<br />
oSocket.SendLine "pass " & strPOPPass<br />
sSocketText = oSocket.GetLine<br />
If InStr(sSocketText,"User successfully logged on") = 0 Then WScript.Echo sSocketText<br />
<br />
oSocket.SendLine "stat"<br />
sSocketText = oSocket.GetLine<br />
strStat = sSocketText<br />
arrStat = Split(strStat, " ")<br />
<br />
Do while Int(arrStat(1)) >= a<br />
   sSocketText = ""<br />
   oSocket.SendLine "retr " & a<br />
   Do while sSocketText <> "."<br />
	sSocketText = oSocket.GetLine<br />
	If InStr(sSocketText, identifier) <> 0 Then fReadPOPMsgs = 1<br />
	'WScript.Echo sSocketText<br />
   Loop<br />
   a = a + 1<br />
Loop<br />
oSocket.SendLine "quit"<br />
<br />
<br />
<br />
oSocket.Close<br />
On Error GoTo 0<br />
'fReadPOPMsgs = 0<br />
<br />
End Function<br />
<br />
'***************** fDelPOPMsgs() **********************<br />
Function fDelPOPMsgs(strPOPServer, intPOPPort, strExpectedGreeting, strPOPUser, strPOPPass)<br />
Dim oSocket, iErr, sSocketText<br />
sSocketText = ""<br />
a = 1<br />
strStat = ""<br />
Set oSocket = CreateObject("Socket.TCP")<br />
oSocket.DoTelnetEmulation = True<br />
oSocket.TelnetEmulation = "TTY"<br />
oSocket.Host = strPOPServer & ":" & intPOPPort<br />
On Error Resume Next <br />
oSocket.Open<br />
iErr = Err.Number<br />
 If iErr <> 0 Then <br />
  fReadPOPMsgs = 0<br />
  Exit Function <br />
 End If <br />
sSocketText = oSocket.GetLine<br />
If InStr(sSocketText, strExpectedGreeting) = 0 Then WScript.Echo sSocketText<br />
<br />
oSocket.SendLine "user " & strPOPUser <br />
sSocketText = oSocket.GetLine<br />
If InStr(sSocketText,"OK") = 0 Then WScript.Echo sSocketText<br />
<br />
oSocket.SendLine "pass " & strPOPPass <br />
sSocketText = oSocket.GetLine<br />
If InStr(sSocketText,"User successfully logged on") = 0 Then WScript.Echo sSocketText<br />
<br />
oSocket.SendLine "stat"<br />
sSocketText = oSocket.GetLine<br />
strStat = sSocketText<br />
arrStat = Split(strStat, " ")<br />
a=1<br />
Do while Int(arrStat(1)) >= a<br />
   sSocketText = ""<br />
   oSocket.SendLine "dele " & a<br />
   sSocketText = oSocket.GetLine<br />
'   wscript.echo sSocketText<br />
   a = a + 1<br />
Loop<br />
oSocket.SendLine "quit"<br />
<br />
<br />
<br />
oSocket.Close<br />
On Error GoTo 0<br />
fDelPOPMsgs = 0<br />
<br />
End Function]]></description>
 <category>General</category>
<comments>http://jar.yosephine.com/index.php?itemid=18</comments>
 <pubDate>Thu, 10 Sep 2009 07:02:44 -0400</pubDate>
</item><item>
 <title>Ok, they found me...</title>
 <link>http://jar.yosephine.com/index.php?itemid=16</link>
<description><![CDATA[I wondered why the traffic was suddenly up to 2GB per day, until I noticed my blog's comment-function was being misused by mass-posting various spam messages into the comment-field.<br />
<br />
With 6000+ spams I figured it was best to just bulk-erase them all. Sorry for removing all nice comments as well. <br />
<br />
For the time being the comment-section is closed :(]]></description>
 <category>General</category>
<comments>http://jar.yosephine.com/index.php?itemid=16</comments>
 <pubDate>Sun, 26 Jul 2009 18:13:51 -0400</pubDate>
</item><item>
 <title>HTA</title>
 <link>http://jar.yosephine.com/index.php?itemid=14</link>
<description><![CDATA[I've mostly been using vbscripts to accomplish various system administration tasks. It's a good tool for automating tasks. While you can get nice message- and input boxes with vbscript I've been missing a real graphical user interface though. A while ago I stumbled upon something called HTA (HTML Applications), and thought it sounded interesting. I didn't have time to study it any further at the time, though, so I just added the site to my favorites folder, where it's been sitting dormant for some months now. A couple of days ago I found it again and took a closer look, and WOW! That's cool. Microsoft has a really nice little two chapter introduction to this <a href="http://www.microsoft.com/technet/scriptcenter/topics/htas/tutorial1.mspx"><B>here</B></a>. <br />
<br />
I've created a small and simple helpdesk application for our users in just a couple of hours. The hta does some basic diagnostics (Checking if the computer is on the network, checking that e-mail servers are available, checking CPU load, etc.), shows basic computer information (Computer name, make, model, memory, hard drive, serial number etc), and allows the user to send support requests to the support team. The nice thing with this method of sending support requests is that the hta can automatically add some relevant information to the support request (such as computer name and IP address), that the user doesn't necessarily understand to add themselves.<br />
<br />
I may be posting the hta here if someone requests it, and more importantly, if I have the time to tidy it up a bit. For now the application is in English only, but I just might add different languages (Swedish, Finnish, German). ]]></description>
 <category>General</category>
<comments>http://jar.yosephine.com/index.php?itemid=14</comments>
 <pubDate>Fri, 29 May 2009 09:47:13 -0400</pubDate>
</item><item>
 <title>Please find me, Googlebots, crawlers, people, anyone...</title>
 <link>http://jar.yosephine.com/index.php?itemid=12</link>
<description><![CDATA[I'm getting frustrated. My excellent blog isn't getting any hits. I guess this is the problem with a privately owned and hosted blog like this. Maybe I should have started this blog on one of the numerous free blog sites on the Internet.<br />
<br />
Well, anyway I should probably start investigating how I can get some publicity for my fine blog. The only thing is that I don't find that very interesting. <br />
<br />
A quick search on one of the leading web search engines led me to some kind of link exchange program, which can be found here:<br />
SubmitLinksFree.com - the high quality <a href="http://www.submitlinksfree.com">Links Directory</a> for webmasters.<br/><br />
<a href="http://www.addyourlink.org" id="RDA18E5">Add Your Link</a> - Web Directory. Add your link today.<BR><br />
-Sorry, I had to include those links to be allowed to submit my link to the site. Let's see if it helps. I'm expecting to get numerous hits within the next 24 hours ;)]]></description>
 <category>General</category>
<comments>http://jar.yosephine.com/index.php?itemid=12</comments>
 <pubDate>Thu, 28 May 2009 15:00:31 -0400</pubDate>
</item><item>
 <title>Replacing the printer server can be a pain</title>
 <link>http://jar.yosephine.com/index.php?itemid=10</link>
<description><![CDATA[So we had this old Windows printer server that needed to be replaced. The server had about 200 printer queues shared to about a thousand computers. A new printer server was set up and new printer shares were made. At the same time we decided to deploy a new printer naming policy, so the printer queues got new names on the new server. Now the only problem was to replace the printer queue connections on the 1000+ workstations from the old server to the corresponding queues on the new server. As our users haven't got that good computing skills we realized we couldn't just post instructions to the users on how to replace the old queues with the new ones. After some thinking I came up with the idea to use a script to replace the old queues with the new ones on the workstations.<br />
<br />
The script works as follows:<br />
First you need to make a file containing a list of old queues and their corresponding new queues. Let the file be named filename.txt in this example. Here's what filename.txt could look like:<br />
<br />
\\OldServer\OldPrinterQueueName,\\NewServer\NewPrinterQueueName<br />
\\OldServer\AnotherOldQueue,\\NewServer\AnotherNewQueue<br />
\\AnotherOldServer\AThirdQueue,\\AnotherNewServer\AThirdQueue<br />
<br />
As you probably can see, each line comprises an old queue and a new queue, separated by a comma. That's all. You may make the list as long as you want as long as each line contains just this comma-separated pair of printer queues. No comments, no other text is allowed, just the comma-separated pairs of queues, one pair per line.<br />
<br />
Then you need to edit the script and insert the full UNC path of the file you just created. If you named the file "filename.txt", saved it on a share called "ShareName" on a server, named "Server", then you would enter "\\Server\ShareName\FileName.txt" as the value of the strFile variable in the script.<br />
<br />
Finally you should make sure this script runs for each user in your environment. This can be done e.g. by calling it from the logon script. As the script might take some time to run you might want to make sure it runs only once for each user. This, in turn, may be accomplished e.g. by adding a few lines in your users' logon script(s), checking if a certain file exists in the user's profile. If the file exists, the logon script will skip calling the printer change script. If the file doesn't exist the logon script should call the printer change script and create this certain file in the user's profile to avoid that the printer change script is run the next time the user logs on.<br />
<br />
Ok, that's probably all you need to know about the script. Here's the script code. You may use it free of charge as long as I'm given the appropriate credit. You may also change it as you wish, but you may not remove my name from it.<br />
<br />
<br />
' Script that changes the user's printer(s) to other(s) printer(s) according to a csv list of printers.<br />
' The list of printers should contain comma separated printer pairs, one pair at each line, like this:<br />
' \\server1\printer1,\\server2\printer2<br />
' where \\server1\printer1 is the printer that shall be replaced, <br />
' and \\server2\printer2 is the printer that shall replace the beforementioned printer.<br />
' The script can be called from a e.g. the logon script and the script can replace several different printers. <br />
' Just add more lines to the list of printers and the script will go through them all.<br />
' The script also notes which printer is the default printer and sets the replacing printer as default printer.<br />
' Created by Dennis Nyholm 23.7.2008<br />
<br />
'Fill in the filename of the list of printers here:<br />
set strFile = "\\servername\sharename\filename.txt"<br />
<br />
Const ForReading = 1<br />
Set objFSO = CreateObject("Scripting.FileSystemObject")<br />
Set objTextFile = objFSO.OpenTextFile(strFile, ForReading)<br />
Do Until objTextFile.AtEndOfStream<br />
	strLine = objTextFile.Readline<br />
	arrprt = Split(strLine, ",")<br />
	Sourceprt = arrprt(0)<br />
	Destprt = arrprt(1)<br />
	'Wscript.Echo Sourceprt & " => " & Destprt<br />
	strComputer = "."<br />
	'Set error handling on:<br />
	'On Error Resume Next<br />
	Set objNetwork = CreateObject("Wscript.Network")<br />
<br />
	Set objWMIService = GetObject("winmgmts:" _<br />
	    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")<br />
	Set colInstalledPrinters =  objWMIService.ExecQuery _<br />
	    ("SELECT * FROM Win32_Printer")<br />
	For Each objPrinter in colInstalledPrinters<br />
		'Wscript.Echo "Printer Name: " & objPrinter.Name<br />
		If LCase(objPrinter.Name) = LCase(Sourceprt) Then<br />
			Wscript.Echo objPrinter.Name & " will be replaced by " & Destprt<br />
			'Install replacing printer:<br />
			objNetwork.AddWindowsPrinterConnection Destprt<br />
<br />
			'Check default printer:<br />
			Set WshShell = WScript.CreateObject("WScript.Shell")<br />
			strDefaultPrinter = WshShell.RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows\Device")<br />
			arrDefaultPrinter = Split(strDefaultPrinter, ",")<br />
<br />
			'Check if this is the default printer:<br />
			If LCase(arrDefaultPrinter(0)) = LCase(objPrinter.Name) Then<br />
				'Wscript.Echo "Is default printer"<br />
				'Set the printer as default:<br />
				objNetwork.SetDefaultPrinter Destprt<br />
			End If <br />
<br />
			'Remove old printer:<br />
			objNetwork.RemovePrinterConnection Sourceprt<br />
		End If<br />
<br />
	Next<br />
Loop<br />
<br />
]]></description>
 <category>General</category>
<comments>http://jar.yosephine.com/index.php?itemid=10</comments>
 <pubDate>Tue, 26 May 2009 05:49:48 -0400</pubDate>
</item><item>
 <title>Instant VNC session</title>
 <link>http://jar.yosephine.com/index.php?itemid=8</link>
<description><![CDATA[Ever wanted to remotely assist someone with their problem only to find out that the remote help program isn't installed on the remote user's computer. Here's a simple solution for that problem. I call it instant VNC session. A script installs the VNC service onto the remote computer and 'instantly' opens a VNC session to it. This can be handy when Remote Assistance or any other remote help software hasn't been installed on the remote computer, or when the installed program just doesn't work. The beautiful thing with this instant VNC script is that upon disconnect it will clean up after itself. No service or files will be left on the target computer. Obviously you will need to have admin privileges to the remote computer for this to work! (Otherwise it would be an evil H4x0R backdoor thingie...)<br />
Oh, and the password for the VNC session is "secret" (without the quotes). You can (and probably should) change it by editing the instantVNC.vbs script.<br />
<br />
How to use:<br />
<br />
1) Download <a href="http://jar.yosephine.com/stuff/instantvnc.zip"><b>this</b></a> file.<br />
2) Extract the content of the file to any desired folder on your PC.<br />
3) Run the RUNME.BAT file<br />
<br />
The script will ask for some details, such as the name or IP address of the computer you wish to remotely control. After this it will install the VNC service onto the target computer and launch the VNC client that will allow you to view and control the remote computer. This should work on Windows XP. Haven't tested in Vista, but probably won't work there.]]></description>
 <category>General</category>
<comments>http://jar.yosephine.com/index.php?itemid=8</comments>
 <pubDate>Mon, 25 May 2009 11:24:47 -0400</pubDate>
</item><item>
 <title>Finding files on any computer in the Active Directory</title>
 <link>http://jar.yosephine.com/index.php?itemid=5</link>
<description><![CDATA[Have you ever been searching for a file that you know is on one of your computers in the AD, but you fail to remember which computer the file resides on. I've had that problem on several occasions, so one day I made a vbs script that searches through all the computers in the AD for the bugger. It might take some time for this script to find your file, because it searches through the computers one by one. Maybe I'll create a new version sometime that searches for the file on several computers in parallel. The script will remember which computers it wasn't able to search, so switched off computers will be retried. <br />
<br />
There are a number of things that could have been done better in this script. Now you can e.g. only search by exact file name, including extension (e.g. filename.exe) or substitute the file name or extension with wildcards (e.g. filename.* or *.exe). You're welcome to improve the script. If you decide to do so, please post the improved version here for everyone (including me) to enjoy.<br />
<br />
Oh, and all scripts on this site (including this one) may be used by anyone for free, as long as you include the credits in the script code.<br />
<br />
Well, enough babbling. Click on Read More to see the script.'ADFileFind.vbs by Dennis Nyholm (jar@yosephine.com) 16.7.2006<br />
<br />
On Error Resume Next<br />
<br />
Set strDomainName = "yourdomain"<br />
Set strDomainExt = "net"<br />
<br />
If Wscript.Arguments.Count < 1 Then<br />
	Wscript.Echo "Too few arguments!"& Chr(10) & Chr(13) & "Usage: cscript ADfilefind.vbs <filename.ext>"<br />
	Wscript.Quit<br />
End If<br />
<br />
Set ArgObj = Wscript.Arguments<br />
ArrFilename = split(ArgObj(0), ".")<br />
<br />
Wscript.Echo "Filename=" & ArrFilename(0)<br />
Wscript.Echo "Extension=" & ArrFilename(1)<br />
<br />
Const ADS_SCOPE_SUBTREE = 2<br />
Const MBCONVERSION= 1048576<br />
Const ForReading = 1<br />
Const ForWriting = 2<br />
<br />
Set objConnection = CreateObject("ADODB.Connection")<br />
Set objCommand =   CreateObject("ADODB.Command")<br />
objConnection.Provider = "ADsDSOObject"<br />
objConnection.Open "Active Directory Provider"<br />
<br />
Set objCOmmand.ActiveConnection = objConnection<br />
objCommand.CommandText = "Select Name, Location from 'LDAP://DC=" & strDomainName & ",DC=" & strDomainExt & "' Where objectClass='computer'"  <br />
objCommand.Properties("Page Size") = 2000<br />
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE <br />
Set objRecordSet = objCommand.Execute<br />
objRecordSet.MoveFirst<br />
Err.Clear<br />
<br />
Set FSO = CreateObject("Scripting.FileSystemObject")<br />
Set objFile = FSO.CreateTextFile("Workfile.txt", True)<br />
objFile.Close<br />
Set objFile = FSO.OpenTextFile("Workfile.txt", ForWriting)<br />
<br />
<br />
Do Until objRecordSet.EOF<br />
<br />
    objFile.WriteLine objRecordSet.Fields("Name").Value<br />
    objRecordSet.MoveNext<br />
Loop<br />
objFile.Close<br />
<br />
Do<br />
strCompsLeft = 0<br />
Set objFSO = CreateObject("Scripting.FileSystemObject")<br />
Set objTextFile = objFSO.OpenTextFile("Workfile.txt", ForReading)<br />
<br />
Set objFSO2 = CreateObject("Scripting.FileSystemObject")<br />
Set objTextFile2 = objFSO2.CreateTextFile("Workfile2.txt", True)<br />
objTextFile2.Close<br />
<br />
Do Until objTextFile.AtEndOfStream<br />
    strComputer = objTextFile.Readline<br />
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")<br />
    If Err.Number = 0 Then<br />
      Wscript.Echo Chr(10) & Chr(13) & strComputer & ": "<br />
      If ArrFilename(0) = "*" Then<br />
        Set colFiles = objWMIService.ExecQuery ("Select * From CIM_DataFile Where Extension = '" & ArrFilename(1) & "'")<br />
      ElseIf ArrFilename(1) = "*" Then<br />
        Set colFiles = objWMIService.ExecQuery ("Select * From CIM_DataFile Where FileName = '" & ArrFilename(0) & "'") <br />
      Else<br />
        Set colFiles = objWMIService.ExecQuery ("Select * From CIM_DataFile Where FileName = '" & ArrFilename(0) & "' and Extension = '" & ArrFilename(1) & "'")<br />
      End If<br />
      For Each objFile in colFiles<br />
        Wscript.Echo objFile.Name<br />
      Next<br />
    Else<br />
      Set objTextFile2 = objFSO2.OpenTextFile("Workfile2.txt", ForWriting)<br />
      objTextFile2.WriteLine strComputer<br />
      obj.TextFile2.Close<br />
      Err.Clear<br />
      strCompsLeft = strCompsLeft + 1<br />
    End If<br />
Loop<br />
objTextFile.Close<br />
<br />
objFSO.DeleteFile("Workfile.txt")<br />
<br />
Set objFile = FSO.CreateTextFile("Workfile.txt", True)<br />
objFile.Close<br />
Set objFile = FSO.OpenTextFile("Workfile.txt", ForWriting)<br />
Set objTextFile2 = objFSO2.OpenTextFile("Workfile2.txt", ForReading)<br />
Do Until objTextFile2.AtEndOfStream<br />
  strTextLine = objTextFile2.Readline<br />
  objFile.WriteLine strTextLine<br />
Loop<br />
objFile.Close<br />
objTextFile2.Close<br />
Set objFSO = CreateObject("Scripting.FileSystemObject")<br />
objFSO.DeleteFile("Workfile2.txt")<br />
Wscript.Echo "Computers left: " & strCompsLeft<br />
Loop]]></description>
 <category>General</category>
<comments>http://jar.yosephine.com/index.php?itemid=5</comments>
 <pubDate>Mon, 25 May 2009 10:20:02 -0400</pubDate>
</item><item>
 <title>First post</title>
 <link>http://jar.yosephine.com/index.php?itemid=3</link>
<description><![CDATA[Just installed Nucleus. I haven't got any experience in this, nor other CMS:es so it will be interesting to see what this will become. I'll probably get stuck while trying to get this CMS to do something exactly as I want instead of settling for what the system can do without major efforts.]]></description>
 <category>General</category>
<comments>http://jar.yosephine.com/index.php?itemid=3</comments>
 <pubDate>Mon, 25 May 2009 09:55:56 -0400</pubDate>
</item><item>
 <title>Welcome to Nucleus CMS v3.3</title>
 <link>http://jar.yosephine.com/index.php?itemid=1</link>
<description><![CDATA[This is the first post on your Nucleus CMS. Nucleus offers you the building blocks you need to create a web presence. Whether you want to create a personal blog, a family page, or an online business site, Nucleus CMS can help you achieve your goals.<br />
<br />
We've loaded this first entry with links and information to get you started. Though you can delete this entry, it will eventually scroll off the main page as you add content to your site. Add your comments while you learn to work with Nucleus CMS, or bookmark this page so you can come back to it when you need to.<b>Home - <a href="http://nucleuscms.org/" title="Nucleus CMS home">nucleuscms.org</a></b><br />
Welcome to the world of Nucleus CMS. In 2001 a set of PHP scripts were let loose on the open Internet. Those scripts, which took user-generated data and used it to dynamically create html pages, contained the ideas and the algorithms that are the core of todayÃ¢â‚¬â„¢s Nucleus CMS. Though Nucleus CMS 3.3 is far more flexible and powerful than the scripts from which it emerged, it still expresses the values that guided its birth: flexibility, security, and computational elegance.<br />
<br />
Thanks to an international community of sophisticated developers and designers, Nucleus CMS remains simple enough for anyone to learn, and expandable enough to allow you to build almost any website you can imagine. Nucleus CMS lets you integrate text, images, and user comments in a seamless package that will make your web presence as serious, professional, personal, or fun as you want it to be. We hope you enjoy its power.<br />
<br />
<b>Documentation - <a href="http://docs.nucleuscms.org/" title="Nucleus CMS Documentation">docs.nucleuscms.org</a></b><br />
The install process places a <a href="nucleus/documentation/">user</a> and a <a href="nucleus/documentation/devdocs/">developer</a> documentation on your web server. Pop-up <a href="/nucleus/documentation/help.html">help</a> is available throughout the administration area to assist you in maintaining and customizing your site. When in the Nucleus CMS admin area, click on this symbol <img src="nucleus/documentation/icon-help.gif" width="15" height="15" alt="help icon" /> for context-sensitive help. You can also read this documentation online under <a href="http://docs.nucleuscms.org/" title="Nucleus CMS Documentation">docs.nucleuscms.org</a>.<br />
<br />
<b>Frequently Asked Questions - <a nicetitle="Nucleus CMS FAQ" href="http://faq.nucleuscms.org/">faq.nucleuscms.org</a></b><br />
If you need more information about managing, extending or troubleshooting your Nucleus CMS the Nucleus FAQ is the first place to search information. Over 170 frequently asked questions are answered from experienced Nucleus users.<br />
<br />
<b>Support - <a href="http://forum.nucleuscms.org/" title="Nucleus CMS Support Forum">forum.nucleuscms.org</a></b><br />
Should you require assistance, please don't hesitate to <a href="http://forum.nucleuscms.org/faq.php">join</a> the 6,800+ registered users on our forums. With its built-in search capability of the 73,000+ posted articles, your answers are just a few clicks away. Remember: almost any question you think of has already been asked on the forums, and almost anything you want to do with Nucleus has been tried and explained there. Be sure to check them out.<br />
<br />
<b>Demonstration - <a href="http://demo.nucleuscms.org/" title="Nucleus CMS Demonstration">demo.nucleuscms.org</a></b><br />
Want to play around, test changes or tell a friend or relative about Nucleus CMS? Visit our live <a href="http://demo.nucleuscms.org/">demo site</a>.<br />
<br />
<b>Skins - <a href="http://skins.nucleuscms.org/" title="Nucleus CMS Skins">skins.nucleuscms.org</a></b><br />
The combination of multi-weblogs and skins/templates make for a powerful duo in personalizing your site or designing one for a friend, relative or business client. Import new skins to change the look of your website, or create your own skins and share them with the Nucleus community! Help designing or modifying skins is only a few clicks away in the Nucleus forums.<br />
<br />
<b>Plugins - <a href="http://plugins.nucleuscms.org/" title="Nucleus plugins">plugins.nucleuscms.org</a></b><br />
Looking to add some extra functionality to the base Nucleus CMS package? Our <a href="http://wiki.nucleuscms.org/plugin">plugin repository</a> gives you plenty of ways to extend and expand what Nucleus CMS can do; your imagination and creativity are the only limit on how Nucleus CMS can work for you.<br />
<br />
<b>Development - <a href="http://dev.nucleuscms.org/" title="Nucleus Development">dev.nucleuscms.org</a></b><br />
If you need more information about the Nucleus development you can find Informations in the developer documents at <a href="http://dev.nucleuscms.org/" title="Nucleus Development">dev.nucleuscms.org</a> or in the <a href="http://forum.nucleuscms.org/">Support Forum</a>. Sourceforge.net graciously hosts our <a href="http://sourceforge.net/projects/nucleuscms/">Open Source project page</a> which contains our software downloads and CVS repository.<br />
<br />
<b>Donators</b><br />
We would like to thank these <a href="http://nucleuscms.org/donators.php">nice people</a> for their <a href="http://nucleuscms.org/donate.php">support</a>. <em>Thanks all!</em><br />
<br />
<b>Vote for Nucleus CMS</b><br />
Like Nucleus CMS? Vote for us at <a href="http://www.hotscripts.com/Detailed/13368.html?RID=nucleus@demuynck.org">HotScripts</a> and <a href="http://www.opensourcecms.com/index.php?option=content&task=view&id=145">opensourceCMS</a>.<br />
<br />
<b>License</b><br />
When we speak of free software, we are referring to freedom, not price. Our <a href="http://www.gnu.org/licenses/gpl.html">General Public Licenses</a> are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things.]]></description>
 <category>General</category>
<comments>http://jar.yosephine.com/index.php?itemid=1</comments>
 <pubDate>Mon, 25 May 2009 09:51:51 -0400</pubDate>
</item>
  </channel>
</rss>