From: <[EMAIL PROTECTED]>
> Perl2bat creates the batch file below. However, running it on my local
> machine does not delete the registry key. Is there anything I'm
> missing?
> 
> @rem = '--*-Perl-*--
> @echo off
> if "%OS%" == "Windows_NT" goto WinNT
> perl -x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9
> goto endofperl
> :WinNT
> perl -x -S %0 %*
> if NOT "%COMSPEC%" == "%SystemRoot%\system32\cmd.exe" goto endofperl
> if %errorlevel% == 9009 echo You do not have Perl in your PATH. if
> errorlevel 1 goto script_failed_so_exit_with_non_zero_val 2>nul goto
> endofperl @rem '; #!C:\perl\bin\perl #line 15
>   use Win32::Registry
>   $HKEY_LOCAL_MACHINE->DeleteValue($AutoShareWks);
> 
> Win32::Registry::DeleteValue('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControl
> Se t\Services\lanmanserver\parameters', $AutoShareWks);
> 
> 
> __END__
> :endofperl

You should add some code that will create a log file or something 
just to make sure the code was run.

You should also check whether the DeleteValue() succeeded.

It's possible that the account under which the script ran did not 
have enough permissions to make the change.

If you will then run this from the login with Perl installed on a 
server share you will have to modify the start of the BAT like this:

@rem = '--*-Perl-*--
@echo off
net use W: \\server\tools
if "%OS%" == "Windows_NT" goto WinNT
w:\perl\bin\perl -x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9
goto endofperl
:WinNT
w:\perl\bin\perl -x -S %0 %*
if NOT "%COMSPEC%" == "%SystemRoot%\system32\cmd.exe" goto endofperl
if %errorlevel% == 9009 echo You do not have Perl in your PATH.
if errorlevel 1 goto script_failed_so_exit_with_non_zero_val 2>nul
goto endofperl
@rem ';
#!C:\perl\bin\perl 
#line 16
...


Jenda
P.S.: Please do not CC: me on emails sent to the group.
===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
        -- Terry Pratchett in Sourcery


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to