Reply by skybuck2000 November 19, 20212021-11-19
The idea to enable history is brilliant ! (Can be done on the far right side of the screen in task schedular when main thing selected.)

Now I can see if there are any error messages, I did notice one and googled it.

It kinda makes sense, the task was trying to run under "user"... I am not very familiar with selecting any other object.

But I managed to set it to "SYSTEM" by simply typing that in which object to use/select.

The coming days I will observe if this technique fix the problem with calling diskpart directly:

diskpart /s "path to script.txt"

In case that somehow fails then another idea could be to call a batch file instead which gives more powerfull possibilities:

mountvhd.bat e: "path to script.txt"

For that purpose I implemented some of you Paul's ideas and also included a timeout loop, it will wait 60 seconds, here is the mountvhd.bat batch script:

@echo off
SET /A "index = 1"
SET /A "count = 60"
:while
if %index% leq %count% (
   echo Waiting 60 seconds for drive %1 to come online, seconds waited: %index%
   SET /A "index = index + 1"
   timeout /t 1 /nobreak>nul

   vol %1 >nul 2>nul
   REM echo %1
   if errorlevel 1 (
     REM    echo IT DOES NOT EXIST
   ) else (
     REM    echo IT EXISTS
     diskpart /s %2
     REM echo %2
     exit
   )   
   goto :while
)

For now I will not use this script because first I want to observe if there are any problems with the direct diskpart method... and ofcourse if the usb drive is unplugged then no cookie... but I also dont want to see any batch file/cmd prompt windows during start so that is why I may prefer the direct diskpart method, here is once more the diskpart script:

C:\Scripts\SomeScript.txt:
select vdisk file="E:\FileDiskImages\MusicConsolidationV2.vhd"
attach vdisk
assign letter=F

Anyway the mountvhd.bat works with two parameters:

The drive letter which must match the script above... in the first line... and then diskpart script filename/path:

so for example to use the mountvhd.bat it would be invoked as follows:

MountVHD.bat E: "C:\Scripts\SomeScript.txt"

I tested the mountvhd.bat in cmd.exe, not sure if it will work with taskplanner, it may suffer the same problem as before... it may need to run from system object instead of user...

the benefit of system object is it requires no annoying password, so that is why I prefer that method... with maximum rights etc...

Anyway I am not sure about the " " quotes but that should work.

I tested mountvhd.bat in taskschedular once... seemed to work, but not sure... so use it on your own risk ! ;) :)

Maybe both scripts can be integrated into one, that would be nice, then the parameters would work better.

So this script could use some more work... it's a bit crude ;) =D

(Posting this one day later, today the diskpart method worked again, so all seems fine for now, so maybe this bigger script is not necessary, time will tell ! ;) it could still be handy for people that like plugging usb drives into their machines and want it to automount within 60 seconds lol.)

Bye for now,
  Skybuck.
Reply by skybuck2000 November 17, 20212021-11-17
Sometimes Virtual Harddisk Images don't mount in Windows 7.

Currently these VHDs are on a usb drive. Perhaps the usb drive is not detected yet during boot and causes the mounting of the VHDs to fail.

However I have seen same behaviour with actualy build in harddisks.

Perhaps same problems. Harddisk not detected during boot ? Seems strange... perhaps ntfs file system not yet fully mounted/available ?

Anyway this is the script that is added to task schedular:

Stored in a file called Script.txt whatever..:

select vdisk file="E:\FileDiskImages\MusicConsolidationV2.vhd"
attach vdisk
assign letter=F

This script is supposed to run during bootup in task schedular..

Is there any way to do this more reliably ?!?!?

Notice the E: drive is an usb drive.

Bye for now,
  Skybuck.