Jump to content

Vb Script Not Working


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!

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...