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 3348428
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:32:29+00:00 2026-05-18T01:32:29+00:00

I’m deploying a Windows service with a Ruby script. After copying files to the

  • 0

I’m deploying a Windows service with a Ruby script. After copying files to the server using FileUtils.cp, I run sc \\MYSERVER start MyService via Ruby’s cmd syntax. This command returns the following error for each of 20 consecutive attempts, at five second intervals:

[SC] StartService FAILED 32:

The process cannot access the file because it is being used by another process.

If I run the command manually immediately after my Ruby script ends, it works fine:

SERVICE_NAME: MyService
        TYPE               : 10  WIN32_OWN_PROCESS
        STATE              : 2  START_PENDING
                                (STOPPABLE, NOT_PAUSABLE, ACCEPTS_SHUTDOWN)
        WIN32_EXIT_CODE    : 0  (0x0)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0
        PID                : 21736
        FLAGS              :

Is FileUtils.cp possibly putting a lock on the copied EXE? If not, what else in my script could possibly be holding this lock?

Here’s pretty much what my script looks like, without all the automatic retry code and configuration:

srcRoot = Pathname.new 'c:\\MyService'
destRoot = Pathname.new '\\\\MYSERVER\\services\\MyService'

destRoot.each_entry() {|item| 
    if not %w(. ..).include?( item.to_s )
        FileUtils.rm_r destRoot.to_s + "\\" + item.to_s, :force => true
    end
} 

destRoot.mkdir unless destRoot.exist?

for dir in %w(Release)
    copy(src_root + dir + ".", destRoot) { destRoot + dir }
end

`sc \\\\MYSERVER start MyService`   

Here’s the copy function, which recursively copies directories and files:

# recursively copies the given source file or directory to the given destination directory.
def copy( src, destDir )
    src = Pathname.new src
    destDir = Pathname.new destDir  
    destDir.mkdir unless destDir.exist?
    exclusions = %w(. .. .svn _svn Thumbs.db)

    for item in Dir.glob( src + "*" )
        itemPath = Pathname.new item

        if not %w(. .. .svn _svn Thumbs.db).include?( itemPath.basename.to_s )
            if itemPath.directory?
                copy( itemPath, destDir + itemPath.basename ) {destDir + itemPath.basename}
            elsif exclusions.select {|k,v| extension? k}.select {|k,v| item.include? k}.empty?
                begin
                    FileUtils.cp( itemPath, destDir, {:verbose => true, :preserve => true} )
                rescue
                    puts "Warning! " + $!
                end
            end
        end
    end
end
  • 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-05-18T01:32:30+00:00Added an answer on May 18, 2026 at 1:32 am

    I found the issue. The MyService.exe.config file was being copied out in a separate method, which did some manipulation of the source file content before creating a new file on the server. The new file was not being closed, so attempting to start the service failed when it couldn’t get a lock on the config file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a bunch of posts stored in text files formatted in yaml/textile (from
I'm making a simple page using Google Maps API 3. My first. One marker
I am trying to loop through a bunch of documents I have to put
I have some data like this: 1 2 3 4 5 9 2 6

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.