windows bat file error

前端 未结 5 2064
没有蜡笔的小新
没有蜡笔的小新 2021-01-02 09:38

i try to launch a BAT file on a network share but i get this error:

\'\\\\dev\\applets\'
CMD.EXE was started with the above path as the current directory.
UN         


        
相关标签:
5条回答
  • 2021-01-02 09:48

    If you want to go without drive-mapping you can use registry hack from Microsoft KB.

    0 讨论(0)
  • 2021-01-02 09:49

    Do you have a chance to mount the network share first?

    net use \\dev\applets z:
    z:\mybatchfile.bat
    
    0 讨论(0)
  • 2021-01-02 09:58

    I had the same problem.. while the script runs just fine, the CMD.EXE header was annoying.

    To supress that text, I simply call a CLS as a first line of my script.

    This will remove that nasty CMD.EXE header and display whatever you want afterwards.

    Hope this helps.

    0 讨论(0)
  • 2021-01-02 10:00

    You can create a Mapped Network Drive. Assuming you are on Windows XP, the process is:

    In a Windows Explorer window,

    • Click Tools
    • Click Map Network Drive
    • Select a drive letter and a folder (e.g. X: and \\dev\applets)
    • Click Finish

    You can now just type

    x:
    cd applets
    

    in your command prompt and run your batch file.

    ALTERNATIVELY

    You can also use the NET USE command to map the network drive. e.g.

    NET USE X: \\dev\applets
    x:
    

    You can test ERRORLEVEL to see if the command completed successfully. Thanks to this brilliant bit of code, I can suggest this solution:

    @echo off
    set alpha=zyxwvutsrqponmlkjihg
    SET completed=false
    
    FOR /L %%i in (1,1,23) DO CALL :MAPDRIVE
    
    :MAPDRIVE
        set drive=%alpha:~0,1%
        set alpha=%alpha:~1,23%
    
        IF NOT %completed%==true (
            ECHO Attempting to mount drive as %drive%
            NET USE %drive%: \\dev\applets
        )
    
        IF %ERRORLEVEL% EQU 0 SET completed=true
    
    
    GOTO END
    
    :END
    
    0 讨论(0)
  • 2021-01-02 10:04

    You can get the command-line processor to automatically map your UNC path to a drive when the batch script starts:

    pushd %~dp0
    echo %CD%
    popd
    

    When the popd command executes, or when your script ends, the drive will be automatically unmapped.

    The only downside to this is that you still get the error message when the script runs.

    0 讨论(0)
提交回复
热议问题