Solved

need to make batch error output go away

Posted on 2013-06-28
13
408 Views
Last Modified: 2013-07-18
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
Comment
Question by:icecom4
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 3
  • +2
13 Comments
 
LVL 84

Expert Comment

by:oBdA
ID: 39285147
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
 
LVL 26

Expert Comment

by:pony10us
ID: 39285182
If you don't want to see ANY error messages you can redirect stderr to null

batch 2>null
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 39285301
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
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 
LVL 54

Expert Comment

by:Bill Prew
ID: 39285722
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
 
LVL 26

Expert Comment

by:pony10us
ID: 39285729
Thanks Bill.  <hanging head in shame>   :)
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 39285790
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
 

Author Comment

by:icecom4
ID: 39298224
@ 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
 
LVL 84

Expert Comment

by:oBdA
ID: 39298324
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
 
LVL 43

Expert Comment

by:Steve Knight
ID: 39298360
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
 

Author Comment

by:icecom4
ID: 39300500
@ Obda,

Not a bad idea, will disabling UNC check impact anything else I wonder?
0
 
LVL 84

Accepted Solution

by:
oBdA earned 500 total points
ID: 39300580
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
 

Author Closing Comment

by:icecom4
ID: 39337663
thank you very much!
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 39337731
Well personally I'd use "cls" or better http:#a39298360 but as long as you are happy...

Steve
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you receive another warning that your shared drive is almost full and you have asked your users to clean out old files again and again, here is a single command that may help. This command will place all the files that have not been used rec…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question