Log in

View Full Version : NSCRIPTM EXAMPLE: Automatically cleaning the HX4700 after a Hard reset


yildi
06-17-2006, 12:01 AM
Hello,

I had enough of repeating the same optimizations time after time after each HR. So, I have given a look to nscriptm(*) for trying to automatize this process (Mennesys has also written earlier about this tool). The documentation of nscriptm is not very complete for now and I had to proceed by trial and error but I have a first simple script with some basic operations. If you are interested by the same operations as me, you could use it (please check the description at the beginning of the script, below). You can also suggest more optimisations (I will complete it later if I have time and, even if I am under WM2003, I am planning to include the Navpoint key in the cleaning, for the WM5 users).

(*) nscriptm is a free script engine for pocketpc written by the excellent programmers who develop SK Tools and SK Menu. You can download it from SK Software's web site: http://www.s-k-tools.com/util.html or, directly through http://s-k-tools.com/freeware/nscriptm.zip.

I paste the script below in this message. It also give examples of some functions of nscriptm not very well documented and for which I had to do some trial and error experiments. You can adapt it quite easily for similar needs (its is copyleft, of course :)).

This script does the following:

1/ Clean Dockware? -> When you say "Yes" to this question ->
1.a/ Delete the following registry keys:
- HKEY_CURRENT_USER\Software\Ilium Software\Dockware
- HKEY_CURRENT_USER\Software\Ilium Software
1.b/ Delete folder \\Program Files\\Dockware

2/ Erase My Pictures? - > When you say "Yes" to this question
Delete the folder \\My Documents\\My Pictures where Dockware puts its trash (if you use it for storing other pictures, just say "No").

3/ Remove HP Mobile Printing? -> If you say "YES":
3.a/ Delete the following keys under HKEY_LOCAL_MACHINE:
- \\SOFTWARE\\Microsoft\\PimApps\\PimExtensions\\Cal endar\\AddIns\\HP Mobile Printing
- \\SOFTWARE\\Microsoft\\PimApps\\PimExtensions\\Con tacts\\AddIns\\HP Mobile Printing
- \\SOFTWARE\\Microsoft\\PimApps\\PimExtensions\\Tas ks\\AddIns\\HP Mobile Printing
- \\SOFTWARE\\HP\\MobilePrinting
- \\SOFTWARE\\HP\\MobilePrint
3.b/ Delete folders:
- \\Program Files\\HP Mobile Printing
- \\Program Files\\Hewlett-Packard

4/ Remove BT Phone Manager? -> If you say "YES"
4.a/ Delete keys
- HKEY_CURRENT_USER\\Software\\BVRP\\BTPhoneManager
- HKEY_CURRENT_USER\\Software\\BVRP
4.b/ Delete folder \\Program Files\\BTPhoneManager

5/ Move html help files from Main memory (Windows folder)? ->
5.a/ Lets you choose a folder to which
5.b/ every file with the extension .htm in the \WINDOWS folder will be moved.
It tells you how many files it has moved.
6/ "FINISHED" - Ta da! :)

Before using it please make a full backup of your RAM on a non-volatile memory (IFS, SD or CF). Using this back up, you can reverse everything in 5 minutes if you do not like the final result (just make a HR and restore from your backup).

Here is the script:

