Help - Search - Members - Calendar
Full Version: Code Repository
MSFN Forums > Coding, Scripting and Servers > Programming (C++, Delphi, VB, etc.)

   
Google Internet Forums Unattended CD/DVD Guide
Gouki
The main objective of this thread is to give users a 'central' thread containing all the code they may need.

You can post your code here, however, there are simple rules you must follow.
This will keep this thread clean and organized, making life easyer to everyone.

These fields are required. All submissions without them will be deleted.
  • Description: Give us a small description of what the code/application does.
  • Screenshot - Optional - In case your posting an application gives us the link to a screenshot. Don't post the image!
  • Programming Language: All programming languages are accepted. Just specify wich one did you use.
That's it. Now ATTACH (not post) your code.

One submission per post.

Don't make posts asking for help or commenting on an application/code you saw her. Instead PM the author.

Posts that are not considered to be submissions will be deleted.

Thank you for participating.

P.S: Taking someone else's work and pretending it's your own is nothing something you should do.
Always credit your sources.
Yzφwl
Have you ever wanted to pause a NT Command Script, without using the ping command, vbs or a third party utility?

Here's my way of doing it! (see the bottom of this post for the attached file)

This is an NT Command Script, (batch file), just place addelay.cmd somewhere in your path and call it from another script, like this:
    CALL ADDELAY [mins] [secs]
Where
[mins] is an integer representing the number of minutes you wish to delay for.
and
[secs] is an integer representing the number of seconds you wish to delay for.


If you don't wish to have any minutes, your first parameter, [mins], should be 0

Examples:
    CALL ADDELAY 0 15
    delays the running NT Command Script by 15 seconds

    CALL ADDELAY 1 7
    delays the running NT Command Script by 1 minute and 7 seconds

    CALL ADDELAY 3
    delays the running NT Command Script by 3 minutes

    CALL ADDELAY 0 72
    delays the running NT Command Script by 72 seconds

Additionally:
    CALL ADDELAY
    displays an error message and delays the running NT Command Script for five seconds

    CALL ADDELAY 0
    displays an error message and delays the running NT Command Script for five seconds

    CALL ADDELAY 0 0
    displays an error message and delays the running NT Command Script for five seconds


This is not intended to be a precision timepiece, so please don't start complaining about it being slightly inaccurate. I know it is, but it does the job for which I intended it. I hope it is useful!
phkninja
Program: Blowfish File Encyptor (command line)
Description:
This is a small application i wrote that implements the Blowfish Encryption algorythm. The archive contains a header for Blowfish Encryption/Decryption, a Header file to implement MD5 hash algorythm (required by command line program), and a command line program source file.

The command line program is a fully functional file encryptor. If the supplied password is less than 128 bits [16 characters long] it uses an MD5 hash of the password as a key, as it is recommended that password be at least 128 bits to be secure, and can take password up to 56 characters long which is the limit of the Blowfish algorythm.

Language: C, but will work in C++

(Removed from my website)

Click to view attachment
or
Click to view attachment
Maelstorm
Description: Function to change computer name.
Language: AutoIT3 3.1.1.x beta

Usage:
Call function with name you want to changed the computer to.
Returns 0 on success, 1 on error.
Reboot computer for changes to take effect.


Click to view attachment



Description: Function to Join a Workgroup (Windows XP Only)
Language: AutoIT3 3.1.1.x beta

Usage:
Call function with name of desired workgroup that you want to join.
Returns 0 on success, 1 on failure.
Reboot computer for changes to take effect.


Click to view attachment

Description: Function to join a Domain (Windows XP Only)
Language: AutoIT3 3.1.1.x beta

Usage:
Call function with name of domain to join, a userid, and password.
The UserID and Password should be an admin account on the domain controller.
Reboot computer for changes to take effect.

Click to view attachment



Note to Moderator:

I posted these as separate posts, but for some reason the board keeps merging them into one large post.
Djι
  • Description: Substring search function that can search starting from the left or from the right.
  • Programming Language: Visual Basic (for Applications, but I guess it works also with VB & VBS).
