Using the following winmgmt:
Set WebAdminWMI = GetObject("winmgmts:root\WebAdministration")
Set VDirWMI = WebAdminWMI.Get("VirtualDirectory")
How do I delete a specific virtual directory by Path and SiteName?
Thank you in advance.
Try using the Delete_ method
VDirWMI.Delete_
Related
I am attempting to use VBscript to open an excel file. However, when I run the script, it says the file cannot be located. I am pretty certain I have the file path correct. Is it possible that something else is causing my code to fail?
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
Set objWorkbook =
objExcel.Workbooks.Open("C:\Users\Guest\Documents\Projects\1A.xlsx")
Set objExcel = Nothing
Set objWorkbook = Nothing
As mentioned in the comments
In 9 out of 10 cases, this is permission related
The likeihood is (if you have already confirmed the file path is correct) that the VBScript does not have the permission required to access the file path, but due to the way elevation works along with UAC on most Windows Operating Systems means that VBScript doesn't know about the path, so it isn't reported as a access permission error.
As the path in question refers to a User Profile path the chances of it being permissions related increases.
To fix the problem the host process running the VBScript (wscript.exe or cscript.exe) needs to be run using elevated privileges. You can do this by opening an elevated command prompt (Run as Administrator context menu option) and specifying the host process followed by the script path.
Something like;
cscript.exe "yourscript.vbs"
From a windows command prompt type
c:\ dir C:\Users\Guest\Documents\Projects\1A.xlsx
The file could have been saved with a different file extension, or if explorer is hiding extensions and a user has provided the extension on save it might be called 1A.xlsx.xslx
Windows explorer might be hiding data. If you can see it in explorer, right click the file > properties > details.
The Name attribute should tell you exactly what the file is named on disk and the Folder path should give you the path.
You can combine the two to give the full path to the file on disk
I am running a perl script file from c# application using IIS, in that I want to open a already existing Excel file and I am opening it using the following line:
$ex = Win32::OLE->new('Excel.Application', sub {$_[0]->Quit;})
or die "Oops, cannot start Excel";//upto this working fine
$book = $ex->Workbooks->Open($fileName); //this line only giving error
Now I am getting the error in the open as follows:
OLE exception from "Microsoft Office Excel":
Microsoft Office Excel cannot access the file
'C:\GWATS\Report\Nov-17-2014_10-06-36\GES-11n_IOT_10-06-37.xls'. There are
several possible reasons:
• The file name or path does not exist.
• The file is being used by another program.
• The workbook you are trying to save has the same name as a currently open
workbook.
Win32::OLE(0.1711) error 0x800a03ec
in METHOD/PROPERTYGET "Open" at C:\GWATS\Lib\System\Report.pm line 611.
The file is surely present I verified that.
Also this script is working fine when I directly run that in cmd. What is the problem here, I think the problem is with IIS but I could find what exactly the problem is?
Try the below perl script. If still some error exists let me know:
Code:
use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft Excel';
my $Excel = Win32::OLE->GetActiveObject('Excel.Application')
|| Win32::OLE->new('Excel.Application', 'Quit');
my $filename = 'C:\GWATS\Report\Nov-17-2014_10-06-36\GES-11n_IOT_10-06-37.xls'
my $book = $Excel->Workbooks->Open($filename);
Open Windows Explorer
Depending on whether you installed a 32bit or 64bit version of office you will need to do one (or both) of the following:
32bit Office installation: Navigate to C:\Windows\System32\config\systemprofile
64bit Office installation: Navigate to C:\Windows\SysWOW64\config\systemprofile
Verify the folder "Desktop" exists (create it if it's not there)
Right click > Properties
On the security tab: Add the account under which the site is running (eg: DefaultAppPool) with default permissions (Read & execute; List folder contents; Read)
i faced similar issue
it worked for me when i gave the absolute path for the files
I'm using Installshield and want to set the destionation folder to c:\test.
the problem is that the dialog does not allow it.
What is the solution for this ?
Your dialog box looks like an older version of Installshield, but in any case this might help others who are looking to do the same thing.
If you do not want to (or cannot) create the custom destination path (method described in other answers), a simple alternative is setting INSTALLDIR to [WindowsVolume]test.
This installs the tool in C:\test. Of course, if the system does not have a C: drive, it installs it in the available drive.
See:
Q104964: HOWTO: Creating a Custom Destination Path
BTW, it is possible that the system doesn't have a C: drive.
Go to Setup.rul in the OnFirstUIBefore function if I remember correctly and add this lines:
// Create a list for system information.
listInfo = ListCreate (STRINGLIST);
// Get the boot drive.
if (GetSystemInfo (BOOTUPDRIVE, nvResult, svResult) < 0) then
szError = "Couldn't get BOOTUPDRIVE info.";
else
TARGETDIR = svResult ^ "Test";
endif;
This guarantees that if the C:\ is not the boot up drive it will be changed to the boot drive.
I am using C# test project .I wish to load a Xml which is available inside the project under a folder Dump . I am able to do
string path =
"C:\APP\FrameworkTest\TestProject\Dump\GetAddressById.xml";
but i don't want to use like this because if the drive changes,my code will fail.
in asp.net we have something like Server.MapPath() . Is there some thing like this ?
For example:
var dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
var path = Path.Combine(dir, "Dump", "GetAddressById.xml")
Hope this helps.
If you know that folder Dump will always be present in the deployement folder of your application then you certainly don't need to hard code full path.
For ASP.net:
var path = System.IO.Path.Combine(Server.MapPath("/"), "Dump",
"GetAddressById.xml");
For C#:
var path = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Dump",
"GetAddressById.xml");
My programming environment includes scripts for setting up my autobuild on a clean machine.
One step uses a vbscript to configure a website on IIS that is used to monitor the build.
On a particular machine I will be running apache on port 80 for a separate task.
I would like my vbscript to set the port to 8080 for the new site that it is adding.
How can I do this?
You can use adsutil.vbs, part of the IIS admin scripts, to change that:
cscript adsutil.vbs set W3SVC/1/ServerBindings “:8080:”
In a default layout, the script resides in C:\Inetpub\AdminScripts\.
you will need to add a host header using WMI or ADSI
http://www.adopenstatic.com/cs/blogs/ken/archive/2006/07/28/188.aspx
An extract of the code on there (with a little editing)
Dim objWebApp
Dim intArraySize
Dim arrOldBindings
Dim arrNewBindings
Set objWebApp = GetObject("IIS://localhost/w3svc/" WebSiteID)
If isArray(objWebApp.ServerBindings) then
arrOldBindings = objWebApp.ServerBindings
intArraySize = UBound(arrOldBindings)
Redim arrNewBindings(intArraySize + 1)
For i = 0 to intArraySize
arrNewBindings(i) = arrOldBindings(i)
Next
arrNewBindings(intArraySize + 1) = ":mydomain.com:8080:"
objWebApp.Put "ServerBindings", (arrNewBindings)
objWebApp.SetInfo
End If