views:

24

answers:

1

I'm trying to write a script that will rename a computer and join it to a domain, and was planning to call on netdom.exe to do the dirty work. However, trying to run this utility in the script (same results in irb) does absolutely nothing. No output, no execution. I tried with backticks and with the system() method. System() returns false for everything but system("netdom") (which returns true). Backticks never return anything but an empty string.

I have verified that netdom runs and works in the environment the script will be running in, and I'm calling other command-line utilities earlier in the script that work (w32tm, getmac, ping).

Here's the exact line that gets executed:

`netdom renamecomputer %COMPUTERNAME% /NewName:#{newname} /force`

FYI, This is windows 7 x64

A: 

may be you should replace %COMPUTERNAME% with an actual computer name?

zed_0xff
%COMPUTERNAME% should echo the current computer name. It does in the command line, so I assumed it would also do so in a subshell.I just testing this, however, replacing the variable with the computer's current name and it still did not execute.I don't think the problem lies in the syntax, rather in getting netdom to run. Maybe something netdom relies on isn't in the path used in the ruby subshell? I really don't know...
Joraff