Jump to content

Vb Script Not Working


ready2drum
 Share

Recommended Posts

The following code is designed to close any instances of the 'Carweek.pdf' file that is/are open and close the document so that no one has the file opened and the file can be edited. However, when the code is executed, no error is given, but it does not close the 'pdf' if a user has it opened on their computer.

Dim ServerNameDim FileNameServerName = "DXTS005FILE2" 'example. fileserver.microsoft.local or fileserverFileName = "E:\GROUP\Site\CarWeek\Carweek.pdf"Set objConnection = GetObject("WinNT://" & ServerName & "/LanmanServer")Set Shell = CreateObject("WScript.Shell")Set colResources = objConnection.ResourcesOn Error Resume NextFor Each objResource in colResources	'	'Wscript.Echo objResource.Path	'Wscript.Quit	'    If objResource.Path = FileName Then	Shell.Run "net file "& objResource.Name & " /close",1,True    End IFNext

Below is the php script that calls the VB script:

 <?php							  							  $tmp = "";$msg = "";							  if(!empty($_REQUEST["file_m"])){	if($_REQUEST["file_m"] = "m")	{		$tmp = shell_exec('net file | Find /i "Carweek.pdf"');		exec('E:\InetPub\.\intranet\close_carweek_docs.vbs');		$msg = "All CarWeek docs have been closed.";	}}if(!empty($_REQUEST["file_d"])){	if($_REQUEST["file_d"] = "d")	{		$tmp = shell_exec('net file | Find /i "Today.pdf"');		exec('E:\InetPub\.\intranet\close_daily_docs.vbs');		$msg = "All Daily Communication docs have been closed.";	}}	echo $msg;	echo '<font color="black"><br><br> ' . $tmp . '<br></font>';?>

Note: the web server and file server are separate. The file server is: 'DXTS005FILE2\e$' and the web server is: e$ on'DXTS005web\'Any suggestions on how to resolve this issue so that when the script is executed, it actually does close any open occurrences of the 'Carweek.pdf' file.Thanks!

Edited by ready2drum
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

×
×
  • Create New...