Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a simple script to join an AD domain and rename the computer. When I execute these commands directly on the CLI, it works fine.

When I execute the same via batch file, I get an error saying

The network path was not found

I am running as Administrator with full privileges. I have googled around microsoft forums but my case is unique because it works from the CLI and not from the batch file

netdom join %%computername%% /domain:OPSCODEDEMO.COM /userd:Administrator /passwordd:xxx
netdom renamecomputer %%computername%% /NewName:%hostname% /Force

The environment is Windows 2k8 R2 SP1 running on Ninefold Cloud (Xenserver).

share|improve this question

migrated from stackoverflow.com Nov 8 '12 at 23:03

This question came from our site for professional and enthusiast programmers.

    
Totally off-topic for a programming-related Q&A site - this belongs on Serverfault.com where sysadmins hang out ... –  marc_s Nov 8 '12 at 16:59

1 Answer 1

I suspect your double percent signs are the culprit.

You can see how it's executing in your batch file by adding an echo on immediately before the first netdom and running the batch file from an elevated command prompt. I expect that you're going to see something like:

netdom join %THE_COMPUTER_NAME% /domain:OPSCODEDEMO.COM /userd:Administrator /passwordd:xxx

How you're getting it to work at all w/ the double percent signs, even just running those commands on the CLI "by hand", is baffling me.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.