/* Script for cleaning and HX4700 after a hard reset.

It optionnally erases (you will be given the choice for each possibility) registry values and folders
corresponding to:
- Dockware
- HP Mobile Printing
- BT Phone Manager.

You will also have the possibility of moving all help files to a folder of your choice.

You can run it to check the possibilities it gives. If you answer "No" to the questions, it will not touch anything in your PDA.

Simple usage:

1/ Download Nscriptm from SK Software's web site:
http://www.s-k-tools.com/util.html
or, directly
http://s-k-tools.com/freeware/nscriptm.zip

2/ Unzip this archive and copy ns.exe from the subfolder ARMPPC to a folder of choice on your 4700 (it is very small,
you can for example put it in \iPAQ File Store\nscriptm
3/ Copy cleanpda.ns to the same folder
4/ Launch ns.exe by double-cliking on it in the file explorer
5/ Choose File/open and load the cleanpda.ns script from its folder.
6/ Answer the on-screen question for each possibility and it will clean the corresponding items.
Author: Murat Yildizoglu
You can contact me, using this forum, for any comment or suggestion.
THE USUAL CAVEAT APPLIES: If you use this script, I can not be considered as responsible for
any damage it could cause (even if it should not cause any damage if you understand what you do).
*/
function main()
{
decision = 0;
result = 99;
// Clean Dockware

decision = msgbox("Remove Dockware?","Please confirm",3);
if (decision == 6)
{
decision = 0;
//Delete Registry keys

key="HKEY_CURRENT_USER";
subkey="\\Software\\Ilium Software";
result = rgdeletekey(key,subkey,"Dockware");
if(result == 0){
msgbox ("Key erased", "Results", 0);
}
else{
msgbox ("Unable to erase the key: %xx%", "Result", 0);
}
subkey="\\Software";
result = rgdeletekey(key,subkey,"Ilium Software");
if(result == 0){
msgbox ("Key erased", "Results", 0);
}
else{
msgbox ("Unable to erase the key: %xx%", "Result", 0);
}

// Delete Folders
path = "\\Program Files\\Dockware";
if(RemoveDirectory(path) == -1){
msgbox("Can't remove directory \"%path%\"","Result",0);
}
else{
msgbox(" \"%path%\" erased!","Result",0);
}

decision = msgbox("Erase My Pictures?","Please confirm",3);

if (decision == 6)
{
decision = 0;
path = "\\My Documents\\My Pictures";

if(RemoveDirectory(path) == -1){
msgbox("Can't remove directory \"%path%\"","Result",0);
}
else{
msgbox(" \"%path%\" erased!","Result",0);
}
result = 99


}
}

// Clean HP Mobile printing
decision = msgbox("Remove HP Mobile Printing?","Please confirm",3);
if (decision == 6)
{
decision = 0;

//Delete Registry keys

key="HKEY_LOCAL_MACHINE";

subkey="\\SOFTWARE\\Microsoft\\PimApps\\PimExtensions\\Calendar\\AddIns";
result = rgdeletekey(key,subkey,"HP Mobile Printing");
if(result==0){
msgbox ("Calendar extension Key erased", "Results", 0);
}
else{
msgbox ("Unable to erase the key1", "Result", 0);
}
result = 99;

subkey="\\SOFTWARE\\Microsoft\\PimApps\\PimExtensions\\Contacts\\AddIns";
result = rgdeletekey(key,subkey,"HP Mobile Printing");
if(result == 0){
msgbox ("Contacts extension Key erased", "Results", 0);
}
else{
msgbox ("Unable to erase the key2", "Result", 0);
}
result = 99;

subkey="\\SOFTWARE\\Microsoft\\PimApps\\PimExtensions\\Tasks\\AddIns";
result = rgdeletekey(key,subkey,"HP Mobile Printing");
if(result == 0){
msgbox ("Tasks extension Key erased", "Results", 0);
}
else{
msgbox ("Unable to erase the key3", "Result", 0);
}
result = 99;

subkey="\\SOFTWARE\\HP";
result = rgdeletekey(key,subkey,"MobilePrinting");
if(result == 0){
msgbox ("%subkey%\MobilePrinting key erased", "Results", 0);
}
else{
msgbox ("Unable to erase the key4", "Result", 0);
}
result = 99;

subkey="\\SOFTWARE\\HP";
result = rgdeletekey(key,subkey,"MobilePrint");
if(result == 0){
msgbox ("%subkey%\MobilePrint erased", "Results", 0);
}
else{
msgbox ("Unable to erase the key5", "Result", 0);
}
result = 99 ;

// Delete Folders
path = "\\Program Files\\HP Mobile Printing";
if(RemoveDirectory(path) == -1){
msgbox("Can't remove directory \"%path%\"","Result",0);
}
else{
msgbox(" \"%path%\" erased!","Result",0);
}
result = 99;

path = "\\Program Files\\Hewlett-Packard";
if(RemoveDirectory(path) == -1){
msgbox("Can't remove directory \"%path%\"","Result",0);
}
else{
msgbox(" \"%path%\" erased!","Result",0);
}
}

// Remove BT Phone Manager

decision = msgbox("Remove BT Phone Manager?","Please confirm",3);
if (decision == 6)
{
decision = 0;

//Delete Registry keys

key="HKEY_CURRENT_USER";
subkey="\\Software\\BVRP";
result = rgdeletekey(key,subkey,"BTPhoneManager");
if(result == 0){
msgbox ("%subkey%\BTPhoneManager Key erased", "Results", 0);
}
else{
msgbox ("Unable to erase the key", "Result", 0);
}
result = 99;

subkey="\\Software";
result = rgdeletekey(key,subkey,"BVRP");
if(result == 0){
msgbox ("%subkey%\BVRP Key erased", "Results", 0);
}
else{
msgbox ("Unable to erase the key", "Result", 0);
}
result = 99;

// Delete Folders
path = "\\Program Files\\BTPhoneManager";
if(RemoveDirectory(path) == -1){
msgbox("Can't remove directory \"%path%\"","Result",0);
}
else{
msgbox(" \"%path%\" erased!","Result",0);
}
}

decision = msgbox("Move html help files from Main memory (Windows folder)?","Please confirm",3);

if (decision == 6)
{
decision = 0;
to = folderdialog ("Chose the receiving folder");
from = "\\Windows\\*.htm";

var hfind;
var name;
var countFiles = 1;

//Find start
hfind = FileFindInit(from);
if(hfind == 0){
msgbox(" No corresponding files in Windows","Moving help files",0);
}
do
{
name = FileFindName(hfind);
result = MoveFile("\\Windows\\%name%",to);
if (result == 0)
{
countFiles++;
}
} while(FileFindNext(hfind) == 1);
//Find end
FileFindClose(hfind);

msgbox(" Moved: %countFiles% files","Result",0);

}

msgbox(" FINISHED!","End",0);

}
[/code]