W dniu 2015-10-29 o 15:48, Jacek W. pisze:
W dniu 2015-10-29 o 14:30, JU pisze:
System Windows 7 z wszystkimi łatami.
Co zrobić, aby poniższy *.bat zadziałał?:
cmd
cd c:\windows\system32\spool\printers
net stop spooler
del *.shd
del *.spl
net start spooler
exit
wykonuje tylko pierwsze cmd, pokazuje dosowe okienko i dalej nie
wykonuje żadnych poleceń.
--
Pozdrawiam: JU
Sorki - poprawka
Oczywiście linia
cd c:\windows\system32\spool\printers
też musi być, jeśli w DEL nie podajesz pełnej ścieżki
Nie
Chyba, że wszystko jest na jednej partycji.
Przykładowo coś takiego (nie całość, bo ktoś się przyczepi)
/*
restartSpooler.js
Skrypt przeznaczony do restartowania spoolera drukarki.
- bufor wydruku jest zamykany jeśli jest uruchomiony,
- kasowane są zadania drukowania,
- jeśli bufor wydruku był wystartowany go uruchamia
*/
/* ***********************************************************************
*
* Class definitions
*
* *********************************************************************** */
//
// Class Include
//
// Dołącza wybrany plik .js z określonej lokalizacji lub wyszukuje go
// i dołącza ze ścieżek, które są określone w zmiennej środowiskowej podanej
// jako parametr podczas tworzenia klasy. Defaultowo szuka na standardowych
// ścieżkach
// Zawartość pliku musi znajdować się w skrypcie, który tej klasy będzie
// używał.
// ***************************************************************************
var Include = function( strEnv )
{
var aPath = new Array();
function constructor( strEnv )
{
if( strEnv === undefined ||
typeof( strEnv ) != "string" ||
strEnv == "" )
{
aPath.push( "e:\\bin\\wsh" );
aPath.push( "e:\\bin\\wsh\\inc" );
}
if( aPath.length == 0 )
{
var oWShell = WScript.CreateObject( "WScript.Shell" );
var oEnv = oWShell.Environment( "PROCESS" );
var strTemp = oSysEnv( strEnv );
if( strTemp != "" )
{
var aspl = strTemp.split( ";" );
for( var i=0; i<aspl.length; i++ )
if( aspl[i] != "" )
aPath.push( aspl[i].replace( /(^\s*)|(\s*$)/g, "" ) );
}
}
for( var i=0; i<aPath.length; i++ )
if( aPath[i].substr( aPath.length - 1 ) != "\\" )
aPath[i] += "\\";
}
constructor( strEnv );
this.include = function( fname )
{
var path = "";
var fso = new ActiveXObject( "Scripting.FileSystemObject" );
if( fso.FileExists( fname ) )
path = fname;
else
{
for( var i=0; i<aPath.length; i++ )
{
if( fso.FileExists( aPath[i] + fname ) )
{
path = aPath[i] + fname;
break;
}
}
}
if( path == "" )
{
var str = "class Include: File [" + fname + "] not found in
path!\n\n.\\\n";
for( var i=0; i<aPath.length; i++ )
str += aPath[i] + "\n";
WScript.Echo( str );
WScript.Quit();
}
var fso = new ActiveXObject( "Scripting.FileSystemObject" );
try
{
var finc = fso.OpenTextFile( path );
var str = finc.ReadAll();
finc.Close();
return( str )
}
catch( err )
{
WScript.Echo( "class Include: Error [" + err.description + "]!" );
WScript.Quit();
}
}
/*
Example:
1.
var inc = new Include( "WHSINC" );
eval( inc.include( "funTests.js" ) );
eval( inc.include( "AllTrim.js" ) );
funTest1( 1 );
funTest2( "[" + AllTrim( " ala ma kota " ) + "]" );
2.
var inc = new Include();
eval( inc.include( "funTests.js" ) );
eval( inc.include( "AllTrim.js" ) );
funTest1( 1 );
funTest2( "[" + AllTrim( " ala ma kota " ) + "]" );
3.
var inc = new Include();
eval( inc.include( "e:\\bin\\wsh\\funTests.js" ) );
eval( inc.include( "e:\\bin\\wsh\\inc\\AllTrim.js" ) );
funTest1( 1 );
funTest2( "[" + AllTrim( " ala ma kota " ) + "]" );
*/
}
/* ***********************************************************************
*
* Main
*
* *********************************************************************** */
//
// include
// ==========================================================================
var oInc = new Include();
eval( oInc.include( "classServDev.js" ) );
eval( oInc.include( "GetEnv.js" ) );
eval( oInc.include( "SrvStart.js" ) );
eval( oInc.include( "DeleteFile.js" ) );
eval( oInc.include( "SrvStop.js" ) );
eval( oInc.include( "RunWin.js" ) );
//
// vars
// ==========================================================================
var strSpoolerPath = GetEnv( "SYSTEMROOT" ) +
"\\system32\\spool\\Printers\\*.*";
var strSpoolerService = "Spooler";
var oServices = new ServDev( "S" );
var lSpoolerRunning = false;
var strInfo = "";
//
// script
// ==========================================================================
if( oServices.status( strSpoolerService ) == 1 )
{
SrvStop( strSpoolerService );
lSpoolerRunning = true;
}
if( !DeleteFile( strSpoolerPath ) )
{
WScript.Echo( "Error deletoing spooler jobs file[s]!" );
WScript.Quit();
}
strInfo += "Spooler jobs deleted!\n";
if( lSpoolerRunning )
{
SrvStart( strSpoolerService );
strInfo += "Spooler is running!";
}
else
strInfo += "Spooler is stoped!";
WScript.Echo( strInfo );
--
Artur
|