Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 417
  • Last Modified:

need to make batch error output go away

Hello script experts,

I get the below message in one of my batches
"CMD.exe was started with the above path as the current directory"
"UNC paths are not supported.  Defaulting to windows directory".  

What I am doing is starting a batch, over the network, from an Intranet iframe page I made.  Anyway, the batch executes fine, does not have any problems,...I would just like that error to go away because I dont want people staring at it.

I converted it to exe, because some some computers open batch files as notepad instead of executing.  Not sure if that has anything to do with it, but when I use just the batch instead of the exe I dont notice this error, but it moves much faster and that is probably why.  

Is there anyway to add something in the batch that will prevent this error message output, or possibly any/all error message output?
0
icecom4
Asked:
icecom4
  • 4
  • 3
  • 3
  • +2
1 Solution
 
oBdACommented:
If your script works correctly, you can just ignore this message. To "sort of" get rid of it, you can just put "cls" as first command in your script, which will clear the screen.
With a registry tweak (per user, though), you can disable the check as well:
Cmd.exe does not support UNC names as the current directory
http://support.microsoft.com/kb/156276
0
 
pony10usCommented:
If you don't want to see ANY error messages you can redirect stderr to null

batch 2>null
0
 
Steve KnightIT ConsultancyCommented:
You could also set the working directory of the batch file to a local drive, i.e. make the shortcut point at \\server\share\path\file.cmd and the working directory of %windir% say or run it from a mapped drive.

The error is as has been said because you can't set the current directory to \\x\y for a cmd window.

Steve
0
Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

 
Bill PrewCommented:
If you want to suppress ALL error output from the batch (now exe) when you run it you can do:

myfile.exe 2>nul

(notice this is NUL not NULL as mentioned earlier)

What does the BAT file actually do or look like?  And how do you initiate it from the intranet site? Maybe there is a way to run it hidden?

~bp
0
 
pony10usCommented:
Thanks Bill.  <hanging head in shame>   :)
0
 
Steve KnightIT ConsultancyCommented:
If .bat files arent associated correctly on some machines try renaming it as .cmd file instead too ... or fix the file association I suppose!
0
 
icecom4Author Commented:
@ Bill
you said do "myfile.exe 2>nul"
So you mean call the exe from another batch file?  

The batch just looks to see if the user is on a workstation, if so it starts mstsc, if they are on a terminal server already it starts the application.  I can always make the exe run invisible, but I can't because it provides various messages to the end user.  

CLS in the beginning does not work, It seems that the error I mentioned above displays BEFORE anything in my batch executes.  I guess the CMD.EXE service sees that I am trying to execute a file over the network and displays that error.  

I may need to do as you suggested, call the exe from another batch, or just live with the error message.

maybe there is a setting I can deploy to the desktops using active directory?
0
 
oBdACommented:
You can
Ignore the error
Port the batch file to another scripting language (VBScript, Powershell, AutoIt, Kix, ...)
Add the following line to your script; the error will show up once more for each user and then be suppressed (see the article I linked above): reg.exe add "HKCU\Software\Microsoft\Command Processor" /v DisableUNCCheck /t REG_DWORD /d "1" /f >NUL
0
 
Steve KnightIT ConsultancyCommented:
or just change the working directory to a mapped or local drive like I said if it is a shortcut, or run it from a mapped drive rather than a UNC path.

Steve
0
 
icecom4Author Commented:
@ Obda,

Not a bad idea, will disabling UNC check impact anything else I wonder?
0
 
oBdACommented:
Shouldn't impact anything else as long as you're aware of the possible issues with UNC locations.
What you should do as one of the first commands in your batch if you disable the check (sorry, should have mentioned that earlier) is a "cd /d C:\Windows" (or any other known local path like %UserProfile%) so that you have a non-UNC current path; when you disable the check, cmd.exe doesn't change the path automatically anymore by itself.
0
 
icecom4Author Commented:
thank you very much!
0
 
Steve KnightIT ConsultancyCommented:
Well personally I'd use "cls" or better http:#a39298360 but as long as you are happy...

Steve
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

  • 4
  • 3
  • 3
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now