• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

Batch file

Sandeep Bhugoo

New Member
Joined
Jun 19, 2014
Messages
6 (0.00/day)
hello,

i am not so good in creating batch files i need some help in creating one.

in the following path

C:\Windows\System32\spool\PRINTERS

there is a .SHD and .SPL file created when prints launched

i need a batch file to open the .SPL in notepad first then on closing the notepad opened, all the files .SHD and .SPL are permanently deleted

any help please

code to open the notepad is as below

start notepad "C:\windows\system32\spool\printers\FP00002.SPL"

the file is opened but there are unwanted characters that appear as well as below

upload_2014-6-19_10-43-2.png
 
Joined
May 1, 2008
Messages
1,039 (0.18/day)
Location
Frankfurt/Main - Germany
System Name Shaman of Sexy
Processor AMD Phenom II X4 955 BE@4Ghz EK Supreme Block
Motherboard M3A79-T Deluxe Anfi-Tech Waterblocks
Cooling Magicool 360 + 120 + 120 Slim scythe slipped Laing DDC-1/T
Memory 4GB Corsair Dominator CM2X2048-8500C5D
Video Card(s) Sapphire ATI Radeon HD 4870 X2 EK 4870 X2 Block
Storage RAID 0 Seagate
Display(s) Samsung 226BW 22"
Case CoolerMaster Cosmos RC-1000 in mod progress
Audio Device(s) onboard
Power Supply Coba Nitrox 750W
Software Windows 7 Ultimate
Benchmark Scores http://service.futuremark.com/compare?3dmv=1056967

Sandeep Bhugoo

New Member
Joined
Jun 19, 2014
Messages
6 (0.00/day)
in fact when i reset a user password it is supposed to print the generated password to a printer but i don't want to print it. i want the batch file to open the .spl file generated in notepad, i note the password then on closing the notepad, the files .shd and .spl are deleted permanently from the folder
 
Joined
May 1, 2008
Messages
1,039 (0.18/day)
Location
Frankfurt/Main - Germany
System Name Shaman of Sexy
Processor AMD Phenom II X4 955 BE@4Ghz EK Supreme Block
Motherboard M3A79-T Deluxe Anfi-Tech Waterblocks
Cooling Magicool 360 + 120 + 120 Slim scythe slipped Laing DDC-1/T
Memory 4GB Corsair Dominator CM2X2048-8500C5D
Video Card(s) Sapphire ATI Radeon HD 4870 X2 EK 4870 X2 Block
Storage RAID 0 Seagate
Display(s) Samsung 226BW 22"
Case CoolerMaster Cosmos RC-1000 in mod progress
Audio Device(s) onboard
Power Supply Coba Nitrox 750W
Software Windows 7 Ultimate
Benchmark Scores http://service.futuremark.com/compare?3dmv=1056967
if you need to clear spooler cache try this:


Code:
@Echo OFF
CLS
net stop spooler
del c:\system32\spool\printers\*.shd
del c:\system32\spool\printers\*.spl
net start spooler

much nicer using %windir% variable:

Code:
net stop spooler
del %windir%\system32\spool\printers\*.shd
del %windir%\system32\spool\printers\*.spl
net start spooler

i don´t think you can read it as plain text
also here is an emf/spl viewer
http://www.fengyuan.com/download.html (emf.zip)
 
Last edited:

Sandeep Bhugoo

New Member
Joined
Jun 19, 2014
Messages
6 (0.00/day)
thank you for your reply. how to merge the codes so that the batch file does this

the batch file displays the options below

1. open the *.spl file in notepad
2. delete the *.shd and *.spl files
3.exit

commands execute as options are selected
 