VB functions for searching a substring in another string (like Instr()) all start from the left and search in the right direction, with an optional start parameter to start searching only from this position.
No easy way to find the last occurance of the substring (like when you want to discriminate a file name from a file path searching for "\").

The attached function can accept a negative 'start' argument to start the search left wise from the end of the string, with a 'start' offset (also from the end).
Both the offset and the returned position still apply to the leftmost character of the substring.

Example usage code provided in the attachement.

The 'maths' involved to avoid an unlegant 'If start<0...' were interesting...
There is also another way arround using StrReverse(), but it is in fact not much simpler.
RogueSpear
Description: Generate MD5 Values of Files
Language: Visual Basic 2005 [Function]
Usage: String = GenerateFileHash(filename)

My initial search for examples on this led me to an example of using MD5 with strings. Specifically, using MD5 to secure the transmisson of passwords. You can find that article here. I spent quite some time trying to rework the example code to work with files rather than strings. Further searching yielded only a single example, in C#, at the MSDN forums. While not very helpful for VB, it did open my eyes to the BitConverter function.

CODE
Private Function GenerateFileHash(ByVal SourceFile As String) As String
        Dim strFile As New IO.FileStream(SourceFile, IO.FileMode.Open, IO.FileAccess.Read)
        Dim MD5 As New MD5CryptoServiceProvider()
        Return BitConverter.ToString(MD5.ComputeHash(strFile)).Replace("-", "")
        strFile.Close()
    End Function
sebbe1991
Description: Sets the computername
Language: C++

Screenshot
Click to view attachment
Djι
Description: VB Array Functions.
Programming Language: Visual Basic (for Applications, but I guess it works also with VB & VBS).
Usage: Have the whole set in a module of your project, or just insert in your code the function(s) that you need (beware of dependancies).

VB's handling of arrays is under everything. Especially when compared to other languages.
Those functions will come handy to everyone seeking to make something out VB arrays.

Yes, they are the same as those I'm using in my Excel ProgsLists generator.

'-Double-check but most of them should work with any array, even not 0-base-indexed (no relevant for VBS).
'-Arrays are normally passed ByRef, so the args are updated by the function.
'-They are fairly tested, but the usual disclaimer apply.

Not all array handling functionnalities of other languages are implemented here. If you have other functions that you'd like to be included in the set, PM me.

Content:
'* Returns true if the array has at least the specified number of elements (default to one element)
CODE
Function isSetArray(anArray, Optional minSize As Integer = 1) As Boolean
QUOTE
Dim myArray(), anything
isSetArray(myArray) -->False
isSetArray(anything) -->False
myArray=Array("test")
isSetArray(myArray) -->True
myArray=Array()
isSetArray(myArray) -->False
myArray=Array("a", "b", "c")
isSetArray(myArray, 3) -->true
isSetArray(myArray, 4) -->False

* Drops the first element out of the array and returns it
- in the array, the other elements' index is decreased by one
CODE
Function arrayDrop(anArray())

* Pops the last element out of the array and returns it
- the array passed as an argument loose this element
CODE
Function arrayPop(anArray())

* adds 'avalue' as a new element at the end of the array
CODE
Function arrayAdd(anArray(), aValue)

* Merges the 2 arrays in the 1st one and returns it
CODE
Function arrayMerge(Array1(), ByVal Array2)

* Like the 'Join' function but with more possibilities
CODE
Function implode(anArray(), Optional separator As String = " ", Optional keepEmptyElem As Boolean = False)

* Like the 'Split' function but actually working with line breaks!
- Try: Split(myString, vbcrlf) -> error
CODE
Function explode(theString As String, Optional separator As String = " ", Optional keepEmptyElem As Boolean = False)

* Translates an array containing arrays [like array(i)(j)] to a bidimentional array [like array(i, j)]
- The second dimension depends on the dimension of array(0)
- The array passed as an argument is NOT updated
CODE
Function arrayRect(anArray())

* Similar to Splice in JS: remove/insert some elements in the array
- starts operating at the 'start' position (from 1st element=0)
- removes 'count' elements
- inserts the elements of 'additions', which has to be an array (if passed)
CODE
Function arraySplice(anArray(), start As Integer, Optional count As Integer = 1, Optional additions As Variant)



Restriction: Except for 'isSetArray()' and the second arrays of arrayMerge & arraySplice, the array arguments are passed ByRef so they must be declared as arrays prior to pass them to the functions:
QUOTE
Dim myArray()
arrayAdd myArray, newValue

To change this and be able to pass anything (!), you may remove the '()' in the declaration:
QUOTE
Function arrayAdd(anArray(), aValue)


[Edits]:
- v0.0.2. Improvements to isSetArray, arrayMerge, implode & arraySplice. Addition of explode.
- Testing Sub() procedure at the bottom of the module.
Nazi Moderation
Purpose: to wait a specified number of seconds
Language: batch script, so just stick this code inside a text file and name it .bat or .cmd

CODE
@echo off
set start=
set secstowait=%1
if defined secstowait (goto :wait)
echo μμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμ
echo   USAGE: %0 X where X is number of seconds to wait.
echo   EXAMPLE: %0 30
echo                    (C) 2006 MSFN.ORG
echo μμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμμ
goto :eof
:wait
FOR /F "tokens=1-3 delims=:." %%i in ("%time%") do set hour=%%i&set minute=%%j&set seconds=%%k
if not defined start set /a start=(%hour%*3600)+(%minute%*60)+%seconds%
set /a current=(%hour%*3600)+(%minute%*60)+%seconds%
set /a elapsed=%current%-%start%
if %elapsed% LSS 0 (goto :eof)
if %elapsed% GEQ %secstowait% (echo Finished! Waited %elapsed% seconds.) else goto :wait


i got the idea for this off of the MSFN forums, but then i couldn't find the original program, so i created this. it is 100% my code and completely free to distribute.

just updated the script so that it will exit if midnight strikes while the script is running. if you wish you could edit it to return an errorcode when that happens.
#rootworm
full-featured command line driven vbs script for creating shortcuts.
i've seen many many examples that only show a couple shortcut parameters, i think this one has them all.

CODE
set objWSHShell = CreateObject("WScript.Shell")

if WScript.Arguments.Named.Exists("file") then
Path=WScript.Arguments.Named.Item("file") & ".lnk"
set objSC = objWSHShell.CreateShortcut(Path)
else
call Usage
end if

if WScript.Arguments.Named.Exists("desc") then
objSC.Description=WScript.Arguments.Named.Item("desc")
end if

if WScript.Arguments.Named.Exists("target") then
objSC.TargetPath=WScript.Arguments.Named.Item("target")
else
call Usage
end if

if WScript.Arguments.Named.Exists("arg") then
objSC.Arguments=WScript.Arguments.Named.Item("arg")
end if

if WScript.Arguments.Named.Exists("icon") and WScript.Arguments.Named.Exists("index") then
objSC.IconLocation = WScript.Arguments.Named.Item("icon") & "," & WScript.Arguments.Named.Item("index")
elseif WScript.Arguments.Named.Exists("icon") then
objSC.IconLocation = WScript.Arguments.Named.Item("icon") & ",0"
end if

if WScript.Arguments.Named.Exists("wstyle") then
objSC.WindowStyle = WScript.Arguments.Named.Item("wstyle")
end if

if WScript.Arguments.Named.Exists("hotkey") then
objSC.HotKey = WScript.Arguments.Named.Item("hotkey")
end if

if WScript.Arguments.Named.Exists("dir") then
objSC.WorkingDirectory = WScript.Arguments.Named.Item("dir")
end if

objSC.Save

sub Usage()
UsageText="Usage: shortcut.vbs /file: /target: /desc: /arg: /dir: /icon: /index: /wstyle: /hotkey:"_
&VbCrLf&VbCrLf&"(required) file is the filename for the shortcut, minus .lnk, i.e. /file:""C:\My Shortcut"""_
&VbCrLf&"(required) target is the file to create a shortcut to, i.e. /target:""c:\windows\notepad.exe"""_
&VbCrLf&"(optional) desc is the info tip for the shortcut, i.e. /desc:""This is my shortcut"""_
&VbCrLf&"(optional) arg sets the command-line argument for the target, i.e. /arg:c:\autoexec.bat"_
&VbCrLf&"(optional) dir sets the working directory for the shortcut, i.e. /dir:c:\"_
&VbCrLf&"(optional) icon is the file containing the icon for the shortcut, i.e. /icon:shell32.dll"_
&VbCrLf&"(optional) index of the icon to use from icon file, (defaults to 0) i.e. /index:40"_
&VbCrLf&"(optional) wstyle sets the window style for the shortcut, i.e. /wstyle:3"_
&VbCrLf&"1 = normal, 3 = maximize window, 7 = minimize window"_
&VbCrLf&"(optional) hotkey is the hotkey combination to assign, i.e. /hotkey:""ctrl+alt+shift+x"""
Wscript.Echo(UsageText)
Wscript.Quit
end sub
LLXX
Program(s): Various text-binary codec filters. They were intended for use with PDFs but I find them useful for the occasional decoding/encoding of URLs, cookies, and other miscellaneous things.

Description:

- Encode16
- Decode16

- Encode64
- (I didn't write a Decode64 for some reason...)

- Encode85
- Decode85

- rot13

Language: Asm
Usage:
CODE
filter < infile > outfile

CODE
cat infile | filter_1 | filter_2 | filter_3 > outfile
etc.

Self explanatory.
PityOnU
Well here's some batch I coded that once run will make it so that Windows automatically redirects a chosen URL to roflwaffle.com. It makes a really good practical joke for yourfriends whistling.gif


P.S. - It has a lot of Zune stuff in it cuz I tested it in a Zune forum shifty.gif[attachment=xxxxx:Zune_Unlocker.zip]

Moderator note
This attachment has been removed, not only do I not agree with 'practical jokes' of this nature, it does not do as you stated. The file basically asks for information it does not use then permanently changes site addresses in your hosts file. It also proceeds without warning to remove your temporary internet files folder. On top of that it is also not very well written.
cluberti
Description: VBscript to run elevated on Vista/Server 2008 when UAC is enabled.
Programming Language: VBScript
Usage: When a VBScript needs to run on Vista/Server 2008 and access parts of the system UAC protects when UAC is enabled, the script will simply fail. When this function is added to your script, UAC will prompt when the script is run, and the script will run once UAC elevation is allowed. Note that this also works on 2K3/XP when the user running the script is a non-Administrative user (a runas dialog will appear instead of a UAC prompt, obviously, but otherwise the same principles apply).
gunsmokingman
Description:
Hta that produces a Vbs Script called DeleteIt.vbs. This is places in the user SendTo Folder.
Uses Wscript.arguments to pass the path of the files or folder to be deleted.
This is a perminent delete and does not use the Recyle Bin or System Volume Information.
Hta also has a Remove Button to remove the DeleteIt.vbs from the user SendTo Folder.

Programming Language:
HTML, JS script, Vbs Script

Usage:
I wrote the original script because I wanted a fast way to delete things.

Note:
There is a limit to how many file or folders can be deleted, 24 items is it limits at one time.
This is a SFX file so it acts like a exe

Edit
Since I made this on Vista it works fine, on XP it did not work properly, that been fixed.
mschol
because the basic GetFiles() method of VB.net wasn't good enough for me i build my own function in order to do what i needed

Description:
the Getfiles() method of VB.net can only handle one fileextension and crashes when it tries to read from system volume information or a Reparsepoint
i thought of my own solution to that problem: build a function that searches a given directory for files that match a give Regular expression, and skip folders which you enter

Usage
CODE
searchFileSystem(path As String,searchPattern As String,searchOption As IO.SearchOption) As ArrayList

path = a path (i.e. c:\)
searchstring = a regular expression (i.e. .*?\.(avi|ogm|mkv|mpg|mp3|rar|mp4|mpeg|txt)$ for matching files with one of the extensions)
SearchOption = wheter to search only the topmost directory or also search in the subdirectory's

inside the function it also has a reference to an array which contains the folders where NOT to search
CODE
            If excluded.BinarySearch(d.Name) < 0 Then

excluded is in my function a Arraylist
Language
VB.net


i included a file thats not directly usable, you have to implement it in your own code.
i did include a few lines of code to show how u could use it


it might not be the best code availble but since i couldnt find any function that did it this way i build it myself. (one of my very first VB.net things smile.gif )
crahak
FontInst.exe was due for a replacement.

It was a bit dated:
  • It won't install some fonts types (unacceptable)
  • It doesn't give any error messages under any circumstances (even if you specify a inf file that doesn't exist or anything else)
  • It needs the /F switch along with the .inf file name (unless you remember the inf name it actually looks for, and know it does)
  • It needs a .inf file, with a [fonts] header which seemingly doesn't really serve any purpose but to make the app not work if you forgot it
  • It doesn't come with the source code, so you can't tweak/fix/modify anything to your liking
  • It's a Microsoft binary, redistribution might be tolerated, but not entirely legal (just look at the AutoPatcher case)

This is a LOT more versatile. It's easier to use (no artificial need for for things like a inf file with proper header, or even a list of fonts at all for that matter). It's open source. It comes with documentation (in the form of this post). You can extend it, modify it, customize it to suit your needs, or fix bugs yourself. It's easy to debug using free tools, and you don't need a fancy IDE or compiler to make changes. And it's even smaller than fontinst.exe

There are 4 modes of operation, use the one that fits your needs:
  1. No parameters/switches at all. It will simply install every font in the current directory automatically (there must be ONLY fonts and the script in the said directory!) This is the simplest way to use it.
  2. Using a simple text file called fonts.txt, which contains the list of font's file names (like the .inf file, but without the header, or with, if you really prefer). The file is automatically detected. No switches necessary!
  3. fontinst.exe compatibility mode: either 1) using the /F switch (case insensitive) followed by the name of the same style of inf file (actually, the [fonts] header is optional) or 2) auto detecting fontinst.inf (see mode 2). Provided to make it easy to replace the old util. If the file is not found, it will install all fonts from the current directory instead (see mode 1)
  4. Using the individual font names as parameters, separated by spaces, e.g. addfont.js font1.ttf font2.ttf font3.ttf (enclose long file names in double quotes as usual, i.e. "some font name.ttf")

