I'm testing the responsiveness of a web application, and want to isolate any slow areas (database access, javascript, etc) and want to be sure that IIS Express isn't slowing things down by all its console output.
Is there a way of running IIS Express without that output, or even without the console being visible at all?
I've tried the /trace:error option, but it still outputs lines for every request.
the following should do the trick:
Create a VBScript: IIS-Express-silent.vbs
Dim App,Site
Site = "[YOUR SITE NAME]"
If Len(Site) < 1 Then
Site = WScript.Arguments(0)
End If
App = """%PROGRAMFILES%\IIS Express\iisexpress""" & _
" /site:" & Site
If Len(Site) > 0 Then
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run App, 0
Set WshShell = Nothing
End If
If you are running IIS Express only as localhost and you don't (intend to) use SSL then you are ready. Just add [YOUR SITE NAME] from applicationhost.config located in your user profile:
<sites>
<site name="[YOUR SITE NAME]" id="1" serverAutoStart="true">
...
</sites>
If you need elevated privileges you must create a second file in the same directory (VBScripts can't be run this way directly): Run-as-Administrator.bat
#echo off
pushd %~dp0
cscript IIS-Express-silent.vbs [YOUR SITE NAME]
Please leave Site in your VBScript blank then and add the name in your batch file instead.
Right mouse button - "Run as Administrator" - and you're done :-)
Related
First of all sorry for poor english.
I am using Classic ASP for simple things on my network. I want users to view their domain password expire date on our intranet page. Intranet page runs classic asp.
on CMD or powershell
"net user "username" /domain"
command gives the result. On asp page I need to run this command and read the result of password expire date.
Can you pls help me.
Thanks.
If you redirect output into a text file, you can read the file from asp:
Set w = Server.CreateObject("WScript.Shell")
w.Run "cmd /c net user > c:\temp\output.txt", 0, true ' send output into file
Set s = CreateObject("Scripting.FileSystemObject")
Set f = s.OpenTextFile("c:\temp\output.txt", 1) ' read file
o = f.ReadAll
f.Close
response.write o
Of course, this will require access of asp account to execute given command and
read/write access to the file.
Please help,
my vbscript: saveGSheet.vbs (to download sheet) works fine when manually run. I woud like to automat this, but an automatic task will NOT download the file.
How to run this in Task Scheduler? On Windows Server 2008.
Task Scheduler - settings:
Action: Run program: saveGSheet.bat with code:
c:\Windows\SysWOW64\cscript saveGSheet.vbs
Run task as LOCAL SERVICE
Run task when NOT LOGGED IN
Tried already:
Run with highest privileges does not help
creating "Desktop" folders does not help
"Log on as a batch job" does not help
Possible reasons:
Not logged in means objects doesnt work properly - possibly needs to be run in interactive mode like MS Excel? I do not understand what in my script needs to be run interactive (logged in)?
"MSXML2.XMLHTTP.3.0"
"ADODB.Stream"
Vbscript:
' Set your settings
strFileURL = "https://docs.google.com/spreadsheets/d/1B5jBWGHT1dGKCwE9KLTlFsyymNCc1s4AH1LcFQOcwqQ/export?format=xlsx"
strHDLocation = "C:\file.xlsx"
' Fetch the file
Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP.3.0")
objXMLHTTP.open "GET", strFileURL, false
objXMLHTTP.send()
'Response 200 is OK, now download sheet
If objXMLHTTP.Status = 200 Then
Set objADOStream = CreateObject("ADODB.Stream")
objADOStream.Open
objADOStream.Type = 1 'adTypeBinary
objADOStream.Write objXMLHTTP.ResponseBody
objADOStream.Position = 0 'Set the stream position to the start
objADOStream.SaveToFile strHDLocation
objADOStream.Close
Set objADOStream = Nothing
End if
Note: I should not use any third party apps, so I dont use wget for example.
EDIT: Made log file as suggested, result:
Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.
C:\AppBackUpTools\ALM\NotifikaceVSE\SLA_Escalation\download_excel\saveGSheet.vbs(27, 3) ADODB.Stream: Write to file failed.
modify your saveGSheet.bat as below:
c:\Windows\SysWOW64\cscript saveGSheet.vbs > %temp%\saveGSheet.log 2>&1
after the task is executed, examine the content of the log file at %temp%\saveGSheet.log that should give you some clue to debug further
You have no rights to write there. Change the folder ie to the folder where you have vbscript.
I'm trying to get classic asp / vbscript to run a less compiler (https://github.com/duncansmart/less.js-windows). Running the exact command from a real cmd prompt on the server works fine. So it's going to be one of those permissiony type things. My server is Win2003 x86 / IIS6.
<%
' foo.asp
outpath = "c:\inetpub\wwwroot\site\less"
cmd = "c:\less.js-windows-v1.6.2\lessc.cmd"
Set Shell = server.createobject("WScript.Shell")
nodeCommand = cmd & " " & outPath & "\app.less " & outPath & "\app.css"
errCode = Shell.Run(nodeCommand, 0, True)
' errcode = 1
%>
foo.asp is running somewhere on the web server, anonymously.
cmd.exe has had iusr_server added so that it has read and execute permission.
c:\less.js-windows-v1.6.2 has had iusr_server added with read/execute as well.
I've granted everyone permission to modify files in side c:\inetpub\wwwroot\site\less to make sure it's not a permission thing.
I have tried modifying my command to include CMD /C ahead of the command file name.
Use the following process:
Stop the server
Change relative paths to full paths for all files
Reconfigure the IUSR to be you
Restart the server
At my company we have to test our apps in IE, but I prefer using Chrome as my default browser. I made the following simple batch script in an attempt to launch the link in IE if it's related to my company, or to launch it in Chrome otherwise. The script looks like below and seems to work well from the command line.
set url=%1
echo %url%|findstr /i companyname >nul:
if %errorlevel%==1 goto :co_not_found
:co_found
"C:\Program Files\Internet Explorer\iexplore.exe" %url%
goto :gensuite_end
:co_not_found
"C:\Program Files\Google\Chrome\Application\chrome.exe" %url%
:co_end
Now I've been trying for days to get this little doodad set as the default browser for my computer. Here's a list of some of the registry keys I've edited. For some reason, Windows is still using IE as the default browser.
HKEY_CURRENT_USER\Software\Clients\StartmenuInternet (Default) = DEFAULTBROWSER
HKEY_CURRENT_USER\Software\Classes\http (Default) = C:\browserFix.exe
HKEY_CURRENT_USER\Software\Classes\http\shell\open\command (Default) = C:\browserFix.exe
HKEY_CURRENT_USER\Software\Classes\https (Default) = C:\browserFix.exe
HKEY_CURRENT_USER\Software\Classes\https\shell\open\command (Default) = C:\browserFix.exe
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\http\shell\open\command (Default) = C:\browserFix.exe
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\https\shell\open\command (Default) = C:\browserFix.exe
HKEY_LOCAL_MACHINE\SOFTWARE\Clients\StartMenuInternet (Default) = DEFAULTBROWSER
HKEY_LOCAL_MACHINE\SOFTWARE\Clients\StartMenuInternet\DEFAULTBROWSER (Default) = Default Browser, LocalizedString = C:\browserFix.exe
HKEY_LOCAL_MACHINE\SOFTWARE\Clients\StartMenuInternet\DEFAULTBROWSER\shell\open\command (Default) = C:\browserFix.exe
If I go to the control panel > programs > default programs > associate a file type or protocol and double click on HTTP or HTTPS, I'm only given the options for Google Chrome and IE. There is no browse option. In the end I'd like to be able to do this programmatically anyway. But to see if I could get it to show up I based these entries off of the ones for Google Chrome.
HKEY_LOCAL_MACHINE\SOFTWARE\Clients\StartMenuInternet\DEFAULTBROWSER\Capabilities\StartMenu StartMenuInternet = Default Browser Fixer
HKEY_LOCAL_MACHINE\SOFTWARE\Clients\StartMenuInternet\DEFAULTBROWSER\Capabilities\URLAssociations http and https = C:\browserFix.exe
It looks like Windows still isn't even looking at the program as a browser, much less the default one. Can anyone point me in the right direction? Keep in mind that I'd like to be able to do this with an installer batch script in the future.
Thanks in advance!
Jake
A program must have registry entries indicating that it can handle particular types of files. See http://msdn.microsoft.com/en-us/library/windows/desktop/ee872121(v=vs.85).aspx and links therefrom for details of the registry entries required in general, and http://msdn.microsoft.com/en-us/library/aa767914(v=vs.85).aspx for how to register URI protocol handlers.
We are working on automating the deployment of some IIS applications. I've used cscript.exe inside a windows batch file to create the web app and such. There are however a few settings currently done by hand that I need to automate. Namely, if you look at the properties of an app, under Directory Structure -> Authentication and access control -> Edit, I need to uncheck Enable anonymous access and check Integrated Windows authentication.
Is there an easy way to do this from a windows batch file?
EDIT: I should clarify this is IIS 6.0, so appcmd is not available.
hope this helpes:
http://forums.iis.net/t/1159665.aspx
I answered a very similar question a wee while back. The example uses the asdutil.vbs tool which you can call from your batch file:
Setting NTAuthenticationProviders at an Application level in IIS 6 (Stack Overflow)
Updated:
Because you've already got a CScript script to create the website, you can just set the AuthFlags in the script:
'' Some values just as an example
iisNumber = 668
ipAddress = "172.16.3.200"
hostName = "myserver.com"
wwwfolder = "c:\mysites\www"
Dim serverBindings(1)
serverBindings(0) = ipAddress & ":80:www." & hostName
serverBindings(1) = ipAddress & ":80:" & hostName
'' Create server
Set w3svc = GetObject("IIS://localhost/w3svc")
Set newWebServer = w3svc.Create("IIsWebServer", iisNumber)
newWebServer.ServerBindings = serverBindings
newWebServer.ServerComment = "Server is: " & hostName
newWebServer.SetInfo
'' Create /root app
Set rootApp = newWebServer.Create("IIsWebVirtualDir", "ROOT")
rootApp.Path = wwwFolder
rootApp.AccessRead = true
rootApp.AccessScript = true
rootApp.AppCreate(True)
rootApp.AuthFlags = 4 '' <== Set AuthFlags here
rootApp.SetInfo
See Configure Windows Authentication (IIS 7):
appcmd set config /section:windowsAuthentication /enabled:true | false
For IIS 6 probably WMI is the alternative:
Creating Sites and Virtual Directories, and Setting Properties Using WMI
IIsWebServiceSetting (WMI)
AuthFlags
Dim sSitePath = "1" 'Set the site ID here
Set oSite = GetObject("IIS://localhost/" & sSitePath & "/root")
Select Case oSite.AuthFlags
Case 1
Wscript.Echo "Anonymous"
Case 2
Wscript.Echo "Basic"
Case 4
Wscript.Echo "NTLM"
Case 6
Wscript.Echo "MD5"
Case 64
Wscript.Echo "Passport"
End Select