donfodi has asked for the wisdom of the Perl Monks concerning the following question:

Hi to all , i have a script of for burning DVD on onther pc , but it's only set to burn DVD+RW disks , i want to burn on any disc format , or at least DVD-R , below is the script :
#!/perl/bin -w ###################################################################### +#### # This script will start burn action # ###################################################################### +#### use strict; use File::Path; sub cleanup_virt_dvd; sub set_read_only; sub remove_read_only; sub eject_dvd; sub cleanup_emergency_dvd; sub cleanup_buffer; my $dvd_drive_letter = "z"; my $command = ""; my $applications_dir = "c:\\nmr\\applications"; my $XCACLS_path = "xcacls.exe"; my $second_hdd = "x:\\"; print("Burn action is called with the next parameters:\n"); print("\tVirtualDVD - $ARGV[1]\n"); print("\tAction type - $ARGV[2]\n"); print("\tMedia type - $ARGV[3]\n"); print("\tBurn8x flag - $ARGV[4]\n"); print("\tBurnDV flag - $ARGV[5]\n"); if ($ARGV[2] == 2) { # Cleanup Virtual DVD without burning print("Perform Virtual DVD cleanup without burning.\n"); if (cleanup_emergency_dvd($ARGV[1]) == 1) { print("Virtual DVD cleanup succeed.\n"); } } else { my $neroDir = $ENV{"ProgramFiles"}."\\Ahead\\Nero"; $neroDir =~ s|\\|/|g; if (chdir("$neroDir") == 0) { print "ERROR: Nero Package is not installed !\n"; exit; } if ($ENV{"GyroConfigTemp"} eq "") { # This is DVD PC $XCACLS_path = "c:\\nmr\\xcacls.exe"; $dvd_drive_letter = "y"; } #Make virtual DVD read-only set_read_only($ARGV[1]); my $media_supported = 0; my $media_type = $ARGV[3]; my $burn_8x = $ARGV[4]; my $burn_dicom_viewer = $ARGV[5]; $command = system("dir $dvd_drive_letter: 1>>nul"); if ($command == 0) { print "ERROR: Disc is not present or not empty.\n"; remove_read_only($ARGV[1]); eject_dvd(); exit; } print "Supported media: $media_type\n"; if ($media_type eq "ALL") { $media_supported = 0; } else { $command = "nerocmd.exe --discinfo --drivename $dvd_drive_lett +er"; print "Checking media type ...\n"; if (open( NERO, "$command|")) { my $first_line = <NERO>; chomp( $first_line); close( NERO); print "Found: $first_line\n"; if (index($first_line,$media_type) != -1) { $command = "nerocmd.exe --get_speeds --media_type medi +a_dvd_p_rw --drivename $dvd_drive_letter"; print "Checking media speed ...\n"; if (open( NERO, "$command|")) { while (<NERO>) { if (/^Write speeds :/) { if (/4$/) { print; $media_supported = 0; } else { if (($burn_8x ne "DISABLE") && (/8$/)) { print; $media_supported = 1; } else { print; } } } next; } } else { print "ERROR: Could not get media speed!"; remove_read_only($ARGV[1]); eject_dvd(); exit; } close( NERO); } } else { print "ERROR: Could not get media type!"; remove_read_only($ARGV[1]); eject_dvd(); exit; } } if ($media_supported) { my $source_location = ""; my $result = 1; if (-e $second_hdd) { $source_location = $second_hdd."\\buffer"; print("Copy data to the temporary HDD...\n"); $command = "xcopy /e/q/y $ARGV[1] $source_location\\"; $result = system($command); if ($result == 0) { set_read_only($source_location); } } else { $source_location = $ARGV[1]; $result = 0; } if ($result == 0) { my $extra_dir = ""; if ($burn_dicom_viewer) { $extra_dir = "$applications_dir\\*"; } #Start burn command $command = "nerocmd.exe $ARGV[0] --drivename $dvd_drive_le +tter $source_location\\* $extra_dir --recursive"; $result = system($command); remove_read_only($ARGV[1]); if (-e $second_hdd) { remove_read_only($source_location); cleanup_buffer($source_location); } if ($result == 0) { if ($ARGV[2] == 1) { # no cleanup print("Burn operation succeed.\n"); } else { if (cleanup_virt_dvd($ARGV[1]) == 1) { print("Burn operation succeed.\n"); } } } else { print("ERROR: Burn operation failed.\n"); } } else { print "ERROR: Could not copy data to the temporary HDD!\n" +; remove_read_only($ARGV[1]); } } else { print "ERROR: Unsupported media type or disc is not present!\n +"; remove_read_only($ARGV[1]); eject_dvd(); } } ###################################################################### +#### # This cleans up the Virtual DVD ###################################################################### +#### sub cleanup_virt_dvd() { my $result = 0; my $delete = 0; my $virt_dvd_path = shift; if (-f "$virt_dvd_path\\DICOMDIR") { if (unlink("$virt_dvd_path\\DICOMDIR")) { $delete = 1; } else { print "$virt_dvd_path\\DICOMDIR is locked.\n"; } } else { $delete = 1; } if ($delete) { if ( rmtree($virt_dvd_path, 0, 1) == 0) { print("ERROR: Virtual DVD cleanup failed!\n"); } else { $result = 1; } mkdir($virt_dvd_path); } return $result; } ###################################################################### +#### # This set read-only attribute from the Virtual DVD ###################################################################### +#### sub set_read_only() { my $virt_dvd_path = shift; system("$XCACLS_path $virt_dvd_path /T /G Everyone:R MRSystem:F SY +STEM:P /Y 2>>nul 1>>nul"); } ###################################################################### +#### # This removes read-only attribute from the Virtual DVD ###################################################################### +#### sub remove_read_only() { my $virt_dvd_path = shift; system("$XCACLS_path $virt_dvd_path /T /G Everyone:F /Y 2>>nul 1>> +nul"); } ###################################################################### +#### # This ejects DVD ###################################################################### +#### sub eject_dvd() { system("nerocmd.exe --eject --drivename $dvd_drive_letter >nul"); } ###################################################################### +#### # This cleans up the Emergency DVD ###################################################################### +#### sub cleanup_emergency_dvd() { my $result = 0; my $idx = 0; my $virt_dvd_path = shift; my $remove_dir = "$virt_dvd_path"."_remove"; system("move $virt_dvd_path $remove_dir"); while(!mkdir($virt_dvd_path) && ($idx < 10)) { print "Can not create $virt_dvd_path\n"; sleep 1; $idx++; } if ( rmtree($remove_dir, 0, 1) == 0) { print("ERROR: Virtual DVD cleanup failed!\n"); } else { $result = 1; } return $result; } ###################################################################### +#### # This cleans up the Buffer partition ###################################################################### +#### sub cleanup_buffer() { my $result = 0; my $idx = 0; my $buffer_path = shift; my $remove_dir = "$buffer_path"."_remove"; system("move $buffer_path $remove_dir"); while(!mkdir($buffer_path) && ($idx < 10)) { print "Can not create $buffer_path\n"; sleep 1; $idx++; } if ( rmtree($remove_dir, 0, 1) == 0) { print("ERROR: Buffer partition cleanup failed!\n"); } else { $result = 1; } return $result; } #

Replies are listed 'Best First'.
Re: Editing setting
by GotToBTru (Prior) on Apr 21, 2016 at 11:53 UTC

    This is more of a Nero question than a Perl question. There are plenty of examples in this code of how to interact with the nerocmd.exe program. Please add code tags; it is just about unreadable as is.

    1. What would be the command line syntax for the tasks you want to do?
    2. Do you have specific questions about what certain statements do?

    But God demonstrates His own love toward us, in that while we were yet sinners, Christ died for us. Romans 5:8 (NASB)

      i'm sorry for not putting the code tag , thanks for notifying me . so i should edit nero setting ??

        Did you write this script? It would benefit from documentation.

        What makes you think this will not burn your desired media? Can you give an example of the command line you are using? As long as your 4th argument matches what nerocmd.exe would report as the media type of your DVD, it looks to me like it should work. Unless there is some limitation on nerocmd.

        But God demonstrates His own love toward us, in that while we were yet sinners, Christ died for us. Romans 5:8 (NASB)