And now, the script itself:
CODE
/* =========================================================================
NAME: fontinst.js
PURPOSE: Installing Fonts
AUTHOR: user crahak from msfn.org forum
REVISIONS:
  1.00 2008-06-25, Initial Release
COMMENTS: Tested with TrueType And OpenType fonts on Win XP Pro SP3 & Vista SP1
LICENSE: Released under the GPLv3 License
============================================================================ */

//installs a font
function installFont(filename)
{
  if (fso.FileExists(filename)) //make sure it exists first
  {
    fontsFolder.CopyHere(filename); //install the font
  }
}

//intalls all fonts listed in a file
function installFontsFromFile(filename)
{
  f = fso.GetFile(filename)
  strm= f.OpenAsTextStream(1,0); //ForReading, TristateFalse (ASCII)
  while(!strm.AtEndOfStream)
  {
    thisFile = strm.ReadLine();
    if (thisFile != "" && thisFile.toUpperCase() != "[FONTS]") //skip header and blank lines
    {
      installFont(currDir + thisFile);
    }
  }
  strm.close();
}

//intalls all fonts located in the current directory
function installFontsFromCurrDir()
{
  var scriptName = WScript.ScriptName;
  var thisFolder = fso.GetFolder(currDir);
  for (files = new Enumerator(thisFolder.Files); !files.atEnd(); files.moveNext())
  {
    var thisFile = files.item();
    if (thisFile.name != scriptName)
    {
      installFont(thisFile.Path);
    }
  }
}

