Link to home
Start Free TrialLog in
Avatar of ReneGe
ReneGeFlag for Canada

asked on

Batch File: Remote "Net Use /delete z:"

Hi there,

I need to delete a mapped drive on a remote PC.

COMMAND LINE USED:
PSEXEC -i -d \\pc CMD "/C NET USE /delete z:"

Thanks,
Rene
Avatar of Bill Prew
Bill Prew

I don't think you want the quotes, try:

PSEXEC -i -d \\pc CMD /C NET USE /delete z:

~bp
Avatar of ReneGe

ASKER

Thanks Bill, but Drive Z is stil there :(

Cheers,
Rene
Well, mapped drives are user specific, right?  So are you using the same user to check the mapping on the remote machine that the psexec is using?

~bp
Hi Rene, you can try adding /Y to your command. Z: may be in use in some way

Without it, I get this:
There are open files and/or incomplete directory searches pending on the connection to z:.
Is it OK to continue disconnecting and force them closed? (Y/N) [N]:

Open in new window

And with, I get this:
There are open files and/or incomplete directory searches pending on the connection to z:.

z: was deleted successfully.

Open in new window

Avatar of ReneGe

ASKER

Sorry taking so long to reply.

With all the proposed solutions, I still did not figured it out.

Have any new ideas?

Thanks,
Rene
Can you enter with -u username and -p password to try?

Psexec \\computer -u user -p password command
Avatar of ReneGe

ASKER

@l33tf0b
Are you referring to the credentials of the currently logged on remote user.

Thanks,
Rene
Yes or Admin account should do it.
Avatar of ReneGe

ASKER

@l33tf0b
Since I'm domain admin, when I execute psexec, it will run on all machines and with my own account.  Do you think that by adding the credentials to PSEXEC would result in a different behaviour?

Thanks,
Rene
ASKER CERTIFIED SOLUTION
Avatar of Ben Personick (Previously QCubed)
Ben Personick (Previously QCubed)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ReneGe

ASKER

It all makes sens.

Thanks guys :)

Cheers,
Rene