Skip to content
View in the app

A better way to browse. Learn more.

MSFN

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

One last problem with my config

Featured Replies

I have nearly perfected my server build but am having issues with one last thing.

I have created a script to create a D: partition and want WPI to disable the checkbox if D: is not present.

At the moment I have the following, which for some reason does not disable the checkbox if D: is a CD-ROM. The CDROM Dependancy currently maps the CD-Rom to X:

prog[pn]=['Create D: Partition'];
ordr[pn]=[2];
uid[pn]=['CREATEDPARTITION'];
dflt[pn]=['yes'];
cat[pn]=['System'];
forc[pn]=['no'];
deps[pn]=['CDROM'];
gcond[pn]=['DriveExists("D:") && FileExists("D:\\pagefile.sys")'];
cmd1[pn]=['hidecmd /w cscript c:\\build\\scripts\\partition.vbs //B'];
pn++;

Ideally I would like a DriveType() function to determine what type of drive D: is, like this

prog[pn]=['Create D: Partition'];
ordr[pn]=[2];
uid[pn]=['CREATEDPARTITION'];
dflt[pn]=['yes'];
cat[pn]=['System'];
forc[pn]=['no'];
deps[pn]=['CDROM'];
gcond[pn]=['DriveExists("D:") && DriveType("Fixed")'];
cmd1[pn]=['hidecmd /w cscript c:\\build\\scripts\\partition.vbs //B'];
pn++;

Am I missing something, why is my config not disabling the option when D: is a CD-ROM?

Cheers.

Edited by tcarman

This wasn't too hard to implement so I went ahead and created two functions: DriveExists(drive) and DriveType(drive).

Pass a drive letter (no colon[:]) to DriveExists() and it will return true or false.

Pass a drive letter (no colon[:]) to DriveType() and it will return one of six values:

UNKNOWN - The drive exists, but the type is unknown.

REMOVEABLE - The drive exists and is removeable (i.e. USB attached drive)

FIXED - The drive exists and is a fixed hard drive partition.

NETWORK - The drive exists and is mapped to a network share.

CDROM - The drive exists and is an optical drive.

RAMDISK - The drive exists and is a memory allocated drive.

NULL - The drive does not exist.

Note: All returned values from DriveType() are in uppercase.

Here are the two functions. Either add them to core.js or download the modified core.js.

function DriveExists(dr)
{
position="core.js";
whatfunc="DriveExists()";
var en, ite;

en = new Enumerator(fso.Drives);
for(; !en.atEnd(); en.moveNext())
{
ite = en.item();
if (ite.DriveLetter == dr.toUpperCase())
return true;
}

return false;
}

function DriveType(dr)
{
position="core.js";
whatfunc="DriveType()";
var driv;

if(DriveExists(dr))
{
driv = fso.GetDrive(dr);
switch(driv.DriveType)
{
case 0: return 'UNKNOWN';
case 1: return 'REMOVEABLE';
case 2: return 'FIXED';
case 3: return 'NETWORK';
case 4: return 'CDROM';
case 5: return 'RAMDISK';
}
}

return NULL;
}

@tcarman your gcond would be the following:

gcond[pn]=['DriveType("D")=="FIXED"'];

This will check if the drive exists and if it is a fixed partition.

Modified core.js file:

Edited by mritter

  • Author

Excellent. Thanks very much zorphnog. I will test it out.

Cheers.

  • Author

This works great. Thanks.

I want to learn to write my own functions based on WMI queries. I am a total noob in JScript but can understand VBScript.

Someone had mentioned WPI has some WMI built in ??

How do I go about writing my own functions in Jscript for WPI?

Thanks for the help.

Edited by tcarman

If you know VBScript then you should be good. JScript and VBScript are interchangeable except for some syntax differences. I'm not a JScript expert by far. I just kind of learn things as I need them.

I guess the best thing to do is go through all of the WPI code to get a feel for how to do things. It takes a while to do, but thats how I learned.

  • Author
function DriveExists(dr)
{
position="core.js";
whatfunc="DriveExists()";
var en, ite;

en = new Enumerator(fso.Drives); // This is the line that I need further clarification on ?!?
for(; !en.atEnd(); en.moveNext())
{
ite = en.item();
if (ite.DriveLetter == dr.toUpperCase())
return true;
}

return false;
}

Nice code, Zorphnog. But I have already written code for those functions. Use the above code if you want, but it won't be the same for 5.5.

@tcarman: I don't know how much you know about programming or what languages you know, but an enumerator is a common operator across all languages. It basically allows you to step through a list of results one item at a time. In this case fso.Drives (fso is a FileSystemObject that is declared globally in WPI) is a list of all drives on the system. The for loop steps through each drive using the moveNext() function. When en.item() is called it returns a Drive object and we can then compare the drive letter to the one that was passed to the function.

@mritter: I figured you would already be working on these, but he needed a solution and it only took me a couple of minutes to put together.

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.