Hi there:
I know very little about VBScript - anyone know of any good online resources for learning? - but I'm currently in an enviroment where VBScript is used to carry out routine network tasks.
The script I'm having problems with is basically a wrapper for standard NT commands to remove user directories and shares. The error I'm getting is Line 22, "Expected ')'", which seems to me that I've left out a bracket or failed to escape some control character.
Here is a part of the script in question - I've bolded the first line where an error occurs. The aim of the line is to xcopy the directory \\server\Y:\users\<username> to \\server\T:\home-archive\<username>:
Result = oShell.run ("cmd /c xcopy /e /i /q \\<SERVER>\y$\" & objArgs(0) & "\users\" & objArgs(1) "t:\Home-Archive\" & objArgs(1),1,true)
I know very little about VBScript - anyone know of any good online resources for learning? - but I'm currently in an enviroment where VBScript is used to carry out routine network tasks.
The script I'm having problems with is basically a wrapper for standard NT commands to remove user directories and shares. The error I'm getting is Line 22, "Expected ')'", which seems to me that I've left out a bracket or failed to escape some control character.
Here is a part of the script in question - I've bolded the first line where an error occurs. The aim of the line is to xcopy the directory \\server\Y:\users\<username> to \\server\T:\home-archive\<username>:
Code:
dim fso, oShell
Set fso = CreateObject("Scripting.FileSystemObject")
Set oShell = WScript.CreateObject ("WSCript.shell")
Set objArgs = WScript.Arguments
if objArgs.Count <> 2 then
wscript.echo "Usage: test.vbs OU USERNAME"
wscript.quit
end if
Wscript.echo "Organisational Unit: " & objArgs(0)
Wscript.echo "Username: " & objArgs(1)
Wscript.echo "Full Path on <SERVER> Y:\" & objArgs(0) & "\users\" & objArgs(1)
If (lcase(objArgs(0)) = "xxx") THEN
If (fso.FolderExists("\\<SERVER>\y$\" & objArgs(0) & "\users\" & objArgs(1))) Then
Result = oShell.run ("cmd /c xcopy /e /i /q \\<SERVER>\y$\" & objArgs(0) & "\users\" & objArgs(1) "t:\Home-Archive\" & objArgs(1),1,true)
Code:
Wscript.echo "RESULT - MOVE FOLDER TO (0=Yes,1=No): " & Result
Result = oShell.run ("cmd /c ntnetshr /d \\<SERVER>\" & objArgs(1) & "$ y:\" & objArgs(0) & "\users\" & objArgs(1),1,true)
Wscript.echo "RESULT - REMOVE SHARE (0=Yes,1=No): " & Result
Result = oShell.run ("cmd /c rd /s /q \\<SERVER>\y$\" & objArgs(0) & "\users\" & objArgs(1),1,true)
Wscript.echo "RESULT - DELETE ORIGINAL FOLDER (0=Yes,1=No): " & Result
end if