Joined
May 1, 2008
Messages
1,039 (0.18/day)
Location
Frankfurt/Main - Germany
System Name Shaman of Sexy
Processor AMD Phenom II X4 955 BE@4Ghz EK Supreme Block
Motherboard M3A79-T Deluxe Anfi-Tech Waterblocks
Cooling Magicool 360 + 120 + 120 Slim scythe slipped Laing DDC-1/T
Memory 4GB Corsair Dominator CM2X2048-8500C5D
Video Card(s) Sapphire ATI Radeon HD 4870 X2 EK 4870 X2 Block
Storage RAID 0 Seagate
Display(s) Samsung 226BW 22"
Case CoolerMaster Cosmos RC-1000 in mod progress
Audio Device(s) onboard
Power Supply Coba Nitrox 750W
Software Windows 7 Ultimate
Benchmark Scores http://service.futuremark.com/compare?3dmv=1056967
does it needs to open a single file ? or multiple in spooler dir

note: it changes file name randomly i think
 

Sandeep Bhugoo

New Member
Joined
Jun 19, 2014
Messages
6 (0.00/day)
it has to open any .spl file present. each time the folder will be cleared when choosing the second option to clear. when another generation is done, another .spl file is created. i run the batch file to open it again when choosing option 1. ya the file name changes each time...
 
Joined
May 1, 2008
Messages
1,039 (0.18/day)
Location
Frankfurt/Main - Germany
System Name Shaman of Sexy
Processor AMD Phenom II X4 955 BE@4Ghz EK Supreme Block
Motherboard M3A79-T Deluxe Anfi-Tech Waterblocks
Cooling Magicool 360 + 120 + 120 Slim scythe slipped Laing DDC-1/T
Memory 4GB Corsair Dominator CM2X2048-8500C5D
Video Card(s) Sapphire ATI Radeon HD 4870 X2 EK 4870 X2 Block
Storage RAID 0 Seagate
Display(s) Samsung 226BW 22"
Case CoolerMaster Cosmos RC-1000 in mod progress
Audio Device(s) onboard
Power Supply Coba Nitrox 750W
Software Windows 7 Ultimate
Benchmark Scores http://service.futuremark.com/compare?3dmv=1056967
try some like this (untested)

batch file:

Code:
@EchoOFF
CLS
:MENU
ECHO ...............................................
ECHO.
ECHO 1 - Open *.spl Files
ECHO 2 - Clear Spooler cache
ECHO 3 - EXIT
ECHO.
ECHO ...............................................
ECHO.

