--- wpkg.js.97test1.org	2006-03-20 13:44:44.000000000 +0100
+++ wpkg.js	2006-03-20 17:13:08.000000000 +0100
@@ -53,6 +53,12 @@
  * /noreboot
  *     System does not reboot regardless of need.
  *
+ * /rebootcmd:<option>
+ *     Use the specified boot command, either with full path or
+ *     relative to location of wpkg.js
+ *     Specifying "special" as option uses wpkg\psshutdown.exe
+ *     from www.sysinternals.com - if it exists - and a notification loop
+ *
  * /force
  *     Uses force when performing actions (does no honour wpkg.xml).
  *
@@ -101,6 +107,7 @@
 
 var nonotify = false;
 var noreboot = false;
+var rebootCmd = "standard";
 
 var packagesDocument;
 var profilesDocument;
@@ -205,6 +212,10 @@
         forceInstall = false;
     }
     
+    if (argn("rebootcmd") != null) {
+        rebootCmd=(argn("rebootcmd"));
+        if (debug)  info("Reboot-Cmd is " + rebootCmd +".");
+    }
     
     // will use the fso a bit
     var fso = new ActiveXObject("Scripting.FileSystemObject");
@@ -397,6 +408,9 @@
     message += "/noreboot\n";
     message += "   System does not reboot regardless of need.\n";
     message += "\n";
+    message += "/rebootcmd:<filename>\n";
+    message += "   Use the specified reboot command\n"
+    message += "\n";
     message += "/force\n";
     message += "    Uses force when performing actions.\n";
     message += "\n";
@@ -2162,17 +2176,39 @@
 /**
  * Reboots the system.
   */
-function oldreboot() {
+function reboot() {
     if (!noreboot ) {
-	var wmi = GetObject("winmgmts:{(Shutdown)}//./root/cimv2");
-	var win = wmi.ExecQuery("select * from Win32_OperatingSystem where Primary=true");
-	var e = new Enumerator(win);
-
-	info("System reboot in progress!");
-
-	for (; !e.atEnd(); e.moveNext()) {
-	    var x = e.item();
-	    x.win32Shutdown(6);
+      var fso = new ActiveXObject("Scripting.FileSystemObject");
+      switch (rebootCmd) {
+        case "standard":
+		{	       
+		  var wmi = GetObject("winmgmts:{(Shutdown)}//./root/cimv2");
+		  var win = wmi.ExecQuery("select * from Win32_OperatingSystem where Primary=true");
+		  var e = new Enumerator(win);
+	
+		  info("System reboot in progress!");
+	
+		  for (; !e.atEnd(); e.moveNext()) {
+		    var x = e.item();
+		    x.win32Shutdown(6);
+		  }
+	        }
+		break;
+        case "special":
+                       psreboot();
+                       break;
+	default:
+          	if (!fso.fileExists(rebootCmd)) {
+                    var path = WScript.ScriptFullName;
+                    base = fso.GetParentFolderName(path);
+        	    rebootCmd = fso.BuildPath(base, rebootCmd);
+        	    if (!fso.fileExists(rebootCmd)) {
+        	      throw new Error("Could not locate rebootCmd " + rebootCmd + ".");
+		    } 
+		} 
+          	info("Running a shutdown command: "+rebootCmd);
+          	exec(rebootCmd,0); 
+	  	break;
 	}
 /**    } else if (pretend) {
 	info("REBOOT");
@@ -2187,7 +2223,7 @@
 /**
  * Reboots the system.
  */
-function reboot() {
+function psreboot() {
     if (!noreboot ) {
 
     // RFL prefers shutdown tool to this method: allows user to cancel
@@ -2196,7 +2232,18 @@
     var cmd;
     var msg="Rebooting to complete software installation. Please note that "+
             "some software might not work until the machine is rebooted."
-    var shutdown="\\\\spd\\wpkg\\psshutdown -r ";
+    // overwrites global variable rebootcmd !   
+    var rebootCmd="wpkg\\psshutdown.exe"
+    var fso = new ActiveXObject("Scripting.FileSystemObject");
+    	if (!fso.fileExists(rebootCmd)) {
+            var path = WScript.ScriptFullName;
+            base = fso.GetParentFolderName(path);
+            rebootCmd = fso.BuildPath(base, rebootCmd);
+            if (!fso.fileExists(rebootCmd)) {
+              throw new Error("Could not locate rebootCmd " + rebootCmd + ".");
+	    } 
+	} 
+    var shutdown=rebootCmd + " -r ";
 
     for (i=60; i!=0; i=i-1) {
         // This could be cancelled
