VBScript permission denied moving a folder

vbscript

Help please. this is driving me nuts.

Running a CMD prompt (As Administrator) on a Win2K3 AD server

I have a source folder on a local disk (C:\test)
I have a dest folder on a network share (\\device\share)

When I do a ojbFS.MoveFolder "C:\Test", "\\\\device\share\Test" running in cscript I get a permission denied error.

I tried ojbFS.MoveFolder "C:\Test", "\\device\share\" and same thing permission denied. Tried without the trailing \ as well and same thing 🙁

I also tried changing the UNC path to a mapped drive let and same thing.

However in the same CMD window if I do MKDIR \\\\device\share\Test it works perfectly fine.

I can confirm that Administrator has FULL Access rights to both the Source Folder and dest Folder. I can confirm I can drag and drop the Test folder from Source Folder to the dest Folder with no problems at all.

It only fails when I do and do it from cscript

I've also tried "runas /user:administrator cscript myscript.vbs" and the same result, permission denied.

What am I missing?

Best Answer

You can't directly use network device, you have to do it using network drive:

Dim oNet = CreateObject("WScript.Network")
oNet.MapNetworkDrive("X:", "\\device\share", False, "LOGIN", "PASS")

ojbFS.MoveFolder "C:\Test", "X:\"

oNet.RemoveNetworkDrive("\\device\shares", True, False)

https://msdn.microsoft.com/en-us/library/8kst88h6(v=vs.84).aspx

Related Topic