views:

18

answers:

1

I created a Windows 7 Gadget and I need to create a place on each user's computer to store the Settings.ini file (Created from my SettingsManager.js file). The application packaging team at my company recommends I use

%LOCALAPPDATA%\Microsoft\Windows Sidebar\

and then add

Gadgets\iMon.Gadget\

subfolders. This is so each user's settings are stored in a unique location and won't be changed by any other applications or gadgets.

Do I need to use something along the lines of

var fso = new ActiveXObject("Scripting.FileSystemObject");
var folder = fso.CreateFolder("path");

Any help on how to do this would be appreciated.

Update: I found how to get the %localappdata% path, but I still need to create the new folder. Here's what I've tried without success:

var wshshell = new ActiveXObject("wscript.shell");
var localAppData = wshshell.ExpandEnvironmentStrings("%localappdata%");
var filePath = localAppData + "\\Microsoft\\Windows Sidebar\\Gadgets\\iMon.Gadget";
var fso = new ActiveXObject("Scripting.FileSystemObject");
var filePath = localAppData + "\\Microsoft\\Windows Sidebar\\Gadgets\\iMon.Gadget";
+1  A: 

I'm not sure I understand what you're trying to do here. is iMon.Gadget the name of your gadget? If so, this folder is automatically created for you upon installation of the gadget when the .gadget archive is executed. All the gadget's files and folders will be unpacked to

%LOCALAPPDATA\Microsoft\Windows Sidebar\Gadgets\iMon.gadget\

In your code, you can then proceed to manipulate files within this folder (and it's subfolders). To get the full path, you use

var gadgetPath = System.Gadget.path;

For example:

var oFile,
    gadgetPath = System.Gadget.path,
    oFSO = ActiveXObject("Scripting.FileSystemObject");

oFile = oFSO.CreateTextFile(gadgetPath, true);
oFile.WriteLine("Test.");
oFile.Close();
Andy E