Jump to content

FileExists over a share?


Recommended Posts

Is there a way to get (accurately) the status of a file over a network drive WITHOUT MAPPING?

I have a script that deploys files to a network share on the remote C drive... i.e.

Run('cmd /c NET USE \\' & $ip & '\C$ "' & $pass & '" /USER:"' & $user & '", '', @SW_HIDE)

then i copy it over:

Run('cmd /c COPY /Y "' & $filepath & '" "\\' & $ip & '\C$\' & $filename & '", '', @SW_HIDE)

Now i want to be able to (reliably) know if the file exists WITHOUT mapping the drive i.e.

NET USE z: \\10.1.6.75\C$ "admin" /USER:"Administrator"

the reason being that disconnecting the drive seems to lag on this machine sometimes, and that slows to deployment down a great deal....

Any other remote deployment guys out there that have tackled this one?

Link to comment
Share on other sites

Is there a way to get (accurately) the status of a file over a network drive WITHOUT MAPPING?

I have a script that deploys files to a network share on the remote C drive... i.e.

then i copy it over:

Now i want to be able to (reliably) know if the file exists WITHOUT mapping the drive i.e.

the reason being that disconnecting the drive seems to lag on this machine sometimes, and that slows to deployment down a great deal....

Any other remote deployment guys out there that have tackled this one?

<{POST_SNAPBACK}>

Why use the NET command when you can do the same thing with a built-in function?

This works for me:

If DriveMapAdd("", "\\192.168.0.1\c$", 0, "administrator", "password") Then
    If FileExists("\\192.168.0.1\c$\autoit-v3.1.0.exe") Then
        MsgBox(0, "", "File Found!")
    ;;; Do your copy here!!!
    Else
        MsgBox(0, "", "File NOT Found!")
    ;;; Handle your file not found here
    EndIf
    DriveMapDel("\\192.168.0.1\c$")
EndIf
Edited by pacman
Link to comment
Share on other sites

didn't he said not to connect the map??

and can't u use net view \\.... to see??

<{POST_SNAPBACK}>

He did say that but he was also using

Run('cmd /c NET USE \\' & $ip & '\C$ "' & $pass & '" /USER:"' & $user & '", '', @SW_HIDE)

in his script.

You can't check for a file or copy files to a remote share without first connecting to it. You can't use NET VIEW to check for a file on a remote share either.

Link to comment
Share on other sites

Ok this is interesting.....

When i map the drive via the NET USE z: method... hang-city....

When i use the Function, it screams through the code like i wanted it to...

wtf? I didn't know about that function, but it makes me wonder what is different about how Au3 handles it that makes the difference...

where is the hang? is it because the cmd /c is used? does this slow the execution of that line so much more than the function?

Props for the DriveMapAdd/DriveMapDel referance this has helped me out alot.

(I still wish i knew what was lagging it so much... :lmao: )

Props to everyone who responded, i know this sounds bad but i swear it's not devious in nature. just being lazy and was curious about the lag....

Edited by MadSc13ntist
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...