//intalls all fonts whose names are passed as command line args
function installFontsFromArgs()
{
  for (i=0; i<objArgs.length; i++)
  {
    filename = currDir + objArgs(i);
    installFont(filename);
  }
}

var fontList = "fonts.txt"
var fontListOld = "fontinst.inf"
var shell = new ActiveXObject("Shell.Application");
var fso = new ActiveXObject("Scripting.FileSystemObject");
try
{
  var fontsFolder = shell.Namespace(0x14); //ssfFONTS ShellSpecialFolderConstant
  var currDir = fso.GetParentFolderName(WScript.ScriptFullName)
  if (currDir.substring(1) != "\\") currDir += "\\"
  var objArgs = WScript.Arguments;
  if ((objArgs.length == 0) || (objArgs.length == 2 && objArgs(0).toUpperCase() == "/F"))
  {
    if (objArgs.length == 2 && objArgs(0).toUpperCase() == "/F")
    {
      fontList = objArgs(1);
    }
    else if (fso.FileExists(fontListOld) && !fso.FileExists(fontList))
    {
      fontList = fontListOld;
    }
    if (fso.FileExists(fontList))
    {
      installFontsFromFile(fontList)
    }
    else
    {
      installFontsFromCurrDir()
    }
  }
  else
  {
    installFontsFromArgs()
  }
}
catch(e)
{
  WScript.Echo("exception " + e.number + ": " + e.description);
}

