Jump to content

Recommended Posts

Folks,

 

I'm not entirely sure this is the best place for this question, but I think it mostly fits.  I have a problem that I'm trying to solve which requires some knowledge of Windows that I don't have.  I have a script that I wrote that needs to access a particular remote server using credentials.  Ideally, what I'd like to have happen is the following:

 

  • Script logs into 999.999.99.999/myDIR/ using a username and password.
  • Script runs
  • Script logs off of remote server.

 

On a unix machine I can accomplish this with a mount/unmount.  How would the same thing be accomplished using Windows?

 

Thanks,

 

- MT

Link to comment
https://forums.phpfreaks.com/topic/143469-solved-mountunmount-on-windows-server/
Share on other sites

with net NET USE you can mount a remote network share with an alternate user/pass:

http://www.ss64.com/nt/net_use.html

 

UPDATE:

I see that exec() will run on any system I'm on so I'm good to go.  Thanks!

 

Sweet, thanks Aaron!  Ok, I've got the exact DOS line worked out.  Now I just need to figure out how to execute it in PHP.

 

- MT

 

 

Finally, for those of you who are like me and need a written example of this, here's what worked for me:

 

exec("NET USE Z: \\123.456.78.910\myDIR /USER:username password");
.
.
.
[script runs]
.
.
.
exec("NET USE Z: /DELETE");

 

This will, if I wrote it properly in php, mount my remote server, run my script which is located locally, and then dismount from the remote server.  Thanks again to Aaron for pointing me in the right direction!

 

- MT

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.