Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8316497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:22:38+00:00 2026-06-08T21:22:38+00:00

I am trying to execute GhostScript in a batch file. batch.bat gswin32.exe ^ -dNOPAUSE

  • 0

I am trying to execute GhostScript in a batch file.

batch.bat

gswin32.exe ^
  -dNOPAUSE ^
  -sDEVICE=pdfwrite ^
  -sOUTPUTFILE=output1.txt ^
  -dBatch ^
   "file1.txt" "file2.txt"

gswin32.exe ^
  -dNOPAUSE ^
  -sDEVICE=pdfwrite ^
  -sOUTPUTFILE=output2.txt ^
  -dBatch ^
   "file1.txt" "file2.txt"

Problem is when first line is executed, it opens GhostScript window. i have to manually type quit or close the window to return the control to parent to execute the next command in batch.
How can we modify batch file so it executes ghost script? Originally I am calling this file from C# program using Process.Start(ProcessInfo). Suggestions are welcome

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T21:22:40+00:00Added an answer on June 8, 2026 at 9:22 pm
    1. To avoid Ghostscript opening a window, don’t use gswin32.exe.
      Use gswin32c.exe instead. (The c in the name is to indicate it’s for console only…)

    2. Also, be aware that Text files cannot serve as input to Ghostscript.
      Ghostscript can only process PostScript, Encapsulated PostScript or PDF files.

    3. You can name your output file as you please.
      But your -sDEVICE=pdfwrite will produce PDF output, so you are well advised to use a .pdf suffix for the output file if you want to avoid confusion later.

    4. The spelling for -dBATCH is case sensitive.
      -dBatch will not work.
      (-dBATCH causes Ghostscript to return after the last page of the job being completed — otherwise it would switch to interactive mode and show its GS> prompt… It’s not for processing ‘batches of input files’, as you appear to assume.)

    5. Your 2 commands in the batch file are using both the same input parameters.
      That means the 2 output files will be the same, just have different filenames.

    I recommend the following commandline scheme to use:

    gswin32.exe ^
      -dNOPAUSE ^
      -dBATCH ^
      -sDEVICE=pdfwrite ^
      -sOUTPUTFILE=output2.pdf ^
       "file1.ps" "file2.pdf" "file3.eps"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to execute a .bat file remotely in a powershell script. The code
I'm trying to execute a 3rd party application, called from a .cmd batch file,
I'm trying to execute a batch file in C#, but I'm not getting any
I'm trying to execute a batch file to move a bunch of files around
I'm trying to execute class file. After that I need the output of the
I'm trying to execute a .bat script in a C# windows service but it
I'm trying to execute a schema file on a SQL Server machine. I currently
I am trying to execute this SQL query prior to restoring a .BAK file
I'm trying to execute a program on a file using the popen() command on
Trying to execute powershell script in my C# code. Using .NET Framework v. 4.0.30319

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.