Some minor points:
  • dir /b > fonts.txt ran from the directory with your fonts are is the quickest way to make a list of your fonts
  • It doesn't generate any output (keeping silent/unattended installs in mind)
  • If both fonts.txt and fontinst.inf exist, it will use the newer and simpler fonts.txt by default (a file name specified using the /F switch always takes precedence, it will ignore either files then)
  • No error logging (don't want to write a log file to PC for something so trivial, and logging to current dir would not work when ran from optical media), nor did I want to make usage more complex by adding optional switches and parameters that don't really seem useful
  • Constants used only once are purposely not declared e.g. ssfFONTS, ForReading and TristateFalse

Questions, suggestions, bug reports, and everything in this thread please. Patches and bug fixes welcome too.
I can port it to other languages (vbscript, powershell, etc) as necessary.
crahak
This is a script meant to automatically change the theme and IPTC keywords used by Vista's Photo Gallery Screen Saver. You can make it either cycle through them, or use random ones.

This is the script I had said I'd share earlier in another thread.

The built-in "random" theme will select a random theme alright, but also from the ones you don't like so much. This script lets you decide from which ones it's chosen -- from the ones you like. Simply comment out the lines for the themes you don't like (i.e. add // in front of them) or even remove them if you prefer.

Personally I don't like the built-in random theme (most of the time it picks the ones I don't care for), or having to change it manually all the time (labor intensive), or always being stuck on the same one (gets stale). I use this to automatically cycle between my 3 or 4 favorite ones. Looks great all the time, and it never gets old.

