Execution problem with .bat file

mathilde5635 Posted messages 2 Status Member -  
brucine Posted messages 24882 Registration date   Status Member Last intervention   -
Hello,

I created a simple .bat file that runs a python file. It works on several computers but on one, we can’t get it to work.
A window opens with "File Open – Security Warning", after clicking on "Run", the Shell window opens with the message "CMD.EXE has been started with the path as the current directory. UNC paths are not supported. Using the default Windows directory. Access denied."


I don’t know how to get the .bat file to work, especially since I can’t "run as administrator"

Thank you

2 answers

  1. mathilde5635 Posted messages 2 Status Member
     
    Thank you for your response :)

    And I'm sorry, I didn't really understand, is it a question of rights?
    How can I resolve the issue?
    Is there no line of code to add to the batch file to solve the problem?
    0
    1. brucine Posted messages 24882 Registration date   Status Member Last intervention   4 175
       
      If the rights are not the issue as I illustrated earlier (but then we don't see why it would work on some machines and not others), it's that your command (we don't know which one) does not support UNC paths.

      At least two ways to remedy this:

      File and printer sharing must be enabled on the target PC (which may be the cause of our troubles), the target folder must be shared, and the "source" user must have the appropriate rights (identification, password) for reading and/or writing.

      NET USE V: \\monpc\C$

      Here, I create a virtual drive V: that represents the local PC named monpc and where I want to share the administrative share C$; I can specify a particular folder in this share.

      I can specify the credentials in the command:

      NET USE G: \\Server64\Share1 /USER:SS64dom\user64

      but in that case, unless I go through PowerShell, a prompt will ask me for the password.

      https://ss64.com/nt/net-use.html

      PAIR OF COMMANDS PUSHD POPD
      I must then chain the required commands to PUSHD by means of the & parameters, for example:

      PUSHD "\\monpc\C$\mondossier\" &&(
      forfiles -s -m *.* -d -7 -c "cmd /c del /q @path"
      ) & POPD

      https://ss64.com/nt/pushd.html
      0