<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>cluberti.com &#187; Scripts</title>
	<atom:link href="http://www.cluberti.com/blog/category/scripts/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cluberti.com/blog</link>
	<description>Random bits of flair pinned to the internet</description>
	<lastBuildDate>Fri, 06 Jan 2012 03:26:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Windows 7 SP1 language packs and MDT 2010 giving errors?</title>
		<link>http://www.cluberti.com/blog/2011/03/12/windows-7-sp1-language-packs-and-mdt-2010-giving-errors/</link>
		<comments>http://www.cluberti.com/blog/2011/03/12/windows-7-sp1-language-packs-and-mdt-2010-giving-errors/#comments</comments>
		<pubDate>Sun, 13 Mar 2011 04:19:26 +0000</pubDate>
		<dc:creator>cluberti</dc:creator>
				<category><![CDATA[Deployment]]></category>
		<category><![CDATA[MDT]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.cluberti.com/blog/?p=168</guid>
		<description><![CDATA[Seems like Microsoft changed the name of the Language Packs from &#8220;Microsoft-Windows-Client-LanguagePack-Package&#8221; to &#8220;Microsoft-Windows-Client-Refresh-LanguagePack-Package&#8221;.  A small distinction, but huge when MDT or SCCM can&#8217;t find the language pack name!  In MDT, go to the DeploymentShare&#8217;s \Scripts folder, edit &#8220;Deploywiz_Initialization.vbs&#8221;, and go down to line 1101 &#8211; you&#8217;ll see that LPQuery is set to look for [...]]]></description>
			<content:encoded><![CDATA[<p>Seems like Microsoft changed the name of the Language Packs from &#8220;Microsoft-Windows-Client-LanguagePack-Package&#8221; to &#8220;Microsoft-Windows-Client-Refresh-LanguagePack-Package&#8221;.  A small distinction, but huge when MDT or SCCM can&#8217;t find the language pack name!  In MDT, go to the DeploymentShare&#8217;s \Scripts folder, edit &#8220;Deploywiz_Initialization.vbs&#8221;, and go down to line 1101 &#8211; you&#8217;ll see that LPQuery is set to look for only the old Language Pack package name.  Add the new package name, and things will work again (you will have to update any media you&#8217;ve created, of course).</p>
<p>I found this while searching TechNet, here:<br />
<a href="http://social.technet.microsoft.com/Forums/en-US/mdt/thread/5253b2e3-a60e-43a5-921d-a9acc6485d35">http://social.technet.microsoft.com/Forums/en-US/mdt/thread/5253b2e3-a60e-43a5-921d-a9acc6485d35</a></p>
<p>The change should have line 1101 looking like this when you&#8217;re done:<br />
<span style="font-style: italic;">LPQuery = &#8220;PackageType = &#8216;LanguagePack&#8217; and (ProductName = &#8216;Microsoft-Windows-Client-LanguagePack-Package&#8217; or ProductName = &#8216;Microsoft-Windows-Client-Refresh-LanguagePack-Package&#8217;) and substring(ProductVersion,1,7) = &#8216;&#8221; &amp; left(ImgBuild,7) &amp; &#8220;&#8216; and substring(ProductVersion,5,4) &gt;= &#8216;&#8221; &amp; mid(ImgBuild,5,4) &amp; &#8220;&#8216;&#8221;</span></p>
<!-- AdSense Now! V2.00 -->
<!-- Post[count: 2] -->
<div class="adsense adsense-leadout" style="text-align:center;margin: 12px;"> <!-- Begin BidVertiser code -->
<SCRIPT LANGUAGE="JavaScript1.1" SRC="http://bdv.bidvertiser.com/BidVertiser.dbm?pid=229404&bid=854878" type="text/javascript"></SCRIPT>
<noscript><a href="http://www.bidvertiser.com">affiliate program</a></noscript>
<!-- End BidVertiser code --> </div>]]></content:encoded>
			<wfw:commentRss>http://www.cluberti.com/blog/2011/03/12/windows-7-sp1-language-packs-and-mdt-2010-giving-errors/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Debian + Sendmail + SpamAssassin + MimeDefang config for inbound mail host</title>
		<link>http://www.cluberti.com/blog/2010/11/18/debian-sendmail-spamassassin-mimedefang-config-for-inbound-mail-host/</link>
		<comments>http://www.cluberti.com/blog/2010/11/18/debian-sendmail-spamassassin-mimedefang-config-for-inbound-mail-host/#comments</comments>
		<pubDate>Fri, 19 Nov 2010 01:48:44 +0000</pubDate>
		<dc:creator>cluberti</dc:creator>
				<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://www.cluberti.com/blog/?p=154</guid>
		<description><![CDATA[Honestly, this is more of an &#8220;I&#8217;m posting this here for my reference&#8221; post than anything else, but searching google and bing for something similar yesterday (which is prompting me to put this here) came up with old, outdated, and frankly useless, results (at least in my opinion). I&#8217;m not going to go into how [...]]]></description>
			<content:encoded><![CDATA[<p>Honestly, this is more of an &#8220;I&#8217;m posting this here for my reference&#8221; post than anything else, but searching google and bing for something similar yesterday (which is prompting me to put this here) came up with old, outdated, and frankly useless, results (at least in my opinion).</p>
<p>I&#8217;m not going to go into how to install Debian or software (honestly, running &#8220;apt-get install sendmail spamassassin mimedefang&#8221; can&#8217;t be that hard), but I have this sendmail.mc on my current Debian Lenny installation, and it deals with spam and ham with very good results:</p>
<pre class="brush: plain; title: ; notranslate">divert(-1)dnl
# /etc/mail/sendmail.mc
# Last modified by cluberti at 01:48 - November 18, 2010
divert(0)dnl

dnl ##########################################################################
dnl # Sendmail-specific information
dnl ##########################################################################

define(`_USE_ETC_MAIL_')dnl
include(`/usr/share/sendmail/cf/m4/cf.m4')dnl
VERSIONID(`$Id: sendmail.mc, $j Sendmail')
OSTYPE(`debian')dnl
DOMAIN(`debian-mta')dnl
dnl # Items controlled by /etc/mail/sendmail.conf - DO NOT TOUCH HERE
undefine(`confHOST_STATUS_DIRECTORY')dnl        #DAEMON_HOSTSTATS=

dnl ##########################################################################
dnl # Machine-specific section
dnl ##########################################################################

FEATURE(`no_default_msa')dnl
DAEMON_OPTIONS(`Family=inet,  Name=MTA-v4, Port=smtp, Addr=ip.ad.dr.ess')dnl
DAEMON_OPTIONS(`Family=inet,  Name=MSP-v4, Port=submission, Addr=ip.ad.dr.ess')dnl
DAEMON_OPTIONS(`Family=inet,  Name=MTA-v4, Port=smtp, Addr=127.0.0.1')dnl
DAEMON_OPTIONS(`Family=inet,  Name=MSP-v4, Port=submission, Addr=127.0.0.1')dnl

define(`confBIND_OPTS', `WorkAroundBrokenAAAA')dnl
define(`confCONNECTION_RATE_THROTTLE', `15')dnl
define(`confCONNECTION_RATE_WINDOW_SIZE',`10m')dnl
define(`confREJECT_MSG', `550 Access denied')dnl
define(`confBAD_RCPT_THROTTLE',`3')dnl

FEATURE(`access_db', , `skip')dnl
FEATURE(`greet_pause', `1000')dnl 1 seconds
FEATURE(`delay_checks', `friend', `n')dnl
FEATURE(`conncontrol', `nodelay', `terminate')dnl
FEATURE(`ratecontrol', `nodelay', `terminate')dnl
FEATURE(`nouucp', `reject')dnl

dnl ##########################################################################
dnl # User-configurable section
dnl ##########################################################################

FEATURE(`use_cw_file')dnl
FEATURE(`genericstable')dnl
GENERICS_DOMAIN_FILE(`/etc/mail/generics-domains')dnl
FEATURE(`virtusertable')dnl
FEATURE(`redirect')dnl
FEATURE(`smrsh')dnl
FEATURE(`mailertable')dnl
FEATURE(`blacklist_recipients')dnl
FEATURE(`lookupdotdomain')dnl
FEATURE(`compat_check')dnl
FEATURE(`authinfo')dnl
FEATURE(`no_default_msa')dnl

FEATURE(`always_add_domain')dnl
MASQUERADE_AS(`mail.domain.tld')dnl
FEATURE(`allmasquerade')dnl
FEATURE(`masquerade_envelope')dnl

FEATURE(`enhdnsbl', `cbl.abuseat.org', `&quot;Spam blocked see: http://cbl.abuseat.org/lookup.cgi?ip=&quot;$&amp;;{client_addr}', `t')dnl
FEATURE(`enhdnsbl', `bl.spamcop.net', `&quot;Spam blocked see: http://spamcop.net/bl.shtml?&quot;$&amp;{client_addr}', `t')dnl
FEATURE(`enhdnsbl', `zen.spamhaus.org', `&quot;Spam blocked see: http://www.spamhaus.org/query/bl?ip=&quot;$&amp;{client_addr}', `t')dnl

define(`ALIAS_FILE',`/etc/mail/aliases')dnl
define(`_QUIET_FREEWARE_')dnl
define(`confREJECT_MSG',`552 Spammer $&amp;(client_addr) $&amp;f rejected by Postmaster@$j - check_mail or check_relay')dnl
define(`confSMTP_LOGIN_MSG', mail.cluberti.com - UCE not welcome!)dnl
define(`confPRIVACY_FLAGS', `authwarnings noexpn novrfy needmailhelo needexpnhelo needvrfyhelo noreceipts ')dnl
define(`confTO_CONNECT', `2m')dnl
define(`confTO_IDENT', `0')dnl
define(`confTO_QUEUEWARN_URGENT', `29m')dnl
define(`confTO_QUEUEWARN_NORMAL', `4h')dnl
define(`confTO_QUEUEWARN_NONURGENT', `8h')dnl
define(`confTo_QUEUERETURN_URGENT', `59m')dnl
define(`confTo_QUEUERETURN_NORMAL', `8h')dnl
define(`confTo_QUEUERETURN_NONURGENT', `16h')dnl

INPUT_MAIL_FILTER(`mimedefang', `S=unix:/var/spool/MIMEDefang/mimedefang.sock, T=S:1m;R:1m')

MAILER_DEFINITIONS
MAILER(`local')dnl
MAILER(`smtp')dnl</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.cluberti.com/blog/2010/11/18/debian-sendmail-spamassassin-mimedefang-config-for-inbound-mail-host/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PageFile vbs for Vista/Win7 systems (may work on XP/2003, not tested)</title>
		<link>http://www.cluberti.com/blog/2010/06/17/pagefile-vbs-for-vistawin7-systems-may-work-on-xp2003-not-tested/</link>
		<comments>http://www.cluberti.com/blog/2010/06/17/pagefile-vbs-for-vistawin7-systems-may-work-on-xp2003-not-tested/#comments</comments>
		<pubDate>Thu, 17 Jun 2010 15:24:15 +0000</pubDate>
		<dc:creator>cluberti</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.cluberti.com/blog/?p=123</guid>
		<description><![CDATA[Wrote up a very small vbscript to handle paging file creation/deletion/modification on Vista/Win7 systems (as PageFileConfig.vbs doesn&#8217;t exist inbox, and it didn&#8217;t have the ability to handle some of the situations that can arise during setup), and it ended up morphing into this.  Figured I&#8217;d save someone the time if they had a need for [...]]]></description>
			<content:encoded><![CDATA[<p>Wrote up a very small vbscript to handle paging file creation/deletion/modification on Vista/Win7 systems (as PageFileConfig.vbs doesn&#8217;t exist inbox, and it didn&#8217;t have the ability to handle some of the situations that can arise during setup), and it ended up morphing into this.  Figured I&#8217;d save someone the time if they had a need for it, so here it is:</p>
<p><span style="font-family: Consolas;">
<pre class="brush: vb; title: ; notranslate">
'// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'//
'// NAME:        setpagefile.vbs
'//
'// Original:    http://www.cluberti.com/blog
'// Last Update: 16th June 2010
'//
'// Comment:     VBS example file for use in configuring the paging file on Windows
'//
'// NOTE:        Provided as-is - usage of this source assumes that you are at the
'//              very least familiar with the vbscript language being used and
'//              the tools used to create and debug this file.
'//
'//              In other words, if you break it, you get to keep the pieces.
'//
'// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Option Explicit
Dim strComputer, strPageFileSizeInput, strPageFileNameInput, strInput
Dim objWMIService, objStaticPageFileItem, objDynamicPageFileItem, objShellApp
Dim colStaticPageFileItems, colDynamicPageFileItems, isRunning, execOutput, gErrData, bRebootNeeded, bNoStaticPageFile, bNoPageFile

'// Ensure that cscript is the engine used to run this script:
RunMeWithCScript()

On Error Resume Next

'// Configure our variables:
strComputer = &quot;.&quot;
bRebootNeeded = False
bNoStaticPageFile = True
bNoPageFile = True

Set objShellApp = CreateObject(&quot;WScript.Shell&quot;)
Set objWMIService = GetObject(&quot;winmgmts:\\&quot; &amp; strComputer &amp; &quot;\root\CIMV2&quot;)
'// Win32_PageFile is deprecated - it still (mostly) works, but Win32_PageFileSetting is not deprecated, so use that:
Set colStaticPageFileItems = objWMIService.ExecQuery(&quot;SELECT * FROM Win32_PageFileSetting&quot;,,48)
Set colDynamicPageFileItems = objWMIService.ExecQuery(&quot;SELECT * FROM Win32_PageFileUsage&quot;,,48)

'// Execute the ChangePagingFile sub:
ChangePagingFile()

'// Check execution of ChangePagingFile(), and handle when &quot;system managed&quot; is set, or no paging file exists:
If bRebootNeeded = True Then
    RebootSystem()
Else
    '// Can't use WMI to create a paging file when it is &quot;system managed&quot; or none exists - handle this condition:
    If bNoStaticPageFile = True Then
        CheckForDynamicPagingFile()
        If bNoPageFile = False Then
            WScript.Quit
        Else
            If bNoPageFile = True Then
                WScript.Echo &quot;No paging file found.&quot;
                WScript.Echo &quot;&quot;
                strPageFileNameInput = UserInput(&quot;Enter new pagefile name (full path and filename) - leave blank to use C:\pagefile.sys: &quot;)
                strPageFileSizeInput = UserInput(&quot;Enter new pagefile size (in MB) - leave blank to keep the system with no paging file:  &quot;)
               
                '// Check to see if the user left the input blank, otherwise set up a paging file:
                If Not strPageFileSizeInput = &quot;&quot; Then
                    If strPageFileNameInput = &quot;&quot; Then
                        strPageFileNameInput = &quot;C:\pagefile.sys&quot;
                    End If
                    WScript.Echo &quot;New pagefile file will be: &quot; &amp; strPageFileNameInput
                    WScript.Echo &quot;New pagefile size will be: &quot; &amp; strPageFileSizeInput &amp; &quot;MB&quot;
                    bNoStaticPageFile = False
                   
                    '// Change the registry to add paging file information:
                    objShellApp.Exec(&quot;reg add &quot;&quot;HKLM\System\CurrentControlSet\Control\Session Manager\Memory Management&quot;&quot; /v PagingFiles /t REG_MULTI_SZ /d &quot;&quot;&quot; &amp; strPageFileNameInput &amp; &quot; &quot; &amp; strPageFileSizeInput &amp; &quot; &quot; &amp; strPageFileSizeInput &amp; &quot;&quot;&quot; /f&quot;)
                   
                    '// Check the return to make sure we succeeded - otherwise, tell the user why we didn't:
                    If Not Err.Number = 0 Then
                        gErrData = gErrData &amp; vbCrLf &amp; &quot;Error writing to registry - reason: &quot; &amp; Err.Number &amp; &quot;  - &quot; &amp; Err.Description
                        WScript.Echo gErrData
                        Err.Clear
                    Else
                        WScript.Echo &quot;Registry edit to add &quot; &amp; strPageFileNameInput &amp; &quot; as size &quot; &amp; strPageFileSizeInput &amp; &quot;MB was successful.&quot;
                        bRebootNeeded = True
                    End If
               
                '// If we've made changes that have succeeded, we need to reboot - otherwise, do nothing:
                    If bRebootNeeded = True Then
                        RebootSystem()
                    Else
                        WScript.Echo &quot;No changes made that require a reboot.  Exiting script.&quot;
                    End If
                Else
                    WScript.Echo &quot;You have elected to continue with no paging file.  Exiting script.&quot;
                End If
            Else
                WScript.Echo &quot;No changes made that require a reboot.  Exiting script.&quot;
            End If
        End If
    End If
End If
Sub ChangePagingFile()
    For Each objStaticPageFileItem In colStaticPageFileItems
        '// There's a static paging file - use WMI to make changes:
        bNoStaticPageFile = False
        bNoPageFile = False
       
        WScript.Echo &quot; --------------------------&quot;
        WScript.Echo &quot;  Current PageFile Details&quot;
        WScript.Echo &quot; --------------------------&quot;
        WScript.Echo &quot;Name:                &quot; &amp; objStaticPageFileItem.Name
        WScript.Echo &quot;InitialSize:         &quot; &amp; objStaticPageFileItem.InitialSize
        WScript.Echo &quot;MaximumSize:         &quot; &amp; objStaticPageFileItem.MaximumSize
        WScript.Echo &quot;&quot;
       
        '// Get user input:
        strInput = UserInput(&quot;Enter new pagefile size (in MB) - leave blank to delete existing paging file: &quot;)
       
        '// If the user entered a value, configure the new paging file size:
        If Not strInput = &quot;&quot; Then
        WScript.Echo &quot;New pagefile size will be: &quot; &amp; strInput &amp; &quot;MB&quot;
            WScript.Echo &quot;&quot;
           
            objStaticPageFileItem.InitialSize = strInput
            objStaticPageFileItem.MaximumSize = strInput
            objStaticPageFileItem.Put_
            bRebootNeeded = True
           
            WScript.Echo &quot; --------------------------&quot;
            WScript.Echo &quot;    New PageFile Details&quot;
            WScript.Echo &quot; --------------------------&quot;
            WScript.Echo &quot;Name:                &quot; &amp; objStaticPageFileItem.Name
            WScript.Echo &quot;InitialSize:         &quot; &amp; objStaticPageFileItem.InitialSize
            WScript.Echo &quot;MaximumSize:         &quot; &amp; objStaticPageFileItem.MaximumSize
            WScript.Echo &quot;&quot;
            WScript.Echo &quot;A reboot is needed for this change to take effect.&quot;
       
        '// If the user left the input blank, delete the paging file - note that Delete and DeleteEx from Win32_PagingFile are deprecated, and
        '// while they'll return 0 on Windows 7, they don't actually delete the paging file.  Using reg add instead, as it works just fine:
        Else
            WScript.Echo &quot;Deleting paging file: &quot; &amp; objStaticPageFileItem.Name
            objShellApp.Exec(&quot;reg add &quot;&quot;HKLM\System\CurrentControlSet\Control\Session Manager\Memory Management&quot;&quot; /v PagingFiles /t REG_MULTI_SZ /d &quot;&quot;&quot;&quot; /f&quot;)
           
            '// Check the return to make sure we succeeded - otherwise, tell the user why we didn't:
            If Not Err.Number = 0 Then
                gErrData = gErrData &amp; vbCrLf &amp; &quot;Error writing to registry - reason: &quot; &amp; Err.Number &amp; &quot;  - &quot; &amp; Err.Description
                WScript.Echo gErrData
                Err.Clear
            Else
                WScript.Echo &quot;Registry edit to remove &quot; &amp; objStaticPageFileItem.Name &amp; &quot; was successful.&quot;
                bRebootNeeded = True
            End If
        End If
    Next
End Sub
Sub CheckForDynamicPagingFile()
    For Each objDynamicPageFileItem In colDynamicPageFileItems
        '// There's a paging file - use WMI to make changes:
        bNoPageFile = False
       
        WScript.Echo &quot;Paging file is configured for 'System managed size'&quot;
        WScript.Echo &quot;&quot;

        WScript.Echo &quot; --------------------------&quot;
        WScript.Echo &quot;  Current PageFile Details&quot;
        WScript.Echo &quot; --------------------------&quot;
        WScript.Echo &quot;Name:                &quot; &amp; objDynamicPageFileItem.Name
        WScript.Echo &quot;Size:                &quot; &amp; objDynamicPageFileItem.AllocatedBaseSize
        WScript.Echo &quot;Current Usage:       &quot; &amp; objDynamicPageFileItem.CurrentUsage
        WScript.Echo &quot;&quot;
       
        WScript.Echo &quot;&quot;
        strPageFileNameInput = UserInput(&quot;Enter new pagefile name (full path and filename) - leave blank to use C:\pagefile.sys: &quot;)
        strPageFileSizeInput = UserInput(&quot;Enter new pagefile size (in MB) - leave blank to remove the paging file:               &quot;)
       
        '// Check to see if the user left the input blank, otherwise set up a paging file:
        If Not strPageFileSizeInput = &quot;&quot; Then
            If strPageFileNameInput = &quot;&quot; Then
                strPageFileNameInput = &quot;C:\pagefile.sys&quot;
            End If
            WScript.Echo &quot;New pagefile file will be: &quot; &amp; strPageFileNameInput
            WScript.Echo &quot;New pagefile size will be: &quot; &amp; strPageFileSizeInput &amp; &quot;MB&quot;
            bNoStaticPageFile = False
           
            '// Change the registry to add paging file information:
            objShellApp.Exec(&quot;reg add &quot;&quot;HKLM\System\CurrentControlSet\Control\Session Manager\Memory Management&quot;&quot; /v PagingFiles /t REG_MULTI_SZ /d &quot;&quot;&quot; &amp; strPageFileNameInput &amp; &quot; &quot; &amp; strPageFileSizeInput &amp; &quot; &quot; &amp; strPageFileSizeInput &amp; &quot;&quot;&quot; /f&quot;)
               
                '// Check the return to make sure we succeeded - otherwise, tell the user why we didn't:
                If Not Err.Number = 0 Then
                    gErrData = gErrData &amp; vbCrLf &amp; &quot;Error writing to registry - reason: &quot; &amp; Err.Number &amp; &quot;  - &quot; &amp; Err.Description
                    WScript.Echo gErrData
                    Err.Clear
                Else
                    WScript.Echo &quot;Registry edit to add &quot; &amp; strPageFileNameInput &amp; &quot; as size &quot; &amp; strPageFileSizeInput &amp; &quot;MB was successful.&quot;
                    bRebootNeeded = True
                End If
           
            '// If we've made changes that have succeeded, we need to reboot - otherwise, do nothing:
            If bRebootNeeded = True Then
                RebootSystem()
                WScript.Quit
            Else
                WScript.Echo &quot;No changes made that require a reboot.  Exiting script.&quot;
                WScript.Quit
            End If
       
        '// If the user left the input blank, delete the paging file - note that Delete and DeleteEx from Win32_PagingFile are deprecated, and
        '// while they'll return 0 on Windows 7, they don't actually delete the paging file.  Using reg add instead, as it works just fine:
        Else
            WScript.Echo &quot;Deleting paging file: &quot; &amp; objDynamicPageFileItem.Name
            objShellApp.Exec(&quot;reg add &quot;&quot;HKLM\System\CurrentControlSet\Control\Session Manager\Memory Management&quot;&quot; /v PagingFiles /t REG_MULTI_SZ /d &quot;&quot;&quot;&quot; /f&quot;)
           
            '// Check the return to make sure we succeeded - otherwise, tell the user why we didn't:
            If Not Err.Number = 0 Then
                gErrData = gErrData &amp; vbCrLf &amp; &quot;Error writing to registry - reason: &quot; &amp; Err.Number &amp; &quot;  - &quot; &amp; Err.Description
                WScript.Echo gErrData
                Err.Clear
            Else
                WScript.Echo &quot;Registry edit to remove &quot; &amp; objDynamicPageFileItem.Name &amp; &quot; was successful.&quot;
                bRebootNeeded = True
            End If
        End If
    Next
End Sub
Sub RebootSystem()
    WScript.Echo &quot;The system will reboot in 5 seconds...&quot;
    Set isRunning = objShellApp.Exec(&quot;shutdown /r /t 5 /f /d p:2:4&quot;)
    '// As long as shutdown.exe is running, wait:
    Do While isRunning.Status = 0
        WScript.Sleep 100
        execOutput = isRunning.StdOut.ReadAll
    Loop
End Sub
Function UserInput(strInput)
    WScript.StdOut.Write strInput &amp; &quot; &quot;
    UserInput = WScript.StdIn.ReadLine
End Function
On Error GoTo 0
Sub RunMeWithCScript()
    Dim ScriptEngine, engineFolder, Args, arg, scriptName, argString, scriptCommand
   
    ScriptEngine = UCase(Mid(WScript.FullName, InstrRev(WScript.FullName, &quot;\&quot;) + 1))
    engineFolder = Left(WScript.FullName, InstrRev(WScript.FullName, &quot;\&quot;))
    argString = &quot;&quot;
   
    If ScriptEngine = &quot;WSCRIPT.EXE&quot; Then
        Dim Shell
        Set Shell = CreateObject(&quot;WScript.Shell&quot;)
        Set Args = WScript.Arguments
       
        For Each arg in Args
            If InStr(arg, &quot; &quot;) &gt; 0 Then arg = &quot;&quot;&quot;&quot; &amp; arg &amp; &quot;&quot;&quot;&quot;
            argString = argString &amp; &quot; &quot; &amp; Arg
        Next
       
        scriptCommand = &quot;cmd.exe /k &quot; &amp; engineFolder &amp; &quot;cscript.exe &quot;&quot;&quot; &amp; WScript.ScriptFullName &amp; &quot;&quot;&quot;&quot; &amp; argString
       
        Shell.Run scriptCommand, , False
        WScript.Quit
    Else
        Exit Sub
    End If
End Sub
</pre>
<p> </p>
<p></span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.cluberti.com/blog/2010/06/17/pagefile-vbs-for-vistawin7-systems-may-work-on-xp2003-not-tested/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Computer Info VBScript</title>
		<link>http://www.cluberti.com/blog/2009/12/26/computer-info-vbscript/</link>
		<comments>http://www.cluberti.com/blog/2009/12/26/computer-info-vbscript/#comments</comments>
		<pubDate>Sun, 27 Dec 2009 04:17:46 +0000</pubDate>
		<dc:creator>cluberti</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.cluberti.com/blog/2009/12/26/computer-info-vbscript/</guid>
		<description><![CDATA[EDIT 9th January 2010 &#8211; the script has gone a fairly major revision due to changes in the Office 2010 product key storage location, as well as migrating this to a class-based script for speed. Again, another side project – a computer info VBScript. I’ve modified it a bit to output information to screen (execute [...]]]></description>
			<content:encoded><![CDATA[<p>EDIT 9th January 2010 &#8211; the script has gone a fairly major revision due to changes in the Office 2010 product key storage location, as well as migrating this to a class-based script for speed.</p>
<p>Again, another side project – a computer info VBScript.  I’ve modified it a bit to output information to screen (execute with cscript from a cmd prompt), but this could be modified to do a lot more.  This is just a simple script template, and as usual I’m posting here for consumption in the event anyone finds this useful:</p>
<pre class="brush: vb; title: ; notranslate">
'// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'//
'// NAME:        osinfo.vbs
'//
'// Original:    http://www.cluberti.com/blog
'// Last Update: 15th January 2010
'//
'// Comment:     VBS example file for use as an OS info gathering template.
'//
'// NOTE:        Provided as-is - usage of this source assumes that you are at the
'//              very least familiar with the vbscript language being used and
'//              the tools used to create and debug this file.
'//
'//              In other words, if you break it, you get to keep the pieces.
'//
'//              Also, if you want to use this on W2K, prepare to hack, as this
'//              was really designed with XP+ systems in mind.
'//
'// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

'//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'//
'// This script will require elevated privileges if run from a non-admin account, so
'// calling the ElevateThisScript() Sub should get the script a full admin token. This is
'// currently disabled, but if you need non-admin users to run this script, enable the
'// call to this subroutine to pop-up a dialog box (they'll of course need administrative
'// credentials to put in the challenge dialog before the script will execute with an
'// administrative token):

Dim ScriptHelper
Set ScriptHelper = New ScriptHelperClass

ScriptHelper.RunMeWithCScript()
'ScriptHelper.ElevateThisScript()

'//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'//
'// Set variables and WMI connections for scripting against:

strComputer = ScriptHelper.Network.ComputerName

CONST HKEY_CLASSES_ROOT  = &amp;H80000000
CONST HKEY_CURRENT_USER  = &amp;H80000001
CONST HKEY_LOCAL_MACHINE = &amp;H80000002
CONST HKEY_USERS         = &amp;H80000003
CONST KEY_QUERY_VALUE      = 1
CONST KEY_SET_VALUE          = 2
CONST SEARCH_KEY = &quot;DigitalProductID&quot;

Dim arrSubKeys(4,1)
Dim foundKeys
Dim iValues, arrDPID
foundKeys = Array()
iValues = Array()
arrSubKeys(0,0) = &quot;Windows PID Key:       &quot;
arrSubKeys(0,1) = &quot;SOFTWARE\Microsoft\Windows NT\CurrentVersion&quot;
arrSubKeys(2,0) = &quot;Office XP PID Key:     &quot;
arrSubKeys(2,1) = &quot;SOFTWARE\Microsoft\Office\10.0\Registration&quot;
arrSubKeys(1,0) = &quot;Office 2003 PID Key:   &quot;
arrSubKeys(1,1) = &quot;SOFTWARE\Microsoft\Office\11.0\Registration&quot;
arrSubKeys(3,0) = &quot;Office 2007 PID Key:   &quot;
arrSubKeys(3,1) = &quot;SOFTWARE\Microsoft\Office\12.0\Registration&quot;
arrSubKeys(4,0) = &quot;Office 2010 PID Key:   &quot;

Arch = &quot;&quot;
Sku = &quot;&quot;

Set colOSItems = ScriptHelper.WMI.ExecQuery( _
    &quot;SELECT * FROM Win32_OperatingSystem&quot;,,48)

Set colProcItems = ScriptHelper.WMI.ExecQuery( _
    &quot;SELECT * FROM Win32_Processor&quot;,,48)

Set colCompSysItems = ScriptHelper.WMI.ExecQuery( _
    &quot;SELECT * FROM Win32_ComputerSystem&quot;,,48)

Set colTZItems = ScriptHelper.WMI.ExecQuery( _
    &quot;SELECT * FROM Win32_TimeZone&quot;,,48)

Set colCompSysProdItems = ScriptHelper.WMI.ExecQuery( _
    &quot;SELECT * FROM Win32_ComputerSystemProduct&quot;,,48)

Set colBIOSItems = ScriptHelper.WMI.ExecQuery( _
    &quot;SELECT * FROM Win32_BIOS&quot;,,48)

Set colDiskItems = ScriptHelper.WMI.ExecQuery( _
    &quot;SELECT * FROM Win32_LogicalDisk&quot;,,48)

Set colNetAdapConfigItems = ScriptHelper.WMI.ExecQuery( _
    &quot;SELECT * FROM Win32_NetworkAdapterConfiguration&quot;,,48)

Set colVideoItems = ScriptHelper.WMI.ExecQuery( _
    &quot;SELECT * FROM Win32_VideoController&quot;,,48)

Set colSoundItems = ScriptHelper.WMI.ExecQuery( _
    &quot;SELECT * FROM Win32_SoundDevice&quot;,,48)

'//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'//
'// If Office 2010 is installed, find the Office 2010 registry key holding the ProductID:

Dim strKey, subkey, arrSubkeys2, strOfficeKey, strValue
strKey = &quot;SOFTWARE\Microsoft\Office\14.0\Registration&quot;

ScriptHelper.Registry.EnumKey HKEY_LOCAL_MACHINE, strKey, arrSubkeys2
If IsNull(arrSubkeys2) Then
    'Office 2010 not installed, skip it
    arrSubKeys(4,1) = &quot;&quot;
Else
    For Each subkey In arrSubkeys2
        ScriptHelper.Registry.GetBinaryValue HKEY_LOCAL_MACHINE, strKey &amp; &quot;\&quot; &amp; subkey, SEARCH_KEY, strValue
        If IsNull(strValue) Then
            strOfficeKey = &quot;&quot;
        Else
            strOfficeKey = strKey &amp; &quot;\&quot; &amp; subkey
            arrSubKeys(4,1) = strOfficeKey
        End If
    Next
End If

'//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'//
'// Get OS SKU from Win32_OperatingSystem class:

    For Each objOSItem in colOSItems
    If objOSItem.BuildNumber =&gt; 6000 Then
        Arch = objOSItem.OSArchitecture

        Select Case objOSItem.OperatingSystemSKU
            Case 0 Sku = &quot;Unknown Windows version&quot;
            Case 1 Sku = &quot;Ultimate Edition&quot;
            Case 2 Sku = &quot;Home Basic Edition&quot;
            Case 3 Sku = &quot;Home Premium Edition&quot;
            Case 4 Sku = &quot;Enterprise Edition&quot;
            Case 5 Sku = &quot;Home Basic N Edition&quot;
            Case 6 Sku = &quot;Business Edition&quot;
            Case 7 Sku = &quot;Standard Server Edition&quot;
            Case 8 Sku = &quot;Datacenter Server Edition&quot;
            Case 9 Sku = &quot;Small Business Server Edition&quot;
            Case 10 Sku = &quot;Enterprise Server Edition&quot;
            Case 11 Sku = &quot;Starter Edition&quot;
            Case 12 Sku = &quot;Datacenter Server Core Edition&quot;
            Case 13 Sku = &quot;Standard Server Core Edition&quot;
            Case 14 Sku = &quot;Enterprise Server Core Edition&quot;
            Case 15 Sku = &quot;Enterprise Server Edition for Itanium-Based Systems&quot;
            Case 16 Sku = &quot;Business N Edition&quot;
            Case 17 Sku = &quot;Web Server Edition&quot;
            Case 18 Sku = &quot;Cluster Server Edition&quot;
            Case 19 Sku = &quot;Home Server Edition&quot;
            Case 20 Sku = &quot;Storage Express Server Edition&quot;
            Case 21 Sku = &quot;Storage Standard Server Edition&quot;
            Case 22 Sku = &quot;Storage Workgroup Server Edition&quot;
            Case 23 Sku = &quot;Storage Enterprise Server Edition&quot;
            Case 24 Sku = &quot;Server For Small Business Edition&quot;
            Case 25 Sku = &quot;Small Business Server Premium Edition&quot;
            Case Else
            Sku = &quot;Could Not Determine Operating System SKU&quot;
        End Select
    End If

'//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'//
'// Get current OS locale setting from Win32_OperatingSystem class:

        Select Case objOSItem.Locale
            Case 0436 Locale = &quot;Afrikaans (South Africa)&quot;
            Case 041c Locale = &quot;Albanian (Albania)&quot;
            ' Case 045e Locale = &quot;Amharic (Ethiopia)&quot;
            Case 0401 Locale = &quot;Arabic (Saudi Arabia)&quot;
            Case 1401 Locale = &quot;Arabic (Algeria)&quot;
            Case 3c01 Locale = &quot;Arabic (Bahrain)&quot;
            Case 0c01 Locale = &quot;Arabic (Egypt)&quot;
            Case 0801 Locale = &quot;Arabic (Iraq)&quot;
            Case 2c01 Locale = &quot;Arabic (Jordan)&quot;
            Case 3401 Locale = &quot;Arabic (Kuwait)&quot;
            Case 3001 Locale = &quot;Arabic (Lebanon)&quot;
            Case 1001 Locale = &quot;Arabic (Libya)&quot;
            Case 1801 Locale = &quot;Arabic (Morocco)&quot;
            Case 2001 Locale = &quot;Arabic (Oman)&quot;
            Case 4001 Locale = &quot;Arabic (Qatar)&quot;
            Case 2801 Locale = &quot;Arabic (Syria)&quot;
            Case 1c01 Locale = &quot;Arabic (Tunisia)&quot;
            Case 3801 Locale = &quot;Arabic (U.A.E.)&quot;
            Case 2401 Locale = &quot;Arabic (Yemen)&quot;
            Case 042b Locale = &quot;Armenian (Armenia)&quot;
            Case 044d Locale = &quot;Assamese&quot;
            Case 082c Locale = &quot;Azeri (Cyrillic)&quot;
            Case 042c Locale = &quot;Azeri (Latin)&quot;
            Case 042d Locale = &quot;Basque&quot;
            Case 0423 Locale = &quot;Belarusian&quot;
            Case 0445 Locale = &quot;Bengali (India)&quot;
            Case 0845 Locale = &quot;Bengali (Bangladesh)&quot;
            Case 141A Locale = &quot;Bosnian (Bosnia/Herzegovina)&quot;
            Case 0402 Locale = &quot;Bulgarian&quot;
            Case 0455 Locale = &quot;Burmese&quot;
            Case 0403 Locale = &quot;Catalan&quot;
            Case 045c Locale = &quot;Cherokee (United States)&quot;
            Case 0804 Locale = &quot;Chinese (PRC)&quot;
            Case 1004 Locale = &quot;Chinese (Singapore)&quot;
            Case 0404 Locale = &quot;Chinese (Taiwan)&quot;
            Case 0c04 Locale = &quot;Chinese (Hong Kong SAR)&quot;
            Case 1404 Locale = &quot;Chinese (Macao SAR)&quot;
            Case 041a Locale = &quot;Croatian&quot;
            Case 101a Locale = &quot;Croatian (Bosnia/Herzegovina)&quot;
            Case 0405 Locale = &quot;Czech&quot;
            Case 0406 Locale = &quot;Danish&quot;
            Case 0465 Locale = &quot;Divehi&quot;
            Case 0413 Locale = &quot;Dutch (Netherlands)&quot;
            Case 0813 Locale = &quot;Dutch (Belgium)&quot;
            Case 0466 Locale = &quot;Edo&quot;
            Case 0409 Locale = &quot;English (United States)&quot;
            Case 0809 Locale = &quot;English (United Kingdom)&quot;
            Case 0c09 Locale = &quot;English (Australia)&quot;
            Case 2809 Locale = &quot;English (Belize)&quot;
            Case 1009 Locale = &quot;English (Canada)&quot;
            Case 2409 Locale = &quot;English (Caribbean)&quot;
            Case 3c09 Locale = &quot;English (Hong Kong SAR)&quot;
            Case 4009 Locale = &quot;English (India)&quot;
            Case 3809 Locale = &quot;English (Indonesia)&quot;
            Case 1809 Locale = &quot;English (Ireland)&quot;
            Case 2009 Locale = &quot;English (Jamaica)&quot;
            Case 4409 Locale = &quot;English (Malaysia)&quot;
            Case 1409 Locale = &quot;English (New Zealand)&quot;
            Case 3409 Locale = &quot;English (Philippines)&quot;
            Case 4809 Locale = &quot;English (Singapore)&quot;
            Case 1c09 Locale = &quot;English (South Africa)&quot;
            Case 2c09 Locale = &quot;English (Trinidad)&quot;
            Case 3009 Locale = &quot;English (Zimbabwe)&quot;
            Case 0425 Locale = &quot;Estonian&quot;
            Case 0438 Locale = &quot;Faroese&quot;
            Case 0429 Locale = &quot;Farsi&quot;
            Case 0464 Locale = &quot;Filipino&quot;
            Case 040b Locale = &quot;Finnish&quot;
            Case 040c Locale = &quot;French (France)&quot;
            Case 080c Locale = &quot;French (Belgium)&quot;
            Case 2c0c Locale = &quot;French (Cameroon)&quot;
            Case 0c0c Locale = &quot;French (Canada)&quot;
            Case 240c Locale = &quot;French (DRC)&quot;
            Case 300c Locale = &quot;French (Cote d'Ivoire)&quot;
            Case 3c0c Locale = &quot;French (Haiti)&quot;
            Case 140c Locale = &quot;French (Luxembourg)&quot;
            Case 340c Locale = &quot;French (Mali)&quot;
            Case 180c Locale = &quot;French (Monaco)&quot;
            Case 380c Locale = &quot;French (Morocco)&quot;
            Case e40c Locale = &quot;French (North Africa)&quot;
            Case 200c Locale = &quot;French (Reunion)&quot;
            Case 280c Locale = &quot;French (Senegal)&quot;
            Case 100c Locale = &quot;French (Switzerland)&quot;
            Case 1c0c Locale = &quot;French (West Indies)&quot;
            Case 0462 Locale = &quot;Frisian (Netherlands)&quot;
            Case 0467 Locale = &quot;Fulfulde (Nigeria)&quot;
            Case 042f Locale = &quot;FYRO Macedonian&quot;
            Case 083c Locale = &quot;Gaelic (Ireland)&quot;
            Case 043c Locale = &quot;Gaelic (Scotland)&quot;
            Case 0456 Locale = &quot;Galician&quot;
            Case 0437 Locale = &quot;Georgian&quot;
            Case 0407 Locale = &quot;German (Germany)&quot;
            Case 0c07 Locale = &quot;German (Austria)&quot;
            Case 1407 Locale = &quot;German (Liechtenstein)&quot;
            Case 1007 Locale = &quot;German (Luxembourg)&quot;
            Case 0807 Locale = &quot;German (Switzerland)&quot;
            Case 0408 Locale = &quot;Greek&quot;
            Case 0474 Locale = &quot;Guarani (Paraguay)&quot;
            Case 0447 Locale = &quot;Gujarati&quot;
            Case 0468 Locale = &quot;Hausa (Nigeria)&quot;
            Case 0475 Locale = &quot;Hawaiian (United States)&quot;
            Case 040d Locale = &quot;Hebrew&quot;
            Case 0439 Locale = &quot;Hindi&quot;
            ' Case 040e Locale = &quot;Hungarian&quot;
            Case 0469 Locale = &quot;Ibibio (Nigeria)&quot;
            Case 040f Locale = &quot;Icelandic&quot;
            Case 0470 Locale = &quot;Igbo (Nigeria)&quot;
            Case 0421 Locale = &quot;Indonesian&quot;
            Case 045d Locale = &quot;Inuktitut&quot;
            Case 0410 Locale = &quot;Italian (Italy)&quot;
            Case 0810 Locale = &quot;Italian (Switzerland)&quot;
            Case 0411 Locale = &quot;Japanese&quot;
            Case 044b Locale = &quot;Kannada&quot;
            Case 0471 Locale = &quot;Kanuri (Nigeria)&quot;
            Case 0860 Locale = &quot;Kashmiri&quot;
            Case 0460 Locale = &quot;Kashmiri (Arabic)&quot;
            Case 043f Locale = &quot;Kazakh&quot;
            Case 0453 Locale = &quot;Khmer&quot;
            Case 0457 Locale = &quot;Konkani&quot;
            Case 0412 Locale = &quot;Korean&quot;
            Case 0440 Locale = &quot;Kyrgyz (Cyrillic)&quot;
            Case 0454 Locale = &quot;Lao&quot;
            Case 0476 Locale = &quot;Latin&quot;
            Case 0426 Locale = &quot;Latvian&quot;
            Case 0427 Locale = &quot;Lithuanian&quot;
            ' Case 043e Locale = &quot;Malay (Malaysia)&quot;
            ' Case 083e Locale = &quot;Malay (Brunei Darussalam)&quot;
            Case 044c Locale = &quot;Malayalam&quot;
            Case 043a Locale = &quot;Maltese&quot;
            Case 0458 Locale = &quot;Manipuri&quot;
            Case 0481 Locale = &quot;Maori (New Zealand)&quot;
            ' Case 044e Locale = &quot;Marathi&quot;
            Case 0450 Locale = &quot;Mongolian (Cyrillic)&quot;
            Case 0850 Locale = &quot;Mongolian (Mongolian)&quot;
            Case 0461 Locale = &quot;Nepali&quot;
            Case 0861 Locale = &quot;Nepali (India)&quot;
            Case 0414 Locale = &quot;Norwegian (Bokmål)&quot;
            Case 0814 Locale = &quot;Norwegian (Nynorsk)&quot;
            Case 0448 Locale = &quot;Oriya&quot;
            Case 0472 Locale = &quot;Oromo&quot;
            Case 0479 Locale = &quot;Papiamentu&quot;
            Case 0463 Locale = &quot;Pashto&quot;
            Case 0415 Locale = &quot;Polish&quot;
            Case 0416 Locale = &quot;Portuguese (Brazil)&quot;
            Case 0816 Locale = &quot;Portuguese (Portugal)&quot;
            Case 0446 Locale = &quot;Punjabi&quot;
            Case 0846 Locale = &quot;Punjabi (Pakistan)&quot;
            Case 046B Locale = &quot;Quecha (Bolivia)&quot;
            Case 086B Locale = &quot;Quecha (Ecuador)&quot;
            Case 0C6B Locale = &quot;Quecha (Peru)&quot;
            Case 0417 Locale = &quot;Rhaeto-Romanic&quot;
            Case 0418 Locale = &quot;Romanian&quot;
            Case 0818 Locale = &quot;Romanian (Moldava)&quot;
            Case 0419 Locale = &quot;Russian&quot;
            Case 0819 Locale = &quot;Russian (Moldava)&quot;
            Case 043b Locale = &quot;Sami (Lappish)&quot;
            Case 044f Locale = &quot;Sanskrit&quot;
            Case 046c Locale = &quot;Sepedi&quot;
            Case 0c1a Locale = &quot;Serbian (Cyrillic)&quot;
            Case 081a Locale = &quot;Serbian (Latin)&quot;
            Case 0459 Locale = &quot;Sindhi (India)&quot;
            Case 0859 Locale = &quot;Sindhi (Pakistan)&quot;
            Case 045b Locale = &quot;Sinhalese (Sri Lanka)&quot;
            Case 041b Locale = &quot;Slovak&quot;
            Case 0424 Locale = &quot;Slovenian&quot;
            Case 0477 Locale = &quot;Somali&quot;
            ' Case 042e Locale = &quot;Sorbian&quot;
            Case 0c0a Locale = &quot;Spanish (Spain - Modern Sort)&quot;
            Case 040a Locale = &quot;Spanish (Spain - Traditional Sort)&quot;
            Case 2c0a Locale = &quot;Spanish (Argentina)&quot;
            Case 400a Locale = &quot;Spanish (Bolivia)&quot;
            Case 340a Locale = &quot;Spanish (Chile)&quot;
            Case 240a Locale = &quot;Spanish (Colombia)&quot;
            Case 140a Locale = &quot;Spanish (Costa Rica)&quot;
            Case 1c0a Locale = &quot;Spanish (Dominican Republic)&quot;
            Case 300a Locale = &quot;Spanish (Ecuador)&quot;
            Case 440a Locale = &quot;Spanish (El Salvador)&quot;
            Case 100a Locale = &quot;Spanish (Guatemala)&quot;
            Case 480a Locale = &quot;Spanish (Honduras)&quot;
            Case 580a Locale = &quot;Spanish (Latin America)&quot;
            Case 080a Locale = &quot;Spanish (Mexico)&quot;
            Case 4c0a Locale = &quot;Spanish (Nicaragua)&quot;
            Case 180a Locale = &quot;Spanish (Panama)&quot;
            Case 3c0a Locale = &quot;Spanish (Paraguay)&quot;
            Case 280a Locale = &quot;Spanish (Peru)&quot;
            Case 500a Locale = &quot;Spanish (Puerto Rico)&quot;
            Case 540a Locale = &quot;Spanish (United States)&quot;
            Case 380a Locale = &quot;Spanish (Uruguay)&quot;
            Case 200a Locale = &quot;Spanish (Venezuela)&quot;
            Case 0430 Locale = &quot;Sutu&quot;
            Case 0441 Locale = &quot;Swahili&quot;
            Case 041d Locale = &quot;Swedish&quot;
            Case 081d Locale = &quot;Swedish (Finland)&quot;
            Case 045a Locale = &quot;Syriac&quot;
            Case 0428 Locale = &quot;Tajik&quot;
            Case 045f Locale = &quot;Tamazight (Arabic)&quot;
            Case 085f Locale = &quot;Tamazight (Latin)&quot;
            Case 0449 Locale = &quot;Tamil&quot;
            Case 0444 Locale = &quot;Tatar&quot;
            Case 044a Locale = &quot;Telugu&quot;
            ' Case 041e Locale = &quot;Thai&quot;
            Case 0851 Locale = &quot;Tibetan (Bhutan)&quot;
            Case 0451 Locale = &quot;Tibetan (PRC)&quot;
            Case 0873 Locale = &quot;Tigrigna (Eritrea)&quot;
            Case 0473 Locale = &quot;Tigrigna (Ethiopia)&quot;
            Case 0431 Locale = &quot;Tsonga&quot;
            Case 0432 Locale = &quot;Tswana&quot;
            Case 041f Locale = &quot;Turkish&quot;
            Case 0442 Locale = &quot;Turkmen&quot;
            Case 0480 Locale = &quot;Uighur (China)&quot;
            Case 0422 Locale = &quot;Ukrainian&quot;
            Case 0420 Locale = &quot;Urdu&quot;
            Case 0820 Locale = &quot;Urdu (India)&quot;
            Case 0843 Locale = &quot;Uzbek (Cyrillic)&quot;
            Case 0443 Locale = &quot;Uzbek (Latin)&quot;
            Case 0433 Locale = &quot;Venda&quot;
            Case 042a Locale = &quot;Vietnamese&quot;
            Case 0452 Locale = &quot;Welsh&quot;
            Case 0434 Locale = &quot;Xhosa&quot;
            Case 0478 Locale = &quot;Yi&quot;
            Case 043d Locale = &quot;Yiddish&quot;
            Case 046a Locale = &quot;Yoruba&quot;
            Case 0435 Locale = &quot;Zulu&quot;
            Case 04ff Locale = &quot;HID (Human Interface Device)&quot;
            Case Else
            Locale = &quot;Could Not Determine OS Locale&quot;
        End Select

'//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'//
'// Set variables gathered from Win32_OperatingSystem class:

        Caption = objOSItem.Caption
        CSDVersion = objOSItem.CSDVersion
        CSName = objOSItem.CSName
        Version = objOSItem.Version
        BuildType = objOSItem.BuildType
        BuildNumber = objOSItem.BuildNumber
        SerialNumber = objOSItem.SerialNumber

        ScriptHelper.SWbemDateTime.Value = objOSItem.InstallDate
        InstallDate = ScriptHelper.SWbemDateTime.GetVarDate(True)

        ScriptHelper.SWbemDateTime.Value = objOSItem.LastBootUpTime
        LastBootUpTime = ScriptHelper.SWbemDateTime.GetVarDate(True)

        Status = objOSItem.Status
    Next

'//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'//
'// Set variables gathered from Win32_ComputerSystem class:

    For Each objCompSysItem in colCompSysItems
        CurrentTimeZone = objCompSysItem.CurrentTimeZone
        DaylightInEffect = objCompSysItem.DaylightInEffect
        TotalMemory = FormatNumber(objCompSysItem.TotalPhysicalMemory/1024^3, 2)
    Next

'//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'//
'// Set variables gathered from Win32_TimeZone class:

    For Each objTZItem in colTZItems
        TZName = objTZItem.StandardName
    Next

'//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'//
'// Set variables gathered from Win32_ComputerSystemProduct class:

    For Each objCompSysProdItem in colCompSysProdItems
        CompSysName = objCompSysProdItem.Name
        IdentifyingNumber = objCompSysProdItem.IdentifyingNumber
        UUID = objCompSysProdItem.UUID
    Next

'//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'//
'// Set variables gathered from Win32_BIOS class:

    For Each objBIOSItem in colBIOSItems
        SMBIOSVersion = objBIOSItem.SMBIOSBIOSVersion
    Next

'//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'//
'// Start echoing output to the screen

    Wscript.Echo &quot;     ------------------------------------------&quot;
    Wscript.Echo &quot;                   System Details&quot;
    Wscript.Echo &quot;     ------------------------------------------&quot;
    Wscript.Echo &quot;&quot;
    Wscript.Echo &quot;     Computer Name:        &quot; &amp; CSName
    Wscript.Echo &quot;&quot;
    Wscript.Echo &quot;&quot;
    Wscript.Echo &quot;     Operating System Information:&quot;
    Wscript.Echo &quot;     =============================&quot;
    Wscript.Echo &quot;     Operating System:     &quot; &amp; Caption &amp; Arch
    Wscript.Echo &quot;     Version:               &quot; &amp; Version &amp; &quot; &quot; &amp; Sku &amp; &quot; &quot; &amp; CSDVersion
    Wscript.Echo &quot;     Build Type:            &quot; &amp; BuildType
    Wscript.Echo &quot;     Locale:                &quot; &amp; Locale
    Wscript.Echo &quot;     Serial Number:         &quot; &amp; SerialNumber
    Wscript.Echo &quot;&quot;
    Wscript.Echo &quot;     Current Time Zone:     &quot; &amp; TZName
    Wscript.Echo &quot;     Offset from UTC:       &quot; &amp; CurrentTimeZone/60 &amp; &quot; hours&quot;
    Wscript.Echo &quot;     DST In Effect:         &quot; &amp; DaylightInEffect
    Wscript.Echo &quot;&quot;

'//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'//
'// Get the product keys (function at the end of script):

GetKeys()

    Wscript.Echo &quot;&quot;
    Wscript.Echo &quot;     Install Date:          &quot; &amp; InstallDate
    Wscript.Echo &quot;     Last Boot Time:        &quot; &amp; LastBootUpTime
    Wscript.Echo &quot;     Local Date/Time:       &quot; &amp; Now()
    Wscript.Echo &quot;&quot;
    Wscript.Echo &quot;     System Status:         &quot; &amp; Status
    Wscript.Echo &quot;&quot;
    Wscript.Echo &quot;&quot;
    Wscript.Echo &quot;     Hardware Information:&quot;
    Wscript.Echo &quot;     =====================&quot;

'//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'//
'// Set and echo variables gathered from Win32_Processor class:

    For Each objProcItem in colProcItems
        Select Case objProcItem.Architecture
            Case 0 CPUArch = &quot;x86&quot;
            Case 1 CPUArch = &quot;MIPS&quot;
            Case 2 CPUArch = &quot;Alpha&quot;
            Case 3 CPUArch = &quot;PowerPC&quot;
            Case 6 CPUArch = &quot;Itanium&quot;
            Case 9 CPUArch = &quot;x64&quot;
            Case Else
            CPUArch = &quot;Could Not Determine CPU Architecture&quot;
        End Select
    Wscript.Echo &quot;     CPU:                  &quot; &amp; objProcItem.Name &amp; &quot; (&quot; &amp; CPUArch &amp; &quot;)&quot;
    Next
    Wscript.Echo &quot;&quot;
    Wscript.Echo &quot;     Physical Memory:      &quot; &amp; TotalMemory &amp; &quot; GB&quot;
    Wscript.Echo &quot;&quot;

'//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'//
'// Set variables gathered from Win32_VideoController class:

    For Each objVideoItem in colVideoItems
        Wscript.Echo &quot;     Video Card:           &quot; &amp; objVideoItem.Name

        If Not objVideoItem.AdapterDACType = &quot;&quot; Then
            Wscript.Echo &quot;     Adapter DAC:           &quot; &amp; objVideoItem.AdapterDACType
        End if

        Wscript.Echo &quot;     PNP Device ID:         &quot; &amp; objVideoItem.PNPDeviceID

        If Not objVideoItem.AdapterRAM = &quot;&quot; Then
            Wscript.Echo &quot;     Video RAM:             &quot; &amp; objVideoItem.AdapterRAM/1024^2 &amp; &quot; MB&quot;
        End If

        Wscript.Echo &quot;     Driver Version:        &quot; &amp; objVideoItem.DriverVersion

        On Error Resume Next
        ScriptHelper.SWbemDateTime.Value = objVideoItem.DriverDate
            If Err.number &lt;&gt; 0 Then
                DriverDate = &quot;&quot;
                ' No DriverDate, do not echo
            Else
                DriverDate = ScriptHelper.SWbemDateTime.GetVarDate(False)
                Wscript.Echo &quot;     Driver Date:           &quot; &amp; DriverDate
            End If
        On Error Goto 0
        Wscript.Echo &quot;&quot;
    Next

'//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'//
'// Set variables gathered from Win32_SoundDevice class:

    For Each objSoundItem in colSoundItems
        Wscript.Echo &quot;     Sound Card:           &quot; &amp; objSoundItem.Name
        Wscript.Echo &quot;     Manufacturer:          &quot; &amp; objSoundItem.Manufacturer
        Wscript.Echo &quot;     PNP Device ID:         &quot; &amp; objSoundItem.PNPDeviceID
        Wscript.Echo &quot;&quot;
    Next

'//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'//
'// Set variables gathered from Win32_LogicalDisk class:

    For Each objDiskItem in colDiskItems
        If objDiskItem.DriveType = 3 Then
            Wscript.Echo &quot;     Volume:               &quot; &amp; objDiskItem.Caption
            Wscript.Echo &quot;     Compressed:            &quot; &amp; objDiskItem.Compressed
            Wscript.Echo &quot;     File System:           &quot; &amp; objDiskItem.FileSystem
            Wscript.Echo &quot;     Volume Size:           &quot; &amp; FormatNumber(objDiskItem.Size/1024^3, 2) &amp; &quot; GB&quot;
            Wscript.Echo &quot;     Free Space:            &quot; &amp; FormatNumber(objDiskItem.FreeSpace/1024^3, 2) &amp; &quot; GB&quot;
            Wscript.Echo &quot;&quot;
        End If
    Next

'//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'//
'// Set variables gathered from Win32_NetworkAdapterConfiguration class:

    For Each objNetAdapConfigItem in colNetAdapConfigItems
        If isNull(objNetAdapConfigItem.IPAddress) Then
            '// Skip adapter, not currently used
        Else
            Wscript.Echo &quot;     Network Adapter:      &quot; &amp; objNetAdapConfigItem.Description
            Wscript.Echo &quot;     MAC Address:           &quot; &amp; objNetAdapConfigItem.MACAddress
            Wscript.Echo &quot;     DHCP Enabled:          &quot; &amp; objNetAdapConfigItem.DHCPEnabled
            Wscript.Echo &quot;     IP Address:            &quot; &amp; Join(objNetAdapConfigItem.IPAddress, &quot;,&quot;)
            Wscript.Echo &quot;     Subnet Mask:           &quot; &amp; Join(objNetAdapConfigItem.IPSubnet, &quot;,&quot;)
            Wscript.Echo &quot;     Default Gateway:       &quot; &amp; Join(objNetAdapConfigItem.DefaultIPGateway, &quot;,&quot;)
            If objNetAdapConfigItem.DHCPEnabled = True Then

                ScriptHelper.SWbemDateTime.Value = objNetAdapConfigItem.DHCPLeaseObtained
                DHCPLeaseObtained = ScriptHelper.SWbemDateTime.GetVarDate(True)
                Wscript.Echo &quot;     Lease Obtained:        &quot; &amp; DHCPLeaseObtained

                ScriptHelper.SWbemDateTime.Value = objNetAdapConfigItem.DHCPLeaseExpires
                DHCPLeaseExpires = ScriptHelper.SWbemDateTime.GetVarDate(True)
                Wscript.Echo &quot;     Lease Exipres:         &quot; &amp; DHCPLeaseExpires

                Wscript.Echo &quot;     DHCP Servers:          &quot; &amp; objNetAdapConfigItem.DHCPServer
            End If
            Wscript.Echo &quot;     DNS Server:            &quot; &amp; Join(objNetAdapConfigItem.DNSServerSearchOrder, &quot;,&quot;)
            If Not objNetAdapConfigItem.WINSPrimaryServer = &quot;&quot; Then
                Wscript.Echo &quot;     WINS Primary Server:   &quot; &amp; objNetAdapConfigItem.WINSPrimaryServer
                If Not objNetAdapConfigItem.WINSSecondaryServer = &quot;&quot; Then
                    Wscript.Echo &quot;     WINS Secondary Server: &quot; &amp; objNetAdapConfigItem.WINSPrimaryServer
                End If
                Wscript.Echo &quot;     Enable LMHosts Lookup: &quot; &amp; objNetAdapConfigItem.WINSEnableLMHostsLookup
            End If
            Wscript.Echo &quot;&quot;
        End If
    Next
    Wscript.Echo &quot;&quot;
    Wscript.Echo &quot;     System Information:&quot;
    Wscript.Echo &quot;     ===================&quot;
    Wscript.Echo &quot;     Computer:             &quot; &amp; CompSysName
    Wscript.Echo &quot;     Serial Number:         &quot; &amp; IdentifyingNumber
    Wscript.Echo &quot;     BIOS Version:          &quot; &amp; SMBIOSVersion
    Wscript.Echo &quot;     UUID:                  &quot; &amp; UUID
    Wscript.Echo &quot;&quot;

'//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'//
'// This pause call is disabled, but you may wish to enable it if running this script
'// with the ElevateThisScript() subroutine call enabled above:

' PressEnter()

'//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'//
'// Functions: GetKeys() and decodeKey(iValues, strProduct)
'//
'// Credit where credit is due - I found and modified script posted by user &quot;Parabellum&quot;
'// found on http://www.visualbasicscript.com/m42793.aspx, hacked it up a bit, and used
'// it here to post keys:

Public Function GetKeys()

    For x = LBound(arrSubKeys, 1) To UBound(arrSubKeys, 1)
    ScriptHelper.Registry.GetBinaryValue HKEY_LOCAL_MACHINE, arrSubKeys(x,1), SEARCH_KEY, arrDPIDBytes

        If Not IsNull(arrDPIDBytes) Then
            Call decodeKey(arrDPIDBytes, arrSubKeys(x,0))
        Else
            ScriptHelper.Registry.EnumKey HKEY_LOCAL_MACHINE, arrSubKeys(x,1), arrGUIDKeys

            If Not IsNull(arrGUIDKeys) Then
                For Each GUIDKey In arrGUIDKeys
                    ScriptHelper.Registry.GetBinaryValue HKEY_LOCAL_MACHINE, arrSubKeys(x,1) &amp; &quot;\&quot; &amp; GUIDKey, SEARCH_KEY, arrDPIDBytes

                    If Not IsNull(arrDPIDBytes) Then
                        Call decodeKey(arrDPIDBytes, arrSubKeys(x,0))
                    End If
                Next
            End If
        End If
    Next

End Function

    Public Function decodeKey(iValues, strProduct)

        Dim arrDPID
        arrDPID = Array()

            For i = 52 to 66
                ReDim Preserve arrDPID( UBound(arrDPID) + 1 )
                arrDPID( UBound(arrDPID) ) = iValues(i)
            Next

        Dim arrChars
        arrChars = Array(&quot;B&quot;,&quot;C&quot;,&quot;D&quot;,&quot;F&quot;,&quot;G&quot;,&quot;H&quot;,&quot;J&quot;,&quot;K&quot;,&quot;M&quot;,&quot;P&quot;,&quot;Q&quot;,&quot;R&quot;,&quot;T&quot;,&quot;V&quot;,&quot;W&quot;,&quot;X&quot;,&quot;Y&quot;,&quot;2&quot;,&quot;3&quot;,&quot;4&quot;,&quot;6&quot;,&quot;7&quot;,&quot;8&quot;,&quot;9&quot;)

            For i = 24 To 0 Step -1
                k = 0

                For j = 14 To 0 Step -1
                    k = k * 256 Xor arrDPID(j)
                    arrDPID(j) = Int(k / 24)
                    k = k Mod 24
                Next

                strProductKey = arrChars(k) &amp; strProductKey

                If i Mod 5 = 0 And i &lt;&gt; 0 Then
                    strProductKey = &quot;-&quot; &amp; strProductKey
                End If
            Next

        ReDim Preserve foundKeys( UBound(foundKeys) + 1 )
        foundKeys( UBound(foundKeys) ) = strProductKey
        strKey = UBound(foundKeys)
        Wscript.Echo &quot;     &quot; &amp; strProduct &amp; &quot;&quot; &amp; foundKeys(strKey)
    End Function

'//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'//
'// Subroutine: PressEnter()
'//
'// Adds a pause with a &quot;Press the ENTER key to continue.&quot; message when called.
'//
'// Usage:  Call this Subroutine to get a pause that will clear when the user presses the
'// ENTER key (and ONLY the ENTER key) on their keyboard:

Sub PressEnter()
    Wscript.Echo &quot;&quot;
    strMessage = &quot;Press the ENTER key to continue. &quot;
    Wscript.StdOut.Write strMessage

    Do While Not WScript.StdIn.AtEndOfLine
        Input = WScript.StdIn.Read(1)
    Loop
End Sub

'// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'//
'// ScriptHelperClass and EnvironmentClass are helper classes to simplify
'// script work. Declare and use globally throughout the script.
'//
'//     Example code:
'//
'//     Option Explicit
'//     Dim ScriptHelper
'//     Set ScriptHelper = New ScriptHelperClass
'//     ScriptHelper.RunMeWithCScript()
'//     ScriptHelper.ElevateThisScript()
'//     WScript.Echo &quot;User profile : &quot; &amp; ScriptHelper.Environment.UserProfile
'//     WScript.Echo &quot;Domain : &quot; &amp; ScriptHelper.Network.UserDomain
'//     ScriptHelper.CreateFolder &quot;\\SERVER\Share\Folder\With\Path&quot;
'//     ScriptHelper.FileSystem.FileExists(&quot;C:\command.com&quot;)
'//     ScriptHelper.Shell.RegRead(&quot;HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ProductOptions\ProductType&quot;)
'//
'// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Class ScriptHelperClass

        Private objEnvironment
        Private objFileSystem
        Private objNetwork
        Private objShell
        Private objSWBemlocator
        Private objWMI
        Private objRegistry
        Private objSWbemDateTime

        Public Computer

        Public Property Get Environment
            If objEnvironment Is Nothing Then
                Set objEnvironment = New EnvironmentClass
                objEnvironment.Shell = Shell
            End If
            Set Environment = objEnvironment
        End Property

        Public Property Get FileSystem
            If objFileSystem Is Nothing Then Set objFileSystem = CreateObject(&quot;Scripting.FileSystemObject&quot;)
            Set FileSystem = objFileSystem
        End Property

        Public Property Get Network
            If objNetwork Is Nothing Then Set objNetwork = CreateObject(&quot;WScript.Network&quot;)
            Set Network = objNetwork
        End Property

        Public Property Get Shell
            If objShell Is Nothing Then Set objShell = CreateObject(&quot;WScript.Shell&quot;)
            Set Shell = objShell
        End Property

        Public Property Get WMI
            If objWMI Is Nothing Then
                On Error Resume Next
                Set objSWBemlocator = CreateObject(&quot;WbemScripting.SWbemLocator&quot;)
                Set objWMI = objSWBemlocator.ConnectServer(Computer, &quot;root\CIMV2&quot;)
                objWMI.Security_.ImpersonationLevel = 3
                On Error Goto 0
            End If
            Set WMI = objWMI
        End Property

        Public Property Get Registry
            If objRegistry Is Nothing Then Set objRegistry = GetObject(&quot;winmgmts:{impersonationLevel=impersonate}!\\&quot; &amp; strComputer &amp; &quot;\root\default:StdRegProv&quot;)
            Set Registry = objRegistry
        End Property

        Public Property Get SWbemDateTime
            If objSWbemDateTime Is Nothing Then Set objSWbemDateTime = CreateObject(&quot;WbemScripting.SWbemDateTime&quot;)
            Set SWbemDateTime = objSWbemDateTime
        End Property

        Private Sub Class_Initialize()
            Computer = &quot;.&quot;
            Set objEnvironment = Nothing
            Set objFileSystem = Nothing
            Set objNetwork = Nothing
            Set objShell = Nothing
            Set objSWBemlocator = Nothing
            Set objWMI = Nothing
            Set objRegistry = Nothing
            Set objSWbemDateTime = Nothing
        End Sub

        Private Sub Class_Terminate
            Set objSWbemDateTime = Nothing
            Set objRegistry = Nothing
            Set objWMI = Nothing
            Set objSWBemlocator = Nothing
            Set objShell = Nothing
            Set objNetwork = Nothing
            Set objFileSystem = Nothing
            Set objEnvironment = Nothing
        End Sub

        Public Property Get ScriptPath()
            ScriptPath = FileSystem.GetFile(WScript.ScriptFullName).ParentFolder
        End Property

        Public Function GetCurrentUserSID()
            Dim intCount, colItems, objItem, strSID

            Set colItems = WMI.ExecQuery(&quot;SELECT * FROM Win32_UserAccount WHERE Name = '&quot; &amp; Network.Username &amp; &quot;' AND Domain = '&quot; &amp; Network.UserDomain &amp; &quot;'&quot;, , 48)

            intCount = 0
            For Each objItem In colItems
                strSID = Cstr(objItem.SID)
                intCount = intCount + 1
            Next

            If intCount &gt; 0 Then
                GetCurrentUserSID = strSID
            Else
                GetCurrentUserSID = &quot;NOTFOUND&quot;
            End If
        End Function

        Public Sub CreateFolder(strFldPath)
            Dim fldArray, x, intStartIndex, blnUNC, strDestFold : strDestFold = &quot;&quot;

            If Left(strFldPath, 2) = &quot;\\&quot;  Then
                blnUNC = True
                intStartIndex = 3                                        'Start at the first folder in UNC path
            Else
                blnUNC = False
                intStartIndex = 0
            End If

            fldArray = Split(strFldPath, &quot;\&quot;)                                                        'Split folders into array

            If fldArray(intStartIndex) = &quot;&quot; Then Exit Sub

            For x = intStartIndex To UBound(fldArray)

                If strDestFold = &quot;&quot; Then
                    If blnUNC Then
                        strDestFold = &quot;\\&quot; &amp; fldArray(x-1) &amp; &quot;\&quot; &amp; fldArray(x)                    'Prefix UNC with server and share
                    Else
                        strDestFold = fldArray(x)
                    End If
                Else
                    strDestFold = strDestFold &amp; &quot;\&quot; &amp; fldArray(x)                                'Append each folder to end of path
                End If

                If Not FileSystem.FolderExists(strDestFold) Then FileSystem.CreateFolder(strDestFold)
            Next
        End Sub

        Public Sub DeleteFolder(strFldPath)
            If FileSystem.FolderExists(strFldPath) Then FileSystem.DeleteFolder strFldPath, True
        End Sub

        '//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        '// Subroutine: RunMeWithCScript()
        '//
        '// Purpose:    Forces the currently running script to use Cscript.exe as the Script
        '//             engine.  If the script is already running with cscript.exe the sub exits
        '//             and continues the script.
        '//
        '//             Sub Attempts to call the script with its original arguments.  Arguments
        '//             that contain a space will be wrapped in double quotes when the script
        '//             calls itself again.  To verify your command string you can echo out the
        '//             scriptCommand variable.
        '//
        '// Usage:      Add a call to this sub (RunMeWithCscript) to the beggining of your script
        '//             to ensure that cscript.exe is used as the script engine.
        '//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        Public Sub RunMeWithCScript()

            Dim scriptEngine, engineFolder, Args, arg, scriptName, argString, scriptCommand

            scriptEngine = Ucase(Mid(Wscript.FullName,InstrRev(Wscript.FullName,&quot;\&quot;)+1))
            engineFolder = Left(Wscript.FullName,InstrRev(Wscript.FullName,&quot;\&quot;))
            argString = &quot;&quot;

            If scriptEngine = &quot;WSCRIPT.EXE&quot; Then
                Dim Shell : Set Shell = CreateObject(&quot;Wscript.Shell&quot;)
                Set Args = Wscript.Arguments

                For each arg in Args                        'loop though argument array as a collection to rebuild argument string
                    If instr(arg,&quot; &quot;) &gt; 0 Then arg = &quot;&quot;&quot;&quot; &amp; arg &amp; &quot;&quot;&quot;&quot;    'if the argument contains a space wrap it in double quotes
                    argString = argString &amp; &quot; &quot; &amp; Arg
                Next

                'Create a persistent command prompt for the cscript output window and call the script with its original arguments
                scriptCommand = &quot;cmd.exe /k &quot; &amp; engineFolder &amp; &quot;cscript.exe &quot;&quot;&quot; &amp; Wscript.ScriptFullName &amp; &quot;&quot;&quot;&quot; &amp; argString

                Shell.Run scriptCommand,,False
                Wscript.Quit
            Else
                Exit Sub                    'Already Running with Cscript Exit this Subroutine
            End If

        End Sub

        '//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        '// Subroutine: ElevateThisScript()
        '//
        '// Purpose:    (Intended for Vista+)
        '//             Forces the currently running script to prompt for UAC elevation if it
        '//             detects that the current user credentials do not have administrative
        '//             privileges.
        '//
        '//             If run on Windows XP this script will cause the RunAs dialog to appear if
        '//             the user does not have administrative rights, giving the opportunity to
        '//             run as an administrator.
        '//
        '//             This Sub Attempts to call the script with its original arguments.
        '//             Arguments that contain a space will be wrapped in double quotes when the
        '//             script calls itself again.
        '//
        '// Usage:      Add a call to this sub (ElevateThisScript) to the beginning of your
        '//             script to ensure that the script gets an administrative token.
        '//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        Public Sub ElevateThisScript()

            Const HKEY_CLASSES_ROOT  = &amp;H80000000
            Const HKEY_CURRENT_USER  = &amp;H80000001
            Const HKEY_LOCAL_MACHINE = &amp;H80000002
            Const HKEY_USERS         = &amp;H80000003
            const KEY_QUERY_VALUE      = 1
            Const KEY_SET_VALUE          = 2

            Dim scriptEngine, engineFolder, argString, arg, Args, scriptCommand, HasRequiredRegAccess
            Dim objShellApp : Set objShellApp = CreateObject(&quot;Shell.Application&quot;)

            scriptEngine = Ucase(Mid(Wscript.FullName,InstrRev(Wscript.FullName,&quot;\&quot;)+1))
            engineFolder = Left(Wscript.FullName,InstrRev(Wscript.FullName,&quot;\&quot;))
            argString = &quot;&quot;

            Set Args = Wscript.Arguments

            For each arg in Args                        'loop though argument array as a collection to rebuild argument string
                If instr(arg,&quot; &quot;) &gt; 0 Then arg = &quot;&quot;&quot;&quot; &amp; arg &amp; &quot;&quot;&quot;&quot;    'if the argument contains a space wrap it in double quotes
                argString = argString &amp; &quot; &quot; &amp; Arg
            Next

            scriptCommand = engineFolder &amp; scriptEngine

            Dim objReg, bHasAccessRight
            Set objReg=GetObject(&quot;winmgmts:&quot;_
                &amp; &quot;{impersonationLevel=impersonate}!\\&quot; &amp;_
                Computer &amp; &quot;\root\default:StdRegProv&quot;)

            'Check for administrative registry access rights
            objReg.CheckAccess HKEY_LOCAL_MACHINE, &quot;System\CurrentControlSet\Control\CrashControl&quot;, _
                KEY_SET_VALUE, bHasAccessRight

            If bHasAccessRight = True Then

                HasRequiredRegAccess = True
                Exit Sub

            Else

                HasRequiredRegAccess = False
                objShellApp.ShellExecute scriptCommand, &quot; &quot;&quot;&quot; &amp; Wscript.ScriptFullName &amp; &quot;&quot;&quot;&quot; &amp; argString, &quot;&quot;, &quot;runas&quot;
                WScript.Quit
            End If

        End Sub
    End Class

    Class EnvironmentClass
        Private objShell
        Private strLogonServer
        Private strProgramFiles
        Private strProgramFilesX86
        Private strUserProfile
        Private strWinDir

        Public Cache

        Public Property Let Shell(objParentShell)
            Set objShell = objParentShell
        End Property

        Public Property Get LogonServer
            If IsNull(strLogonServer) Or Cache = False Then strLogonServer = objShell.ExpandEnvironmentStrings(&quot;%LOGONSERVER%&quot;)
            LogonServer = strLogonServer
        End Property

        Public Property Get ProgramFiles
            If IsNull(strProgramFiles) Or Cache = False Then strProgramFiles = objShell.ExpandEnvironmentStrings(&quot;%PROGRAMFILES%&quot;)
            ProgramFiles = strProgramFiles
        End Property

        Public Property Get ProgramFilesX86
            If IsNull(strProgramFilesX86) Or Cache = False Then strProgramFilesX86 = objShell.ExpandEnvironmentStrings(&quot;%PROGRAMFILES(x86)%&quot;)
            ProgramFilesX86 = strProgramFilesX86
        End Property

        Public Property Get UserProfile
            If IsNull(strUserProfile) Or Cache = False Then strUserProfile = objShell.ExpandEnvironmentStrings(&quot;%USERPROFILE%&quot;)
            UserProfile = strUserProfile
        End Property

        Public Property Get WinDir
            If IsNull(strWinDir) Or Cache = False Then strWinDir = objShell.ExpandEnvironmentStrings(&quot;%WINDIR%&quot;)
            WinDir = strWinDir
        End Property

        Private Sub Class_Initialize()
            Cache = True
            strLogonServer = Null
            strProgramFiles = Null
            strProgramFilesX86 = Null
            strUserProfile = Null
            strWinDir = Null
        End Sub
    End Class
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.cluberti.com/blog/2009/12/26/computer-info-vbscript/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Proxy PAC configuration file</title>
		<link>http://www.cluberti.com/blog/2009/12/18/proxy-pac-configuration-file/</link>
		<comments>http://www.cluberti.com/blog/2009/12/18/proxy-pac-configuration-file/#comments</comments>
		<pubDate>Fri, 18 Dec 2009 22:36:42 +0000</pubDate>
		<dc:creator>cluberti</dc:creator>
				<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[Proxy Autoconfig]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.cluberti.com/blog/2009/12/18/proxy-pac-configuration-file/</guid>
		<description><![CDATA[Had to work on one of these for a client, and decided that while there’s a whole host of documentation out there, there aren’t a lot of good working examples of how to use the proxy auto config functions properly in a complex file. Since I spent the better part of 8 hours getting something [...]]]></description>
			<content:encoded><![CDATA[<p>Had to work on one of these for a client, and decided that while there’s a whole host of documentation out there, there aren’t a lot of good working examples of how to use the proxy auto config functions properly in a complex file.</p>
<p>Since I spent the better part of 8 hours getting something that works properly in the environment (including site blocking to a custom server), I figured I’d share it with the users of this series of tubes in the hope it helps someone.</p>
<pre class="brush: jscript; title: ; notranslate">
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// NAME:        proxy.pac
//
// Original:    http://www.cluberti.com/blog
// Last Update: 14th May 2010
//
// Comment:     Proxy.pac example file for use as an auto configuration script
//              template.
//
// NOTE:        Provided as-is - usage of this source assumes that you are at the
//              very least familiar with the javascript language being used and
//              the tools used to create and debug this file.
//
//              In other words, if you break it, you get to keep the pieces.
//
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

// javascript:alert (&quot;Using PAC file&quot;);

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Start of the PAC file - function FindProxyForUrl:

function FindProxyForURL(url, host)
{

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Set proxy values as strings to use during return
// NOTE that if a rule directs the browser to return proxy_block, in this example
// the browser should attempt to visit http://internalserver:80, and will display
// the default web site at that location.

	var proxy_primary = &quot;PROXY proxy.primary.internal.domain.com:80&quot;;
	var proxy_secondary = &quot;PROXY proxy.secondary.internal.domain.com:80&quot;;
	var proxy_testing = &quot;PROXY proxy.testing.internal.domain.com:80&quot;;
	var proxy_block = &quot;PROXY internalserver:80&quot;; //&lt;- useful for blocking sites
	var proxy_no = &quot;DIRECT&quot;;

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Some proxies may have issues with mixed-case URLs, so change host variable to
// all lower case, and resolve the host IP to reduce DNS lookups later:

	host = host.toLowerCase();
	var resolved_IP = dnsResolve(host);

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Master blocked sites list
// NOTE: Add all sies you wish to redirect to proxy_block here:

	// if destination is .someblockeddomain.com, return proxy_block:
	if (dnsDomainIs(host, &quot;.someblockeddomain.com&quot;))
	{
		return proxy_block;
	}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// If URL has no dots in host name, send traffic direct.

	if (isPlainHostName(host))
	{
		return proxy_no;
	}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Master proxy bypass list
// NOTE: Add all other proxy bypass entries into this section:

	// If destination is to an RFC 1918 IP, return direct:
	if (isInNet(resolved_IP, &quot;10.0.0.0&quot;, &quot;255.0.0.0&quot;) ||
			isInNet(resolved_IP, &quot;172.16.0.0&quot;,  &quot;255.240.0.0&quot;) ||
			isInNet(resolved_IP, &quot;192.168.0.0&quot;, &quot;255.255.0.0&quot;) ||
			isInNet(resolved_IP, &quot;127.0.0.0&quot;, &quot;255.255.255.0&quot;))
	{
		return proxy_no;
	}

	// If request matches certain hosts in our IP range, return direct:
	if (isInNet(resolved_IP, &quot;11.11.11.11&quot;, &quot;255.0.0.0&quot;) ||
			isInNet(resolved_IP, &quot;11.11.11.12&quot;, &quot;255.0.0.0&quot;))
	{
		return proxy_no;
	}

		If request begins with &quot;xww&quot;, return direct:
	if (shExpMatch(host, &quot;xww.*&quot;))
	{
		return proxy_no;
	}

	// If request matches for *.internal.ourdomain.com/.net/.org, return direct:
	if (shExpMatch(host, &quot;*.internal.ourdomain.com&quot;) ||
			shExpMatch(host, &quot;*.internal.ourdomain.net&quot;) ||
			shExpMatch(host, &quot;*.internal.ourdomain.org&quot;))
	{
		return proxy_no;
	}

	// If request resolves to .external/.testing.ourdomain.com, return direct:
	if (dnsDomainIs(host, &quot;.external.ourdomain.com&quot;) ||
			dnsDomainIs(host, &quot;.testing.ourdomain.com&quot;))
	{
		return proxy_no;
	}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Hosts/domains to proxy
// NOTE: Add all hosts/domains that should go through the proxy into this section:

        // If request is for *.ourdomain.com and we've gotten this far, further
        // parsing is required:
        if (shExpMatch(host, &quot;*.ourdomain.com&quot;))
        {

                // If request is for .us.ourdomain.com, use primary proxy:
                if (dnsDomainIs(host, &quot;.us.ourdomain.com&quot;))
                {
                        return proxy_primary;
                }

                // If request is for .world.ourdomain.com, use secondary proxy:
                if (dnsDomainIs(host, &quot;.world.ourdomain.com&quot;))
                {
                        return proxy_secondary;
                }
        }

        // If browsing to *.microsoft.com, further parsing is required:
        if (shExpMatch(host, &quot;*.microsoft.com&quot;))
        {

                // If request is specifically for www.microsoft.com, try the secondary
                // proxy first:
                if (localHostOrDomainIs(host, &quot;www.microsoft.com&quot;))
                {
                        return proxy_secondary + &quot;; &quot; + proxy_primary ;
                }

                // Otherwise, try the primary proxy first to other microsoft sites:
                if (dnsDomainIs(host, &quot;.microsoft.com&quot;))
                {
                        return proxy_primary + &quot;; &quot; + proxy_secondary ;
                }
        }

        // If browsing to *.someotherdomain.com, further parsing is required:
        if (shExpMatch(host, &quot;*.someotherdomain.com&quot;))
        {

                // 172.16.0.0/255.255.0.0 IP address block -- try primary proxy first:
                if (isInNet(myIpAddress(), &quot;172.16.0.0&quot;, &quot;255.255.0.0&quot;))
                {
                        return proxy_primary + &quot;; &quot; + proxy_secondary ;
                }

                // 172.31.0.0/255.255.0.0 IP address block -- try secondary proxy first:
                if (isInNet(myIpAddress(), &quot;172.31.0.0&quot;, &quot;255.255.0.0&quot;))
                {
                        return proxy_secondary + &quot;; &quot; + proxy_primary ;
                }
        }

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Advanced proxying based on computer IP Address via the myIpAddress() function
// NOTE: Add all IP Address ranges you wish to proxy for in this section:

        // If the computer's IP address is in the 172.16.0.0/255.255.0.0 range, use
        // the the primary proxy Monday through Friday:
        if (isInNet(myIpAddress(), &quot;172.16.0.0&quot;, &quot;255.255.0.0&quot;))
        {
                if (weekdayRange(&quot;MON&quot;, &quot;FRI&quot;))
                {
                        return proxy_primary;
                }
        // If this check is done on Saturday or Sunday, this will fall through and
        // parsing will continue.
        }

        // If the computer's IP address is in the 172.31.0.0/255.255.0.0 range, use
        // the secondary proxy from January to June, and September to December:
        if (isInNet(myIpAddress(), &quot;172.31.0.0&quot;, &quot;255.255.0.0&quot;))
        {
                if (dateRange(&quot;JAN&quot;, &quot;JUN&quot;))
                {
                        return proxy_secondary;
                }
                if (dateRange(&quot;SEP&quot;, &quot;DEC&quot;))
                {
                        return proxy_secondary;
                }
        // If this check is done in July or August, this will fall through and parsing
        // will continue.
        }

        // If the computer's IP address is in the 192.168.0.0/255.255.0.0 range, use
        // the testing proxy from 8AM to 6PM local time:
        if (isInNet(myIpAddress(), &quot;192.168.0.0&quot;, &quot;255.255.0.0&quot;))
        {
                if (timeRange(8, 18))
                {
                        return proxy_testing;
                }
        // If this check is done before 8AM or after 6PM, this will fall through and
        // parsing will continue.
        }

        // If the computer's IP address is in the 10.0.0.0/255.0.0.0 range, use the
        // testing proxy:
        if (isInNet(myIpAddress(), &quot;10.0.0.0&quot;, &quot;255.0.0.0&quot;))
        {
                return proxy_testing;
        }

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Default return direct rule

// If the request matches no other parsing rules, return direct:
else
        // javascript:alert (&quot;PAC finished parsing for: &quot; + host + &quot;\nFrom IP: &quot; + myIpAddress() + &quot;\nReturning: &quot; + proxy_no);
        return proxy_no;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.cluberti.com/blog/2009/12/18/proxy-pac-configuration-file/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Login Scripts?</title>
		<link>http://www.cluberti.com/blog/2009/10/20/login-scripts/</link>
		<comments>http://www.cluberti.com/blog/2009/10/20/login-scripts/#comments</comments>
		<pubDate>Tue, 20 Oct 2009 21:30:47 +0000</pubDate>
		<dc:creator>cluberti</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.cluberti.com/blog/?p=35</guid>
		<description><![CDATA[OK, so I haven’t had a chance to finish up either of the two posts I’ve been working on, so to start I’m merging them into one larger MDT post.  Secondly, however, I’ve also been working with a friend of mine on creating a logon script for his environment that will replace a certain other [...]]]></description>
			<content:encoded><![CDATA[<p>OK, so I haven’t had a chance to finish up either of the two posts I’ve been working on, so to start I’m merging them into one larger MDT post.  Secondly, however, I’ve also been working with a friend of mine on creating a logon script for his environment that will replace a certain other tool they are using for logon management for their mix of 9x and 2000 workstations.  They’re slowly upgrading their back-end environment in preparation for a migration to Windows 7 on the clients, and they wanted to see if they could move from &lt;product&gt; to logon scripts and group policy (they are going to be using MDT and SCCM for deployment and lifecycle management).  They had to try and completely replace their current solution with group policy and a logon script (or scripts), and this has been accomplished.</p>
<p>Since this project took almost 2 weeks to complete, test, and roll out to the test environment, I decided to post it here just in case anyone else found it useful.  The starting framework and the progress bar .exe I have linked for anyone who wanted to see the roots from which this beast rose, and a download location for the progressbar binary ultimately used for this as well.</p>
<p>Progress bar code / binary from:<br />
<a href="http://www.devenezia.com/downloads/ppb/index.html">www.devenezia.com/downloads/ppb/index.html</a></p>
<p>Original source template from<br />
<a href="http://www.anonymoos.com/scripting/logonscript.txt">www.anonymoos.com/scripting/logonscript.txt</a></p>
<p>Here it is, in all it’s… glory?:</p>
<pre class="brush: vb; title: ; notranslate">
'// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \\
'//                                                                                 \\
'// NAME:           profile-based-testlogon.vbs                                     \\
'//                                                                                 \\
'// Original:       http://www.cluberti.com/blog                                    \\
'// Last Update:    18th January 2010, Carl Luberti                                 \\
'// Version:        2.5                                                             \\
'//                                                                                 \\
'//                                                                                 \\
'// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \\

'// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'//
'// Configure Script Parameters

Option Explicit
Dim strLogName, bolWriteLog, bolManagePrinters, bolEnableCrossDomain, strScriptVer
strLogName = &quot;script.log&quot;         ' Filename of log to write to in the %userprofile% folder.
strScriptVer = &quot;20th October 2009, v2.5&quot; ' Version to write in log
bolWriteLog = True               ' Toggles log-writing - True for on, False for off.
bolManagePrinters = True         ' Set this to False to disable printer management
bolEnableCrossDomain = True      ' Toggles Cross Domain AuThentication. Reads registry to obtain NetBIOS domain for the machine.

'// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'//
'// Gather User/Machine/Domain Info

Dim objNetwork, objDrives, objPrinters, objDict, objComputer, objShell, objShellApp, objFileSystem, objLogFile, objRootDSE, objTrans
Dim strComputerName, strDomain, strUser, strAdsPath, strNetBIOSDomain, strDNSDomain, strTemp, strLogPath, strUserOU, intPrinter, intNetLetter, i
Dim objFSO, objFiles, intCount
Dim strFile, strName, strDirectory, strTempFolder, strUserProfile, strExt, strProgressBarExe
Dim strOSVer
Dim objUserProfile, objTempFolder, objWMIService
Dim objUser

Set objNetwork = WScript.CreateObject(&quot;Wscript.Network&quot;)
Set objShell = WScript.CreateObject(&quot;WScript.Shell&quot;)
Set objShellApp = CreateObject(&quot;Shell.Application&quot;)
Set objFSO = CreateObject(&quot;Scripting.FileSystemObject&quot;)

Set objDrives = objNetwork.EnumNetworkDrives
Set objPrinters = objNetwork.EnumPrinterConnections

strUserProfile = objShell.ExpandEnvironmentStrings(&quot;%userprofile%&quot;)
strTempFolder = objShell.ExpandEnvironmentStrings(&quot;%temp%&quot;)
Set objUserProfile = objFSO.GetFolder(strUserProfile)
Set objTempFolder = objFSO.GetFolder(strTempFolder)

strComputerName = objNetwork.ComputerName
strDomain = objNetwork.UserDomain
strUser = objNetwork.UserName
strAdsPath = strDomain &amp; &quot;/&quot; &amp; strUser

Set objUser = GetObject(&quot;WinNT://&quot; &amp; strDomain &amp; &quot;/&quot; &amp; strUser)

'// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'//
'// Cross-Domain login check

If bolEnableCrossDomain Then
    On Error Resume Next
    strNetBIOSDomain = objShell.RegRead _
    (&quot;HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultDomainName&quot;)
    If Not Err.Number = 0 Then
        'do nothing
    End If
    On Error Goto 0
Else
    strNetBIOSDomain = strDomain
End If

'//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'//
'// Start Login Script Work

Set objComputer = GetObject(&quot;WinNT://&quot; &amp; strDomain &amp; &quot;/&quot; &amp; strComputerName &amp; &quot;,computer&quot;)
strTemp = objshell.ExpandEnvironmentStrings(&quot;%userprofile%&quot;)
strLogPath = strTemp &amp; &quot;\&quot; &amp; strLogName  '&quot;
Set objFileSystem = WScript.CreateObject(&quot;Scripting.FileSystemObject&quot;)

If bolWriteLog Then 'initialize log file
    On Error Resume Next
    Set objLogFile = objFileSystem.OpenTextFile(strLogPath, 2, True) '&quot;
    WriteLog &quot;#####################################################&quot;
    WriteLog &quot;############### Start Login Script ##################&quot;
    WriteLog &quot;#####################################################&quot;
    WriteLog &quot;&quot;
    objLogFile.WriteLine(Now() &amp; &quot;: Log:     Logon script version &quot; &amp; strScriptVer )
    WriteLog &quot;&quot;
    If Not Err.Number = 0 Then
        msgbox &quot;There was a problem opening the log file for writing.&quot; &amp; chr(10) &amp; _
        &quot;Please check whether &quot;&quot;&quot; &amp; strLogPath &amp; &quot;&quot;&quot; is a valid file and can be opened for writing.&quot; &amp; _
        chr(10) &amp; chr(10) &amp; &quot;If you're not sure what to do, please contact your support person.&quot;,vbCritical, &quot;Logon Script Error&quot;
        WScript.quit
    End If
    On Error Goto 0
End If

'//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'//
'// Copy Progressbar.exe to %userprofile%:

WriteLog &quot;----------- Checking for progressbar.exe ------------&quot;
WriteLog &quot;&quot;

strProgressBarExe = strUserProfile &amp; &quot;\progressbar.exe&quot;

If (objFSO.FileExists(strProgressBarExe)) Then
    objLogFile.WriteLine(Now() &amp; &quot;: Success: Progressbar.exe exists in %userprofile%, continuing&quot;)
    WriteLog &quot;&quot;
Else
    objLogFile.WriteLine(Now() &amp; &quot;: Log:     Progressbar.exe does not exist in %userprofile%, copying:&quot;)
    FileCopy &quot;\\domain.tld\netlogon\progressbar.exe&quot;, &quot;&quot; &amp; strUserProfile &amp; &quot;\&quot;
    WriteLog &quot;&quot;
End If

'Write final empty log line for section
WriteLog &quot;&quot;

'//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'//
'// Configure trusted sites on every login:

WriteLog &quot;------------- Setting Trusted Sites List ------------&quot;
WriteLog &quot;&quot;
Run &quot;regedit /s \\domain.tld\netlogon\trustedsites.reg&quot;
WriteLog &quot;&quot;

'Write final empty log line for section
WriteLog &quot;&quot;

'// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \\
'// ############################################################################### \\
'// ################################ INSTRUCTIONS ################################# \\
'// ############################################################################### \\
'// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \\

'Check for OS Version with IsOSVer:
'isOSVer will write an entry in the log when run
'If IsOSVer(&quot;Full OS Version&quot;) Then
'commands here
'End If

'Check for user group membership with isMember:
'isMember will write an entry in the log file when a user is in the group
'If isMember(&quot;groupname&quot;) Then
' commands here
'End If

'Check for computer group membership with isComputerMember:
'isComputerMember will write an entry in the log file when a computer is in the group
'If isComputerMember(&quot;groupname&quot;) Then
' commands here
'End If

'Check for user OU group membership with isOUMember:
'isOUMember will write an entry in the log file when a user is in the OU
'If isOUMember(&quot;OUName&quot;) Then
' commands here
'End If

'Check the computer running the script for a specific IP address with isThisIP:
'If isThisIP(&quot;172.23.0.5&quot;) Then
'   commands here
'End If
'isThisIP will write log file entries when logging is enabled. Requires WMI.

'Check the computer running the script for a specific IP address with isThisMachine:
'If isThisMachine(&quot;ComputerName&quot;) Then
'   commands here
'End If
'isThisMachine will write log file entries when logging is enabled. Requires WMI.

'Map drives with DriveMapper:
'DriveMapper &quot;Drive:&quot;, &quot;\\Server\share&quot;

'Add Printers with AddPrinter:
'AddPrinter &quot;\\Server\Printername&quot;

'Set a default printer with SetPrinterDefault (printer has to exist, or this will not work)
'SetPrinterDefault &quot;\\Server\Printername&quot;

'Remove Printers with RemovePrinter:
'RemovePrinter &quot;\\Server\Printername&quot;

'Remove All Printers from a Server with RemovePrintersFromServer. Handy when you retire a windows print server.
'RemovePrintersFromServer &quot;Servername&quot;

'Execute any file with Run:
'Run &quot;c:\windows\notepad.exe&quot;
'Run &quot;\\server\share\script.vbs&quot;

'Copy files with FileCopy(source, target):
'FileCopy &quot;\\server\share\*.txt&quot;, &quot;c:\temp\&quot;
'NOTE: copies are not recursive, and wildcards can only exists in the file level.
'NOTE: The user running the script must have permission to write AND DELETE files in the target location

'Write an entry to the log file with WriteLog():
'WriteLog(&quot;some text here&quot;)

'Write an entry to the registry file with RegWrite:
'RegWrite &quot;Reg value to change, Reg data to have entered into the value, Reg value type&quot;

'Set user environment variables with PutEnv:
'PutEnv &quot;Variablename&quot;, &quot;VariableValue&quot;

'A log file will be placed in the user's temp directory and will be named to the ScriptLogName variable set above.

'Interact with the logon script Progress Bar with ProgressBar:
'ProgressBar(&quot;parameters here&quot;)
'Fully documented here:  http://www.devenezia.com/downloads/ppb/index.html

'// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \\
'// ############################################################################### \\
'// ############################# Change Script Below ############################# \\
'// ############################################################################### \\
'// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \\

'// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \\
'//
'// Checking OS Version:

WriteLog &quot;---------------- Checking OS Version ----------------&quot;
WriteLog &quot;&quot;
If IsOSVer(&quot;5.0.2195&quot;) Then
    If bolWriteLog Then
        WriteLog &quot;OS is Windows 2000&quot;
        strOSVer = &quot;2000&quot;
        WriteLog &quot;&quot;
        WriteLog &quot;&quot;
        WScript.sleep 5000
        Run &quot;\\domain.tld\netlogon\oldlogonscript.bat&quot;
        WScript.Quit
    End If
End If

If IsOSVer(&quot;5.1.2600&quot;) Then
    If bolWriteLog Then WriteLog &quot;OS is Windows XP&quot;
        strOSVer = &quot;XP&quot;
        WriteLog &quot;&quot;
        WriteLog &quot;&quot;
'      WScript.sleep 5000
'       Run &quot;\\domain.tld\netlogon\oldlogonscript.bat&quot;
'       WScript.Quit
    End If
End If

If IsOSVer(&quot;5.2.3790&quot;) Then
    If bolWriteLog Then
        WriteLog &quot;OS is Windows Server 2003&quot;
        strOSVer = &quot;2003&quot;
        WriteLog &quot;&quot;
        WriteLog &quot;&quot;
'       WScript.sleep 5000
'       Run &quot;\\domain.tld\netlogon\oldlogonscript.bat&quot;
'       WScript.Quit
    End If
End If

If IsOSVer(&quot;6.1.7600&quot;) Then
    strOSVer = &quot;7 / 2008 R2 RTM&quot;
    WriteLog &quot;&quot;
    If bolWriteLog Then
        WriteLog &quot;OS is Windows 7 / Server 2008 R2 RTM&quot;
    End If
End If

If IsOSVer(&quot;6.0.6002&quot;) Then
    strOSVer = &quot;Vista / 2008 SP2&quot;
    WriteLog &quot;&quot;
    If bolWriteLog Then
        WriteLog &quot;OS is Windows Vista / Server 2008 SP2&quot;
    End If
End If

If IsOSVer(&quot;6.0.6001&quot;) Then
    strOSVer = &quot;Vista / 2008 SP1&quot;
    WriteLog &quot;&quot;
    If bolWriteLog Then
        WriteLog &quot;OS is Windows Vista / Server 2008 SP1&quot;
    End If
End If

If IsOSVer(&quot;6.0.6000&quot;) Then
    strOSVer = &quot;Vista RTM&quot;
    WriteLog &quot;&quot;
    If bolWriteLog
        Then WriteLog &quot;OS is Windows Vista RTM&quot;
    End If
End If

'Write final empty log line for section
WriteLog &quot;&quot;

'// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \\
'// ############################### Global Settings ############################### \\
'// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \\

'// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'//
'// Create Login Progress Bar application:

ProgressBar(&quot;Create &quot;&quot;Login Script&quot;)
WScript.sleep 100

'// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'//
'// Synchronize PC's time with a domain controller:

ProgressBar(&quot;SetText 1 &quot;&quot;Setting time&quot;)
WScript.sleep 100
WriteLog &quot;------------- Configuring Machine Time --------------&quot;
WriteLog &quot;&quot;
objShell.run &quot;net time /domain: &quot; &amp; strDomain &amp; &quot; /set /yes&quot;, 0, TRUE

If Err.Number = 0 Then
    objLogFile.WriteLine(Now() &amp; &quot;: Success: Machine time for computer &quot; &amp; strComputerName &amp; &quot; synchronized with &quot; &amp; strDomain &amp; &quot; domain&quot; )
Else
    objLogFile.WriteLine(Now() &amp; &quot;: Failure: Machine time for computer &quot; &amp; strComputerName &amp; &quot; not synchronized with &quot; &amp; strDomain &amp; &quot; domain&quot; )
End If

WriteLog &quot;&quot;
ProgressBar(&quot;SetPos 1 5&quot;)
WScript.sleep 300

'Write final empty log line for section
WriteLog &quot;&quot;

'// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \\
'// #################### Settings based on user/group/machine ##################### \\
'// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \\

'// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'//
'// Remove mapped drives and printers before continuing:

ProgressBar(&quot;SetText 1 &quot;&quot;Removing old mapped drives and printers&quot;)
ProgressBar(&quot;SetPos 1 20&quot;)

On Error Resume Next
For i = 0 to objDrives.Count - 1 Step 2
    'WScript.Echo objDrives.Item(i+1)
    objNetwork.RemoveNetworkDrive objDrives.Item(i),True,True
Next
WScript.sleep 600

On Error Resume Next
For i = 0 to objPrinters.Count - 1 Step 2
    'WScript.Echo objPrinters.Item(i+1)
    objNetwork.RemovePrinterConnection objPrinters.Item(i+1)
Next
WScript.sleep 600

'// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'//
'// Skip printer mappings If the computer is a member of a specific group:

If IsComputerMember(&quot;PrintServers&quot;) Then
    bolManagePrinters = False
    writeLog &quot;Printer Management Disabled for Terminal Servers&quot;
'   Exclude anyone logging on to a print server from creating printers.
End If

'// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'//
'// Domain Users Domain Group check:

On Error Resume Next
If isMember(&quot;Domain Users&quot;) Then
    WriteLog &quot;&quot;
    WriteLog &quot;Processing 'Domain Users' Script Profile&quot;
    WriteLog &quot;&quot;
    WriteLog &quot;---------------- Profile Redirection ----------------&quot;
    WriteLog &quot;&quot;
    ProgressBar(&quot;SetText 1 &quot;&quot;Redirecting Domain Users folders&quot;)
    WScript.sleep 100
    RegWrite &quot;HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Cookies&quot;, &quot;\\FILESERVER\Profiles$\Windows\&quot; &amp; strUser &amp; &quot;\Cookies&quot; , &quot;REG_EXPAND_SZ&quot;
    RegWrite &quot;HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Desktop&quot;, &quot;\\FILESERVER\Profiles$\Windows\&quot; &amp; strUser &amp; &quot;\Desktop&quot; , &quot;REG_EXPAND_SZ&quot;
    RegWrite &quot;HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Favorites&quot;, &quot;\\FILESERVER\Profiles$\Windows\&quot; &amp; strUser &amp; &quot;\Favorites&quot; , &quot;REG_EXPAND_SZ&quot;
    RegWrite &quot;HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\History&quot;, &quot;\\FILESERVER\Profiles$\Windows\&quot; &amp; strUser &amp; &quot;\History&quot; , &quot;REG_EXPAND_SZ&quot;
    RegWrite &quot;HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Recent&quot;, &quot;\\FILESERVER\Profiles$\Windows\&quot; &amp; strUser &amp; &quot;\Recent&quot; , &quot;REG_EXPAND_SZ&quot;
    RegWrite &quot;HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Personal&quot;, &quot;\\FILESERVER\Profiles$\Windows\&quot; &amp; strUser , &quot;REG_EXPAND_SZ&quot;
    RegWrite &quot;HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\My Music&quot;, &quot;\\FILESERVER\Profiles$\Windows\&quot; &amp; strUser &amp; &quot;\Music&quot; , &quot;REG_EXPAND_SZ&quot;
    RegWrite &quot;HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\My Pictures&quot;, &quot;\\FILESERVER\Profiles$\Windows\&quot; &amp; strUser &amp; &quot;\Pictures&quot; , &quot;REG_EXPAND_SZ&quot;
    RegWrite &quot;HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\My Video&quot;, &quot;\\FILESERVER\Profiles$\Windows\&quot; &amp; strUser &amp; &quot;\Video&quot; , &quot;REG_EXPAND_SZ&quot;
    RegWrite &quot;HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\{374DE290-123F-4565-9164-39C4925E467B}&quot;, &quot;\\FILESERVER\Profiles$\Windows\&quot; &amp; strUser &amp; &quot;\Downloads&quot; , &quot;REG_EXPAND_SZ&quot;
    RegWrite &quot;HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\AppData&quot;, &quot;\\FILESERVER\Profiles$\Windows\&quot; &amp; strUser &amp; &quot;\AppData&quot; , &quot;REG_EXPAND_SZ&quot;
    ProgressBar(&quot;SetPos 1 25&quot;)
    WScript.sleep 300
    WriteLog &quot;&quot;
    WriteLog &quot;------------------ Drive Mappings -------------------&quot;
    WriteLog &quot;&quot;
    ProgressBar(&quot;SetText 1 &quot;&quot;Mapping Domain Users drives&quot;)
    WScript.sleep 100
    DriveMapper &quot;H:&quot;, &quot;\\FILESERVER\Home$\Windows\&quot; &amp; strUser , &quot;Home&quot;
    DriveMapper &quot;L:&quot;, &quot;\\FILESERVER\Profiles$\Windows\&quot; &amp; strUser , &quot;Profile&quot;
    DriveMapper &quot;P:&quot;, &quot;\\FILESERVER\Public&quot;, &quot;Public&quot;
    DriveMapper &quot;S:&quot;, &quot;\\FILESERVER\Applications$&quot;, &quot;Apps&quot;
    DriveMapper &quot;V:&quot;, &quot;\\FILESERVER\system$&quot;, &quot;Access System Files&quot;
    WriteLog &quot;&quot;
    WriteLog &quot;&quot;
    ProgressBar(&quot;SetPos 1 30&quot;)
    WScript.sleep 300
    If isMember(&quot;Quick Books&quot;) Then
        ProgressBar(&quot;SetText 1 &quot;&quot;Mapping Quick Books drives&quot;)
        WScript.sleep 100
        WriteLog &quot;&quot;
        DriveMapper &quot;Q:&quot;, &quot;\\FILESERVER\QuickBooks$&quot;
        objShellApp.NameSpace(qDrive).Self.Name = &quot;QuickBooks&quot;
        WriteLog &quot;&quot;
        ProgressBar(&quot;SetPos 1 40&quot;)
        WScript.sleep 300
    End If
    WriteLog &quot;&quot;
    WriteLog &quot;----------------- Printer Mappings ------------------&quot;
    WriteLog &quot;&quot;
    If isOUMember(&quot;North Campus&quot;) Then
        ProgressBar(&quot;SetText 1 &quot;&quot;Mapping North Campus printers&quot;)
        WScript.sleep 100
        WriteLog &quot;&quot;
        AddPrinter &quot;\\PRINTSERVER\PRINTER01&quot;
        AddPrinter &quot;\\PRINTSERVER\PRINTER02&quot;
        AddPrinter &quot;\\PRINTSERVER\PRINTER04&quot;
        AddPrinter &quot;\\PRINTSERVER\PRINTER05&quot;
        SetPrinterDefault &quot;\\PRINTSERVER\PRINTER02&quot;
        WriteLog &quot;&quot;
        WriteLog &quot;&quot;
        ProgressBar(&quot;SetPos 1 52&quot;)
        WScript.sleep 300
        If isMember(&quot;Accounting&quot;) Then
            ProgressBar(&quot;SetText 1 &quot;&quot;Mapping Accounting printers&quot;)
            WScript.sleep 100
            WriteLog &quot;&quot;
            AddPrinter &quot;\\PRINTSERVER\PRINTER06&quot;
            'SetPrinterDefault &quot;\\PRINTSERVER\PRINTER06&quot;
            WriteLog &quot;&quot;
            ProgressBar(&quot;SetPos 1 54&quot;)
            WScript.sleep 300
        End If
        If isUser(&quot;usera&quot;) Then
            ProgressBar(&quot;SetText 1 &quot;&quot;Mapping usera's printers&quot;)
            WScript.sleep 100
            WriteLog &quot;&quot;
            AddPrinter &quot;\\PRINTSERVER\PRINTER03&quot;
            SetPrinterDefault &quot;\\PRINTSERVER\PRINTER03&quot;
            WriteLog &quot;&quot;
            ProgressBar(&quot;SetPos 1 58&quot;)
            WScript.sleep 300
        End If
    End If
    If isOUMember(&quot;South Campus&quot;) Then
        ProgressBar(&quot;SetText 1 &quot;&quot;Mapping South Campus printers&quot;)
        WScript.sleep 100
        WriteLog &quot;&quot;
        AddPrinter &quot;\\PRINTSERVER\PRINTER01&quot;
        AddPrinter &quot;\\PRINTSERVER\PRINTER02&quot;
        AddPrinter &quot;\\PRINTSERVER\PRINTER04&quot;
        AddPrinter &quot;\\PRINTSERVER\PRINTER05&quot;
        SetPrinterDefault &quot;\\PRINTSERVER\PRINTER01&quot;
        WriteLog &quot;&quot;
        WriteLog &quot;&quot;
        ProgressBar(&quot;SetPos 1 60&quot;)
        WScript.sleep 300
        If isMember(&quot;Accounting&quot;) Then
            ProgressBar(&quot;SetText 1 &quot;&quot;Mapping Accounting printers&quot;)
            WScript.sleep 100
            WriteLog &quot;&quot;
            AddPrinter &quot;\\PRINTSERVER\PRINTER06&quot;
            SetPrinterDefault &quot;\\PRINTSERVER\PRINTER06&quot;
            WriteLog &quot;&quot;
            ProgressBar(&quot;SetPos 1 62&quot;)
            WScript.sleep 300
        End If
        If isUser(&quot;userb&quot;) Then
            ProgressBar(&quot;SetText 1 &quot;&quot;Mapping userb's printers&quot;)
            WScript.sleep 100
            WriteLog &quot;&quot;
            AddPrinter &quot;\\PRINTSERVER\PRINTER03&quot;
            WriteLog &quot;&quot;
            ProgressBar(&quot;SetPos 1 66&quot;)
            WScript.sleep 300
        End If
    End If
    WriteLog &quot;&quot;
    WriteLog &quot;----------------- Registry Policies -----------------&quot;
    WriteLog &quot;&quot;
    ProgressBar(&quot;SetText 1 &quot;&quot;Setting profile policies&quot;)
    WScript.sleep 100
    'Internet Explorer
    'Disable Internet Connection Wizard:
    RegWrite &quot;HKCU\Software\Microsoft\Internet Connection Wizard\Completed&quot;, &quot;1&quot;, &quot;REG_DWORD&quot;
    'Disable changing proxy settings:
    RegWrite &quot;HKCU\Software\Policies\Microsoft\Internet Explorer\Control Panel\Proxy&quot;, &quot;1&quot;, &quot;REG_DWORD&quot;
    'Disable Reset Web Settings feature:
    RegWrite &quot;HKCU\Software\Policies\Microsoft\Internet Explorer\Control Panel\ResetWebSettings&quot;, &quot;1&quot;, &quot;REG_DWORD&quot;
    'Disable automatic check for software updates:
    RegWrite &quot;HKCU\Software\Microsoft\Internet Explorer\Main\NoUpdateCheck&quot;, &quot;1&quot;, &quot;REG_DWORD&quot;
    'System
    'Require alphanumeric password:
    RegWrite &quot;HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Network\AlphanumPwds&quot;, &quot;1&quot;, &quot;REG_DWORD&quot;
    'No workgroup contents in network neighborhood:
    RegWrite &quot;HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Network\NoWorkgroupContents&quot;, &quot;1&quot;, &quot;REG_DWORD&quot;
    'Hide L, N, S, and V drive letters:
    RegWrite &quot;HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\NoDrives&quot;, &amp;H00242800, &quot;REG_DWORD&quot;
    WriteLog &quot;&quot;
    ProgressBar(&quot;SetPos 1 75&quot;)
    WScript.sleep 300
End If

'// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'//
'// Domain Admins Domain Group check:

If isMember(&quot;Domain Admins&quot;) Then
    WriteLog &quot;&quot;
    WriteLog &quot;Processing 'Domain Admins' Script Profile&quot;
    WriteLog &quot;&quot;
    ProgressBar(&quot;SetText 1 &quot;&quot;Redirecting Domain Admins folders&quot;)
    WScript.sleep 100
    WriteLog &quot;&quot;
    WriteLog &quot;---------------- Profile Redirection ----------------&quot;
    WriteLog &quot;&quot;
    If isUser(&quot;otheradmin&quot;) Then
        ProgressBar(&quot;SetText 1 &quot;&quot;Redirecting otheradmin's folders&quot;)
        WScript.sleep 100
        WriteLog &quot;&quot;
        RegWrite &quot;HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Cookies&quot;, &quot;\\FILESERVER\Profiles$\Windows\&quot; &amp; strUser &amp; &quot;\Cookies&quot; , &quot;REG_EXPAND_SZ&quot;
        RegWrite &quot;HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Desktop&quot;, &quot;\\FILESERVER\Profiles$\Windows\&quot; &amp; strUser &amp; &quot;\Desktop&quot; , &quot;REG_EXPAND_SZ&quot;
        RegWrite &quot;HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Favorites&quot;, &quot;\\FILESERVER\Profiles$\Windows\&quot; &amp; strUser &amp; &quot;\Favorites&quot; , &quot;REG_EXPAND_SZ&quot;
        RegWrite &quot;HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\History&quot;, &quot;\\FILESERVER\Profiles$\Windows\&quot; &amp; strUser &amp; &quot;\History&quot; , &quot;REG_EXPAND_SZ&quot;
        RegWrite &quot;HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Recent&quot;, &quot;\\FILESERVER\Profiles$\Windows\&quot; &amp; strUser &amp; &quot;\Recent&quot; , &quot;REG_EXPAND_SZ&quot;
        RegWrite &quot;HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Personal&quot;, &quot;\\FILESERVER\Profiles$\Windows\&quot; &amp; strUser , &quot;REG_EXPAND_SZ&quot;
        RegWrite &quot;HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\My Music&quot;, &quot;\\FILESERVER\Profiles$\Windows\&quot; &amp; strUser &amp; &quot;\Music&quot; , &quot;REG_EXPAND_SZ&quot;
        RegWrite &quot;HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\My Pictures&quot;, &quot;\\FILESERVER\Profiles$\Windows\&quot; &amp; strUser &amp; &quot;\Pictures&quot; , &quot;REG_EXPAND_SZ&quot;
        RegWrite &quot;HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\My Video&quot;, &quot;\\FILESERVER\Profiles$\Windows\&quot; &amp; strUser &amp; &quot;\Video&quot; , &quot;REG_EXPAND_SZ&quot;
        'RegWrite &quot;HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\{374DE290-123F-4565-9164-39C4925E467B}&quot;, &quot;\\FILESERVER\Profiles$\Windows\&quot; &amp; strUser &amp; &quot;\Downloads&quot; , &quot;REG_EXPAND_SZ&quot;
        'RegWrite &quot;HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\AppData&quot;, &quot;\\FILESERVER\Profiles$\Windows\&quot; &amp; strUser &amp; &quot;\AppData&quot; , &quot;REG_EXPAND_SZ&quot;
        WriteLog &quot;&quot;
        WScript.sleep 300
    Else
        ProgressBar(&quot;SetText 1 &quot;&quot;Redirecting Domain Admins folders&quot;)
        WScript.sleep 100
        WriteLog &quot;&quot;
        RegWrite &quot;HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Cookies&quot;, &quot;%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Cookies&quot; , &quot;REG_EXPAND_SZ&quot;
        RegWrite &quot;HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Desktop&quot;, &quot;%USERPROFILE%\Desktop&quot; , &quot;REG_EXPAND_SZ&quot;
        RegWrite &quot;HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Favorites&quot;, &quot;%USERPROFILE%\Favorites&quot; , &quot;REG_EXPAND_SZ&quot;
        RegWrite &quot;HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\History&quot;, &quot;%USERPROFILE%\AppData\Local\Microsoft\Windows\History&quot; , &quot;REG_EXPAND_SZ&quot;
        RegWrite &quot;HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Recent&quot;, &quot;%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Recent&quot; , &quot;REG_EXPAND_SZ&quot;
        RegWrite &quot;HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Personal&quot;, &quot;%USERPROFILE%\Documents&quot; , &quot;REG_EXPAND_SZ&quot;
        RegWrite &quot;HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\My Music&quot;, &quot;%USERPROFILE%\Music&quot; , &quot;REG_EXPAND_SZ&quot;
        RegWrite &quot;HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\My Pictures&quot;, &quot;%USERPROFILE%\Pictures&quot; , &quot;REG_EXPAND_SZ&quot;
        RegWrite &quot;HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\My Video&quot;, &quot;%USERPROFILE%\Videos&quot; , &quot;REG_EXPAND_SZ&quot;
        'RegWrite &quot;HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\{374DE290-123F-4565-9164-39C4925E467B}&quot;, &quot;%USERPROFILE%\Downloads&quot; , &quot;REG_EXPAND_SZ&quot;
        RegWrite &quot;HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\AppData&quot;, &quot;%USERPROFILE%\AppData\Roaming&quot; , &quot;REG_EXPAND_SZ&quot;
        WriteLog &quot;&quot;
        WScript.sleep 300
    End If
    ProgressBar(&quot;SetPos 1 25&quot;)
    WScript.sleep 300
    WriteLog &quot;&quot;
    WriteLog &quot;------------------ Drive Mappings -------------------&quot;
    WriteLog &quot;&quot;
    ProgressBar(&quot;SetText 1 &quot;&quot;Mapping Domain Admins drives&quot;)
    WScript.sleep 100
    DriveMapper &quot;H:&quot;, &quot;\\FILESERVER\Home$\Windows\&quot; &amp; strUser , &quot;Home&quot;
    DriveMapper &quot;L:&quot;, &quot;\\FILESERVER\Profiles$\Windows\&quot; &amp; strUser , &quot;Profile&quot;
    DriveMapper &quot;M:&quot;, &quot;\\FILESERVER\adminshare$&quot;, &quot;Admin&quot;
    DriveMapper &quot;P:&quot;, &quot;\\FILESERVER\Public&quot;, &quot;Public&quot;
    DriveMapper &quot;Q:&quot;, &quot;\\FILESERVER\QuickBooks$&quot;, &quot;QuickBooks&quot;
    DriveMapper &quot;S:&quot;, &quot;\\FILESERVER\Applications$&quot;, &quot;Apps&quot;
    DriveMapper &quot;V:&quot;, &quot;\\FILESERVER\system$&quot;, &quot;MS Access System Files&quot;
    WriteLog &quot;&quot;
    WriteLog &quot;&quot;
    ProgressBar(&quot;SetPos 1 50&quot;)
    WScript.sleep 300
    ProgressBar(&quot;SetText 1 &quot;&quot;Mapping Domain Admins printers&quot;)
    WScript.sleep 100
    WriteLog &quot;&quot;
    WriteLog &quot;----------------- Printer Mappings ------------------&quot;
    WriteLog &quot;&quot;
    AddPrinter &quot;\\PRINTSERVER\PRINTER01&quot;
    AddPrinter &quot;\\PRINTSERVER\PRINTER06&quot;
    AddPrinter &quot;\\PRINTSERVER\PRINTER02&quot;
    AddPrinter &quot;\\PRINTSERVER\PRINTER03&quot;
    AddPrinter &quot;\\PRINTSERVER\PRINTER04&quot;
    AddPrinter &quot;\\PRINTSERVER\PRINTER05&quot;
    SetPrinterDefault &quot;\\PRINTSERVER\PRINTER01&quot;
    WriteLog &quot;&quot;
    WriteLog &quot;&quot;
    ProgressBar(&quot;SetPos 1 70&quot;)
    WScript.sleep 300
    If isOUMember(&quot;North Campus&quot;) Then
        ProgressBar(&quot;SetText 1 &quot;&quot;Mapping North Campus printers&quot;)
        WScript.sleep 100
        WriteLog &quot;&quot;
        SetPrinterDefault &quot;\\PRINTSERVER\PRINTER02&quot;
        WriteLog &quot;&quot;
        ProgressBar(&quot;SetPos 1 72&quot;)
        WScript.sleep 300
    End If
    If isOUMember(&quot;South Campus&quot;) Then
        ProgressBar(&quot;SetText 1 &quot;&quot;Mapping South Campus printers&quot;)
        WScript.sleep 100
        WriteLog &quot;&quot;
        SetPrinterDefault &quot;\\PRINTSERVER\PRINTER01&quot;
        WriteLog &quot;&quot;
        ProgressBar(&quot;SetPos 1 75&quot;)
        WScript.sleep 300
    End If
    ProgressBar(&quot;SetText 1 &quot;&quot;Setting Domain Admins Registry Policies&quot;)
    WScript.sleep 100
    WriteLog &quot;&quot;
    WriteLog &quot;----------------- Registry Policies -----------------&quot;
    WriteLog &quot;&quot;
    WriteLog &quot;No policies written for Domain Admins&quot;
    WriteLog &quot;&quot;
    ProgressBar(&quot;SetPos 1 80&quot;)
    WScript.sleep 300
End If

'Write final empty log line for section
WriteLog &quot;&quot;

'// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \\
'// ############################ Temp File Cleanup ################################ \\
'// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \\

'// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'//
'// Delete files from temp directory:

WriteLog &quot;---------------- Deleting Temp Files ----------------&quot;
WriteLog &quot;&quot;

ProgressBar(&quot;SetText 1 &quot;&quot;Cleaning up&quot;)
WScript.sleep 100
intcount = 0
Set objFiles = objTempFolder.Files

For Each strFile In objFiles
    On Error Resume Next
    strFile.delete
    intCount = intCount +1
Next

WriteLog intCount &amp; &quot; temp files were deleted&quot;
ProgressBar(&quot;SetPos 1 95&quot;)
WScript.sleep 300

'Write final empty log line for section
WriteLog &quot;&quot;

'// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \\
'// ############################################################################### \\
'// ################## ^^^^^^^^^^ CHANGE SCRIPT ABOVE ^^^^^^^^^^ ################## \\
'// ####################### DO NOT EDIT BELOW THIS SECTION ######################## \\
'// ############################################################################### \\
'//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \\

WriteLog &quot;&quot;

'// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'//
'// Subs and Functions

ProgressBar(&quot;SetPos 1 100&quot;)
WScript.sleep 100
ProgressBar(&quot;SetText 1 &quot;&quot;Login script finished&quot;)
WScript.sleep 2000
ProgressBar(&quot;shutdown&quot;)
WriteLog &quot;#####################################################&quot;
WriteLog &quot;################ End Login Script ###################&quot;
WriteLog &quot;#####################################################&quot;
Set objNetwork = Nothing
Set objDrives = Nothing
Set objComputer = Nothing
Set objShell = Nothing
Set objFileSystem = Nothing
Set objLogFile = Nothing
Set objFSO = nothing
Set strFile = nothing
Set objFiles = nothing
Wscript.Quit

Function IsOSVer(sOSVer)
    On Error Resume Next
    Dim sThisComputer, oWMIService, cItems, oItem, sVer, intComparison

    sThisComputer = &quot;.&quot;
    Set oWMIService = GetObject(&quot;winmgmts:\\&quot; &amp; sThisComputer &amp; &quot;\root\cimv2&quot;)
    Set cItems = oWMIService.ExecQuery(&quot;Select * from Win32_OperatingSystem&quot;,,48)

    For Each oItem In cItems
        intComparison = StrComp(oItem.Version ,sOSVer ,1)

        If intComparison = 0 Then
            isOSVer =  True
            If bolWriteLog Then
                objLogFile.WriteLine(Now() &amp; &quot;: Success: OS Version is &quot; &amp; sOSVer )
            End If
            Exit Function
        Else
            isOSVer =  False
        End If
    Next
End Function

Function IsUser(sUser)
    Dim intComparison

    intComparison = StrComp(strUser ,sUser ,1)
    If intComparison = 0 Then
        IsUser = True
        If bolWriteLog Then
            objLogFile.WriteLine(Now() &amp; &quot;: Success: User is &quot; &amp; strUser)
        End If
        Exit Function
    Else
        IsUser = False
    End If
End Function

Function IsMember(sGroup)
    Dim oDict, oUser, oGroup

    If IsEmpty(oDict) Then
        Set oDict = CreateObject(&quot;Scripting.Dictionary&quot;)
        oDict.CompareMode = vbTextCompare
        Set oUser = GetObject(&quot;WinNT://&quot; &amp; strAdsPath &amp; &quot;,user&quot;)

        For Each oGroup In oUser.Groups
            oDict.Add oGroup.Name, &quot;-&quot;
        Next

        Set oUser = Nothing
    End If

    IsMember = CBool(oDict.Exists(sGroup))

    If IsMember And bolWriteLog Then
        objLogFile.WriteLine(Now() &amp; &quot;: Success: User is member of &quot; &amp; sGroup)
    End If
End Function

Function IsOUMember(sOU)
    Dim oConnection, oCommand, oRecordSet
    Dim strDN, arrPath, intLength, intNameLength, intComparison

    Const ADS_SCOPE_SUBTREE = 2

    Set oConnection = CreateObject(&quot;ADODB.Connection&quot;)
    Set oCommand =   CreateObject(&quot;ADODB.Command&quot;)
    oConnection.Provider = &quot;ADsDSOObject&quot;
    oConnection.Open &quot;Active Directory Provider&quot;
    Set oCommand.ActiveConnection = oConnection
    oCommand.Properties(&quot;Page Size&quot;) = 1000
    oCommand.Properties(&quot;Searchscope&quot;) = ADS_SCOPE_SUBTREE
    oCommand.CommandText = _
    &quot;SELECT distinguishedName FROM 'LDAP://dc=DOMAIN,dc=to'WHERE objectCategory='user'AND sAMAccountName='&quot; &amp; strUser &amp; &quot;'&quot;
    Set oRecordSet = oCommand.Execute
    oRecordSet.MoveFirst

    Do Until oRecordSet.EOF
        strDN = oRecordSet.Fields(&quot;distinguishedName&quot;).Value
        arrPath = Split(strDN, &quot;,&quot;)
        intLength = Len(arrPath(1))
        intNameLength = intLength - 3
        strUserOU = Right(arrPath(1), intNameLength)
        oRecordSet.MoveNext
    Loop
        intComparison = StrComp(strUserOU ,sOU ,1)

    If intComparison = 0 Then
        IsOUMember = True
        If bolWriteLog Then
            objLogFile.WriteLine(Now() &amp; &quot;: Success: User is a member of &quot; &amp; strUserOU)
        End If
        Exit Function
    Else
        IsOUMember = False
    End If
End Function

Function IsComputerMember(sGroup)
    Dim oGroup

    On Error Resume Next
    Set oGroup = GetObject(&quot;WinNT://&quot; &amp; strDomain &amp; &quot;/&quot; &amp; sGroup &amp; &quot;,group&quot;)
    IsComputerMember = CBool(oGroup.IsMember(objComputer.ADsPath &amp; &quot;$&quot;))

    If IsComputerMember And bolWriteLog Then
        objLogFile.WriteLine(Now() &amp; &quot;: Success: Computer is member of &quot; &amp; sGroup)
        Set oGroup = Nothing
        If Not Err.Number = 0 Then
            'nothing to see here, move along
        End If
    End If
    On Error Goto 0
End Function

Sub WriteLog(sEntry)
    If bolWriteLog Then
        objLogFile.WriteLine(Now() &amp; &quot;: Log:     &quot; &amp; sEntry)
    End If
End Sub

Sub DriveMapper(sDrive, sShare, sName)
    On Error Resume Next
    objNetwork.MapNetworkDrive sDrive, sShare

    If Err.Number = 0 Then
        objShellApp.NameSpace(sDrive).Self.Name = sName
        If bolWriteLog Then
            objLogFile.WriteLine(Now() &amp; &quot;: Success: Connect  &quot;&quot;&quot; &amp; sDrive &amp; &quot;&quot;&quot; to share &quot;&quot;&quot; &amp; sShare &amp; &quot;&quot;&quot; with name &quot;&quot;&quot; &amp; sName &amp; &quot;&quot;&quot;&quot;)
        End If
    Else
        If bolWriteLog Then
            objLogFile.WriteLine(Now() &amp; &quot;: Log:     Unable to connect &quot;&quot;&quot; &amp; sDrive &amp; &quot;&quot;&quot; to share &quot;&quot;&quot; &amp; sShare &amp; &quot;&quot;&quot; with name &quot;&quot;&quot; &amp; sName &amp; &quot;&quot;&quot;&quot;)
        End If
    On Error Goto 0
End Sub

Sub AddPrinter(sPrinterUNC)
    On Error Resume Next

    If Not bolManagePrinters Then
        If bolWriteLog Then
            objLogFile.WriteLine(Now() &amp; &quot;: Success: Printer connection skipped because disabled (&quot; &amp; _
            strUser &amp; &quot; on &quot; &amp; strComputerName &amp; &quot;)&quot;)
        End If
    Else
        objNetwork.AddWindowsPrinterConnection sPrinterUNC
        If Err.Number = 0 Then
            If bolWriteLog Then
                objLogFile.WriteLine(Now() &amp; &quot;: Success: Connect to printer: &quot; &amp; sPrinterUNC)
            End If
        Else
            If bolWriteLog Then
                objLogFile.WriteLine(Now() &amp; &quot;: Failed:  Connect to printer: &quot; &amp; sPrinterUNC)
            End If
        End If
    End If
    On Error Goto 0
End Sub

Sub RemovePrinter(sPrinterUNC)
    If Not bolManagePrinters Then
        If bolWriteLog Then
            objLogFile.WriteLine(Now() &amp; &quot;: Success: Printer connection skipped because disabled (&quot; &amp; _
            strUser &amp; &quot; on &quot; &amp; strComputerName &amp; &quot;)&quot;)
        End If
    Else
        Dim oPrinters
        Set oPrinters = objNetwork.EnumPrinterConnections

        For i = 0 To oPrinters.Count - 1 Step 2
            If uCase(oPrinters.Item(i+1)) = uCase(sPrinterUNC) Then
                On Error Resume Next
                objNetwork.RemovePrinterConnection sPrinterUNC, True, True
                If Err.Number = 0 Then
                    If bolWriteLog Then
                    objLogFile.WriteLine(Now() &amp; &quot;: Success: Remove printer: &quot; &amp; sPrinterUNC)
                Else
                    If bolWriteLog Then\
                    objLogFile.WriteLine(Now() &amp; &quot;: Failed:  Remove printer: &quot; &amp; sPrinterUNC)
                End If
                On Error Goto 0
                Exit Sub
            End If
        Next
    End If

    If bolWriteLog Then
        objLogFile.WriteLine(Now() &amp; &quot;: Success: Remove printer: &quot; &amp; sPrinterUNC &amp; &quot; (Printer did not exist)&quot; )
    End If
End Sub

Sub RemovePrintersFromServer(sServerName)
    If Not bolManagePrinters Then
        If bolWriteLog Then
            objLogFile.WriteLine(Now() &amp; &quot;: Success: Printer connection skipped because disabled (&quot; &amp; _
            strUser &amp; &quot; on &quot; &amp; strComputerName &amp; &quot;)&quot;)
        End If
    Else
        Dim oPrinters, aPrinter

        If bolWriteLog Then
            objLogFile.WriteLine(Now() &amp; &quot;: Removing all printers from: &quot; &amp; ucase(sServerName))
            Set oPrinters = objNetwork.EnumPrinterConnections

            For i = 0 to oPrinters.Count - 1 Step 2
                On Error Resume Next
                aPrinter = split(uCase(oPrinters.Item(i+1)),&quot;\&quot;,-1, 1)  '&quot;
                If Not UBound(aPrinter) = 0 Then  'this is not a local printer, process code
                    If aPrinter(2) = ucase(sServerName) Then
                        objNetwork.RemovePrinterConnection oPrinters.Item(i+1), True, True
                        If Err.Number = 0 Then
                            If bolWriteLog Then
                                objLogFile.WriteLine(Now() &amp; &quot;: Success: Remove printer: &quot; &amp; oPrinters.Item(i+1))
                            End If
                        Else
                            If bolWriteLog Then
                                objLogFile.WriteLine(Now() &amp; &quot;: Failed:  Remove printer: &quot; &amp; oPrinters.Item(i+1))
                            End If
                        End If
                    End If
                End If
                aPrinter = &quot;&quot;
                On Error Goto 0
            Next
        End If

        If bolWriteLog Then
            objLogFile.WriteLine(Now() &amp; &quot;: Removed  all printers from: &quot; &amp; ucase(sServerName))
        End If
    End If
End Sub

Sub SetPrinterDefault(sPrinterUNC)
    On Error Resume Next
    If Not bolManagePrinters Then
        If bolWriteLog Then
            objLogFile.WriteLine(Now() &amp; &quot;: Success: Default printer to &quot; &amp; sPrinterUNC &amp; _
            &quot; skipped because disabled (&quot; &amp; strUser &amp; &quot; on &quot; &amp; strComputerName &amp; &quot;)&quot;)
        Else
            objNetwork.SetDefaultPrinter sPrinterUNC
            If Err.Number = 0 Then
                If bolWriteLog Then
                    objLogFile.WriteLine(Now() &amp; &quot;: Success: Set as Default: &quot; &amp; sPrinterUNC)
                End If
            Else
                If bolWriteLog Then
                    objLogFile.WriteLine(Now() &amp; &quot;: Failed:  Set as Default: &quot; &amp; sPrinterUNC)
                End If
            End If
    End If
    On Error Goto 0
End Sub

Sub PutEnv(sName, sValue)
    Dim oEnv
    Set oEnv = objShell.Environment(&quot;USER&quot;)
    oEnv(sName) = sValue

    If bolWriteLog Then
        objLogFile.WriteLine(Now() &amp; &quot;: Success: Set user variable &quot;&quot;&quot; &amp; sName &amp; &quot;&quot;&quot; to: &quot;&quot;&quot; &amp; sValue &amp; &quot;&quot;&quot;&quot;)
    End If
    Set oEnv = Nothing
End Sub

Sub Run(ByVal sFile)
    On Error Resume Next
    'objShell.Run Chr(34) &amp; sFile &amp; Chr(34), 1, False
    objShell.Run sFile, 1, False

    If Err.Number = 0 Then
        If bolWriteLog Then
            objLogFile.WriteLine(Now() &amp; &quot;: Success: Execute: &quot; &amp; sFile)
        End If
    Else
        If bolWriteLog Then
            objLogFile.WriteLine(Now() &amp; &quot;: Failed:  Execute: &quot; &amp; sFile &amp; &quot; with error &quot; &amp; Err.Number)
        End If
    End If
    On Error Goto 0
End Sub

Sub FileCopy(sSource, sTarget)
    On Error Resume Next
    objFileSystem.CopyFile sSource, sTarget

    If Err.Number = 0 Then
        If bolWriteLog Then
            objLogFile.WriteLine(Now() &amp; &quot;: Success: Copy: &quot; &amp; sSource &amp; &quot; to &quot; &amp; sTarget)
        End If
    Else
        If bolWriteLog Then
            objLogFile.WriteLine(Now() &amp; &quot;: Failed:  Copy: &quot; &amp; sSource &amp; &quot; to &quot; &amp; sTarget)
        End If
    End If
    On Error Goto 0
End Sub

Sub RegWrite(sRegValue, sRegData, sRegType)
    On Error Resume Next
    objShell.Regwrite sRegValue, sRegData, sRegType

    If Err.Number = 0 Then
        If bolWriteLog Then
            objLogFile.WriteLine(Now() &amp; &quot;: Success: Reg value &quot; &amp; sRegValue &amp; &quot; set to &quot; &amp; sRegData &amp; &quot; as type &quot; &amp; sRegType )
        End If
    Else
        If bolWriteLog Then
            objLogFile.WriteLine(Now() &amp; &quot;: Failed:  Reg value &quot; &amp; sRegValue &amp; &quot; not set to &quot; &amp; sRegData)
        End If
    End If
    On Error Goto 0
End Sub

Function isThisIP(sThisAddress)
    On Error Resume Next
    Dim sThisComputer, oWMIService, cItems, oItem ,sAddress
    sThisComputer = &quot;.&quot;
    Set oWMIService = GetObject(&quot;winmgmts:\\&quot; &amp; sThisComputer &amp; &quot;\root\cimv2&quot;)
    Set cItems = oWMIService.ExecQuery (&quot;Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True&quot;)

    For Each oItem In cItems 'cycle all adapters
        'objItem.MACAddress 'this is the mac address, just in case

        For Each sAddress In oItem.IPAddress 'cycle all ip addresses for this adapter
            If sAddress = sThisAddress Then
                isThisIP =  True
                If bolWriteLog Then
                    objLogFile.WriteLine(Now() &amp; &quot;: Success: Found IP &quot; &amp; sThisAddress )
                    Exit function
                End If
            End If
        Next
    Next

    If Err.Number = 0 Then
        If bolWriteLog Then
            objLogFile.WriteLine(Now() &amp; &quot;: Success: Did not find IP &quot; &amp; sThisAddress )
        End If
    Else
        If bolWriteLog Then
            objLogFile.WriteLine(Now() &amp; &quot;: Failed:  An error occurred looking for IP &quot; &amp; sThisAddress )
        End If
    End If

    isThisIP =  False
    On Error goto 0
End Function

Function isThisMachine(sThisMachine)
    On Error Resume Next
    If sThisMachine = strComputer Then
        isThisMachine = True
        If bolWriteLog Then
            objLogFile.WriteLine(Now() &amp; &quot;: Success: Machine name is &quot; &amp; sThisMachine )
        Exit function
        End If
    End If

    If Err.Number = 0 Then
        If bolWriteLog Then
            objLogFile.WriteLine(Now() &amp; &quot;: Success: Machine name is not &quot; &amp; sThisMachine )
        End If
    Else
        'nothing to see here, move along
    End If

    isThisMachine =  False
    On Error goto 0
End Function

Sub ProgressBar(params)
    objShell.Run &quot;&quot;&quot;&quot; &amp; strUserProfile &amp; &quot;\progressbar.exe&quot;&quot; &quot; &amp; params
End Sub
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.cluberti.com/blog/2009/10/20/login-scripts/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