It can also change (random or cycle) IPTC keywords used to select which photos to display. This way you can show photos with a certain theme for a while (like say, show landscapes), and then change it to something else later on. If you don't like that, then just leave useKeywords set to false. You have to manually enable the feature (by default, it won't change them -- see the comments in the code), and have set the screen saver to use tags in the first place too. This merely changes the keyword used by the screen saver.

Showing any old photo photos is a bit too random for my taste sometimes. I prefer seeing themed photos for a while (one day travel pics, the next day family pics, the day after photos of nice landscapes, etc).

I have the script scheduled to run everyday (at night), which is what I recommend to do. This way, you have a new theme (and possibly a new keyword, for a different style of photos) everyday.

Also, for keywords changer to work, you have to manually create a plain old text file called keywords.txt (place it where the script is), with the list of keywords you want it to use -- 1 per line, e.g.
CODE
nature
landscape
family
travel
sunset
flower
cityscape
animal

It will pick a keyword based on the contents on the file.

Now, the script itself:
CODE
/* =========================================================================
NAME: screensaver.js
PURPOSE: Cycle or randomly change themes and Keywords used by Vista's Photo Gallery Screen Saver
AUTHOR: user crahak from msfn.org forum
REVISIONS:
  1.00 2008-06-28, Initial Release
COMMENTS: Tested on Windows Vista SP1 en-US
LICENSE: Released under the GPLv3 License
============================================================================ */
var WshShell = WScript.CreateObject("WScript.Shell");
var fso = new ActiveXObject("Scripting.FileSystemObject");
var regPathTheme = "HKCU\\Software\\Microsoft\\Windows Photo Gallery\\Slideshow\\Screensaver\\Theme";
var regPathLabel = "HKCU\\Software\\Microsoft\\Windows Photo Gallery\\Slideshow\\Screensaver\\Label";
var curTheme = WshShell.RegRead(regPathTheme);
var curKeyword =  WshShell.RegRead(regPathLabel);

