I think, these things should be introduced a bit more customizable, e.g.
as commandline switch:

wpkg.js /shutdownmethod:"%0\..\wpkg\my-shutdown-command.whatever"

If wpkg.js handles this itself it could be shortened to
 wpkg.js /shutdownmethod:"wpkg\my-shutdown-command.whatever"
but this is a bit less flexible.

Without this switch the normal behaviour should be as in 0.9.5 of course.

Other projects even do it this way:
... -r"myscript -option1 -option2" -r"myotherscript -option" ...

Just my 2ยข. If I have time on monday I'll send a patch.

I had no time, but here is the patch:

- without option /rebootcmd -> normal behaviour

- with option /rebootcmd:special
 -> looks if it can find wpkg\psshutdown.exe and uses the loop from Frank

- with option /rebootcmd:wpkg\myshutdown.bat _or_
  option   /rebootcmd:\\server\share\myshutdown.bat
 it uses this for reboot



Someone confused? Drop me a mail ...

Falko
--- 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

Reply via email to