SET /P M=Type 1, 2, or 3 then press ENTER:
IF %M%==1 GOTO SPL
IF %M%==2 GOTO CLEAR
IF %M%==3 GOTO EOF
:SPL
for %%X in ("%windir%\system32\spool\printers\"*.spl) do notepad %%X
GOTO MENU
:CLEAR
net stop spooler
del %windir%\system32\spool\printers\*.shd
del %windir%\system32\spool\printers\*.spl
net start spooler
GOTO MENU



save as *.bat


fixed :MENU tag
 
Last edited:

Sandeep Bhugoo

New Member
Joined
Jun 19, 2014
Messages
6 (0.00/day)
NICE PAL....WORKING FINE BUT WHEN I CLOSE THE NOTEPAD IT CLOSES THE CMD SCREEN AS WELL...
 
Joined
May 1, 2008
Messages
1,039 (0.18/day)
Location
Frankfurt/Main - Germany
System Name Shaman of Sexy
Processor AMD Phenom II X4 955 BE@4Ghz EK Supreme Block
Motherboard M3A79-T Deluxe Anfi-Tech Waterblocks
Cooling Magicool 360 + 120 + 120 Slim scythe slipped Laing DDC-1/T
Memory 4GB Corsair Dominator CM2X2048-8500C5D
Video Card(s) Sapphire ATI Radeon HD 4870 X2 EK 4870 X2 Block
Storage RAID 0 Seagate
Display(s) Samsung 226BW 22"
Case CoolerMaster Cosmos RC-1000 in mod progress
Audio Device(s) onboard
Power Supply Coba Nitrox 750W
Software Windows 7 Ultimate
Benchmark Scores http://service.futuremark.com/compare?3dmv=1056967
recopy script added the :menu tag and it should jump back to menu

might also be run as admin to have permission of deleting files in spooler dir
 
Joined
May 1, 2008
Messages
1,039 (0.18/day)
Location
Frankfurt/Main - Germany
System Name Shaman of Sexy
Processor AMD Phenom II X4 955 BE@4Ghz EK Supreme Block
Motherboard M3A79-T Deluxe Anfi-Tech Waterblocks
Cooling Magicool 360 + 120 + 120 Slim scythe slipped Laing DDC-1/T
Memory 4GB Corsair Dominator CM2X2048-8500C5D
Video Card(s) Sapphire ATI Radeon HD 4870 X2 EK 4870 X2 Block
Storage RAID 0 Seagate
Display(s) Samsung 226BW 22"
Case CoolerMaster Cosmos RC-1000 in mod progress
Audio Device(s) onboard
Power Supply Coba Nitrox 750W
Software Windows 7 Ultimate
Benchmark Scores http://service.futuremark.com/compare?3dmv=1056967
Joined
May 1, 2008
Messages
1,039 (0.18/day)
Location
Frankfurt/Main - Germany
System Name Shaman of Sexy
Processor AMD Phenom II X4 955 BE@4Ghz EK Supreme Block
Motherboard M3A79-T Deluxe Anfi-Tech Waterblocks
Cooling Magicool 360 + 120 + 120 Slim scythe slipped Laing DDC-1/T
Memory 4GB Corsair Dominator CM2X2048-8500C5D
Video Card(s) Sapphire ATI Radeon HD 4870 X2 EK 4870 X2 Block
Storage RAID 0 Seagate
Display(s) Samsung 226BW 22"
Case CoolerMaster Cosmos RC-1000 in mod progress
Audio Device(s) onboard
Power Supply Coba Nitrox 750W
Software Windows 7 Ultimate
Benchmark Scores http://service.futuremark.com/compare?3dmv=1056967
Code:
@ECHO OFF
CLS
:MENU
ECHO ...............................................
ECHO.
ECHO 1 - Open *.spl Files
ECHO 2 - Clear Spooler cache
ECHO 3 - EXIT
ECHO.
ECHO ...............................................
ECHO.

SET /P M=Type 1, 2, or 3 then press ENTER:
IF %M%==1 GOTO SPL
IF %M%==2 GOTO CLEAR
IF %M%==3 GOTO EOF
:SPL
if exist {"%windir%\system32\spool\printers\"*.spl} (
        ECHO .
        ECHO Files found, opening...
        ECHO.
        for %%X in ("%windir%\system32\spool\printers\"*.spl) do notepad %%X
        GOTO MENU
    ) else (
        ECHO.
        ECHO No Files found...
        ECHO.
        GOTO MENU
    )
:CLEAR
if exist {"%windir%\system32\spool\printers\"*.spl} (
        ECHO .
        ECHO Files found, deleting...
        ECHO.
        net stop spooler
        del %windir%\system32\spool\printers\*.shd
        del %windir%\system32\spool\printers\*.spl
        net start spooler
        GOTO MENU
    ) else (
        ECHO.
        ECHO No Files found...
        ECHO.
        GOTO MENU
    )
:EOF
exit


a bit nicer, added some file checks and notes
 
Joined
May 3, 2014
Messages
965 (0.27/day)
System Name Sham Pc
Processor i5-2500k @ 4.33
Motherboard INTEL DZ77SL 50K
Cooling 2 bay res. "2L of fluid in loop" 1x480 2x360
Memory 16gb 4x4 kingstone 1600 hyper x fury black
Video Card(s) hfa2 gtx 780 @ 1306/1768 (xspc bloc)
Storage 1tb wd red 120gb kingston on the way os, 1.5Tb wd black, 3tb random WD rebrand
Display(s) cibox something or other 23" 1080p " 23 inch downstairs. 52 inch plasma downstairs 15" tft kitchen
Case 900D
Audio Device(s) on board
Power Supply xion gaming seriese 1000W (non modular) 80+ bronze
Software windows 10 pro x64
dont need to cls the @Echo off and its advisable to @Echo on at the end of a batch file just before it exits.. "but next to no one does it"

i assume your doing cls so a new menu will be clean though, which keeps the bat nicer looking. rather than having a cls at the end of every option.
I think your way looks a lot cleaner than i would have done.. and i d have probably ended up with something looking a lot more like this.
Im prety sure your way is probably the better way the more i think about it. but id have still done it the way im adding just to ensure that it always ended at the menu.
I dont see any reason why your way wouldnt jump back to the menu though. so your way has to be better.

Code:
@ECHO OFF
:MENU
ECHO ...............................................
ECHO.
ECHO 1 - Open *.spl Files
ECHO 2 - Clear Spooler cache
ECHO 3 - EXIT
ECHO.
ECHO ...............................................
ECHO.

SET /P M=Type 1, 2, or 3 then press ENTER:
IF %M%==1 GOTO SPL
IF %M%==2 GOTO CLEAR
IF %M%==3 GOTO EOF
:SPL
if exist {"%windir%\system32\spool\printers\"*.spl} (
ECHO .
ECHO Files found, opening...
ECHO.
for %%X in ("%windir%\system32\spool\printers\"*.spl) do notepad %%X
pause
cls
ECHO ...............................................
ECHO.
ECHO 1 - Open *.spl Files
ECHO 2 - Clear Spooler cache
ECHO 3 - EXIT
ECHO.
ECHO ...............................................
ECHO.

SET /P M=Type 1, 2, or 3 then press ENTER:
IF %M%==1 GOTO SPL
IF %M%==2 GOTO CLEAR
IF %M%==3 GOTO EOF
) else (
ECHO.
ECHO No Files found...
pause
cls
ECHO ...............................................
ECHO.
ECHO 1 - Open *.spl Files
ECHO 2 - Clear Spooler cache
ECHO 3 - EXIT
ECHO.
ECHO ...............................................
ECHO.

SET /P M=Type 1, 2, or 3 then press ENTER:
IF %M%==1 GOTO SPL
IF %M%==2 GOTO CLEAR
IF %M%==3 GOTO EOF
)
:CLEAR
if exist {"%windir%\system32\spool\printers\"*.spl} (
ECHO .
ECHO Files found, deleting...
ECHO.
net stop spooler
del %windir%\system32\spool\printers\*.shd
del %windir%\system32\spool\printers\*.spl
net start spooler
ECHO deleted
pause
cls
ECHO ...............................................
ECHO.
ECHO 1 - Open *.spl Files
ECHO 2 - Clear Spooler cache
ECHO 3 - EXIT
ECHO.
ECHO ...............................................
ECHO.

SET /P M=Type 1, 2, or 3 then press ENTER:
IF %M%==1 GOTO SPL
IF %M%==2 GOTO CLEAR
IF %M%==3 GOTO EOF

) else (
ECHO.
ECHO No Files found...
pause
cls
ECHO ...............................................
ECHO.
ECHO 1 - Open *.spl Files
ECHO 2 - Clear Spooler cache
ECHO 3 - EXIT
ECHO.
ECHO ...............................................
ECHO.

SET /P M=Type 1, 2, or 3 then press ENTER:
IF %M%==1 GOTO SPL
IF %M%==2 GOTO CLEAR
IF %M%==3 GOTO EOF

)
:EOF
cls
pause
@Echo on
 
Last edited:
Joined
May 1, 2008
Messages
1,039 (0.18/day)
Location
Frankfurt/Main - Germany
System Name Shaman of Sexy
Processor AMD Phenom II X4 955 BE@4Ghz EK Supreme Block
Motherboard M3A79-T Deluxe Anfi-Tech Waterblocks
Cooling Magicool 360 + 120 + 120 Slim scythe slipped Laing DDC-1/T
Memory 4GB Corsair Dominator CM2X2048-8500C5D
Video Card(s) Sapphire ATI Radeon HD 4870 X2 EK 4870 X2 Block
Storage RAID 0 Seagate
Display(s) Samsung 226BW 22"
Case CoolerMaster Cosmos RC-1000 in mod progress
Audio Device(s) onboard
Power Supply Coba Nitrox 750W
Software Windows 7 Ultimate
Benchmark Scores http://service.futuremark.com/compare?3dmv=1056967
this is more shorter, the other where to reach the goal

Code:
@ECHO OFF
REM Set File Path variable
SET SPLFILES=%WINDIR%\SYSTEM32\spool\printers\
REM Build Menu
:MENU
    CLS
    ECHO ...............................................
    ECHO.
    ECHO 1 - Open *.spl Files
    ECHO 2 - Clear Spooler cache
    ECHO 3 - EXIT
    ECHO.
    ECHO ...............................................
    ECHO.
    SET /P M=Type 1, 2, or 3 then press ENTER:
    IF %M%==1 GOTO SPL
    IF %M%==2 GOTO CLEAR
    IF %M%==3 GOTO EOF
REM check if there are any and open files with notepad
:SPL
    REM "FORFILES" Native command in Vista/Windows7/2008, via Resource Kit for XP
    for %%G in (.spl) do FORFILES -p %SPLFILES% -m  *%%G -c "cmd /c ECHO Opening File: @path & cmd /c notepad @path"
    ECHO.
    pause
    goto MENU
REM check if there are any stop spooler , delete files, start spooler
:CLEAR
    net stop spooler
    ECHO.
    REM "FORFILES" Native command in Vista/Windows7/2008, via Resource Kit for XP
    for %%G in (.shd, .spl) do FORFILES -p %SPLFILES% -m  *%%G -c "cmd /c ECHO Deleting File: @path & cmd /c del @path /Q"
    ECHO.
    net start spooler
    pause
    goto MENU
REM Exit Script
:EOF
    exit

have fun
 
Last edited:
Joined
May 1, 2008
Messages
1,039 (0.18/day)
Location
Frankfurt/Main - Germany
System Name Shaman of Sexy
Processor AMD Phenom II X4 955 BE@4Ghz EK Supreme Block
Motherboard M3A79-T Deluxe Anfi-Tech Waterblocks
Cooling Magicool 360 + 120 + 120 Slim scythe slipped Laing DDC-1/T
Memory 4GB Corsair Dominator CM2X2048-8500C5D
Video Card(s) Sapphire ATI Radeon HD 4870 X2 EK 4870 X2 Block
Storage RAID 0 Seagate
Display(s) Samsung 226BW 22"
Case CoolerMaster Cosmos RC-1000 in mod progress
Audio Device(s) onboard
Power Supply Coba Nitrox 750W
Software Windows 7 Ultimate
Benchmark Scores http://service.futuremark.com/compare?3dmv=1056967
Joined
May 1, 2008
Messages
1,039 (0.18/day)
Location
Frankfurt/Main - Germany
System Name Shaman of Sexy
Processor AMD Phenom II X4 955 BE@4Ghz EK Supreme Block
Motherboard M3A79-T Deluxe Anfi-Tech Waterblocks
Cooling Magicool 360 + 120 + 120 Slim scythe slipped Laing DDC-1/T
Memory 4GB Corsair Dominator CM2X2048-8500C5D
Video Card(s) Sapphire ATI Radeon HD 4870 X2 EK 4870 X2 Block
Storage RAID 0 Seagate
Display(s) Samsung 226BW 22"
Case CoolerMaster Cosmos RC-1000 in mod progress
Audio Device(s) onboard
Power Supply Coba Nitrox 750W
Software Windows 7 Ultimate
Benchmark Scores http://service.futuremark.com/compare?3dmv=1056967
did you try without %s? Just system32?

nope not working,
you could do some like this to set Env Variable

setx -m System32"%windir%\System32\"

for current User

but its similar to my:

SET SPLFILES=%WINDIR%\SYSTEM32\spool\printers\


type: set in commad-line to see your system env variables
 
Last edited:
Top