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

  • SEARCH
  • Home
  • 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 8814537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:09:01+00:00 2026-06-14T04:09:01+00:00

So I have some code for running a batch file as a specific user.

  • 0

So I have some code for running a batch file as a specific user. This was my attempt to automate the following syntax

runas /user:thisguy "C:\ThisGuysScript.bat"

so it looks like this in Ruby

Process.create(:command_line => "C:\\ThisGuysScript.bat ", :domain => "MYServer", :with_logon => "thisguy", :password => "thisguyspassword", :cwd =>"C:\\")

So I try to put this in a recipe in chef and disaster strikes

require 'win32/process'

::Process.create(:command_line => "C:\\ThisGuysScript.bat ", :domain => "MYServer", :with_logon => "thisguy", :password => "thisguyspassword", :cwd =>"C:\\")

Is failing with the following error

[Tue, 30 Oct 2012 15:57:03 +0000] FATAL: ArgumentError: You must supply a name when declaring a user resource

So it seems to not realise that I want to use the win32 flavour process. Chef seems to override the win32 module (I know recipes are the opscode DSL rather than really ruby right?)

Anyone been able to get this working? Or the same function with a different implementation. Checked out the windows cookbook but didn’t spot much

  • 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-14T04:09:03+00:00Added an answer on June 14, 2026 at 4:09 am

    It sounds like you want to make an LWRP for creating a process on a windows machine.

    The error you are getting means you have something like

    user do # Missing name
      gid 500
      home "..."
    end
    

    the correct syntax is

    user "apache" do # or whatever the user name should be
       # ...
    end
    

    If you don’t have the above in your cookbook, it is possible that the included file has a variable named user which would also cause this issue.

    To answer your subquestion, Chef is straight ruby with some functions made available and a frame work to run things. Note, there are several stages in a chef run. I think you are having issues in the compilation stage.

    Making an LWRP seems like the way to go. If you don’t want to go that far you could do something like.

    ruby_block "Firing process lazers" do
       require 'win32/process'
       ::Process.create(:command_line => "C:\\ThisGuysScript.bat ", :domain => "MYServer", :with_logon => "thisguy", :password => "thisguyspassword", :cwd =>"C:\\")
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Following the directions at this question , I have some code running to extract
I have been using this code, but have been running into some memory issues:
I have some code on two systems running kernel 2.4.20 and kernel 2.4.38 .
I have some code which is been running by a backgroundworker I'd like some
I have some very basic SignalR code running on the js client: var conn
I have some code that attempts to test whether my application is running with
I have some debugging code that if executed while running with GBD attached should
I have some jQuery code that is having difficulty running because I'm using it
I have some Java code that is throwing out of memory exceptions after running
I have some VBA code that needs to talk to a running c# application.

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.