//set this to true for random choice, or false to cycle them
var randomTheme = true;
//set to true if you want to show photos based on IPTC Keywords instead of all photos
var useKeywords = false;
//if using IPTC Keywords, set this to true for random choice, or false to cycle them
var randomKeyword = true;
//name of the file that will contain your keywords to use
var keywordList = "keywords.txt"

//comment out the lines for the themes you don't want or don't like
var themes=new Array();
themes.push("{00000000-0000-0000-0000-000000000000}"); //Random
themes.push("{71ED30A7-499A-4F61-84F8-10CDEC657FE0}"); //Classic
themes.push("{773AFF18-2083-47C1-9EA9-A5DA346A0122}"); //Fade
themes.push("{B1CACF91-6F51-4533-BB28-B22D4E8A9C65}"); //Pan and Zoom
themes.push("{B9087BDF-F0F8-4454-A7D1-F6242E1654F8}"); //Black and white
themes.push("{F91A0A3F-3E4E-4273-88CC-6664834ACA6F}"); //Sepia
themes.push("{C84CFE1B-89DC-40E7-83BF-CB821255F9EC}"); //Album
themes.push("{AEE6C573-A192-4AF3-B62B-A4E6848533D3}"); //Collage
themes.push("{B4E10BE6-A2CE-4BEF-9D80-99995CB3C162}"); //Frame
themes.push("{5515D2B5-6825-409E-B377-544708C9DD06}"); //Glass
themes.push("{653E52D8-D033-469A-8BB5-9C1A164416D5}"); //Spin
themes.push("{D5561752-E5A7-46E7-B768-D945E144CA78}"); //Stack
themes.push("{CC4F1166-CE12-41F7-85E2-AE4744D9381B}"); //Travel
var numOfThemes = themes.length;

var keywords=new Array();
var numOfKeywords = 0
f = fso.GetFile(keywordList)
strm= f.OpenAsTextStream(1,0); //ForReading, TristateFalse (ASCII)
while(!strm.AtEndOfStream)
{
  keywords[numOfKeywords] = strm.ReadLine();
  numOfKeywords++;
}
strm.close();

if (randomTheme)
{
  var selTheme = Math.floor((numOfThemes) * Math.random()) // +1 ?
}
else
{
  selTheme = 0;
  for (i=0;i<numOfThemes;i++)
  {
    if (themes[i] == curTheme)  
    {
      selTheme = (i+1) % numOfThemes;
    }
  }
}
WshShell.RegWrite(regPathTheme, themes[selTheme], "REG_SZ");

if (useKeywords)
{
  if (randomKeyword)
  {
      var selKeyword = Math.floor((numOfKeywords) * Math.random())
  }
  else
  {
  selKeyword = 0;
  for (i=0;i<numOfKeywords;i++)
  {
    if (keywords[i] == curKeyword)  
    {
      selKeyword = (i+1) % numOfKeywords;
    }
  }
  }
  WshShell.RegWrite(regPathLabel, keywords[selKeyword], "REG_SZ");
}

(Again, it's JScript. I can port to other languages as necessary and such)

So there's a little bit of work involved in setting this up (like scheduling it to run by hand), but the result is totally worth it!
Google Internet Forums Unattended CD/DVD Guide
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.