Search Results

Search found 165 results on 7 pages for 'wscript'.

Page 2/7 | < Previous Page | 1 2 3 4 5 6 7  | Next Page >

  • if then endif , other smart solution in place of if then ....

    - by yael
    I have the following VB script How to write this VB script with case syntax? In order to perform professional writing in place if then…. yael Set fso = CreateObject("Scripting.FileSystemObject") If (fso.FileExists("C:\file1 ")) Then Verification=ok Else WScript.Echo("file1") Wscript.Quit(100) End If If (fso.FileExists("C:\file2 ")) Then Verification=ok Else WScript.Echo("file2") Wscript.Quit(100) End If If (fso.FileExists("C:\file3 ")) Then Verification=ok Else WScript.Echo("file3") Wscript.Quit(100) End If . . . .

    Read the article

  • Quick Script for Adding Skype Groups

    - by Robert May
    So, I needed to add about 30 people to several different Skype groups today, and I didn’t want to repeat the /add [skypename] thing over and over and over.  Building the list was a pain . . . I couldn’t find a good way to extract all of the users in an existing group.  There’s probably an api or something, but I just did that part by hand. Adding them to the groups was pretty easy with Windows Scripting Host.  Basically, I just ran this: <package>    <job id="vbs">       <script language="VBScript">          set WshShell = WScript.CreateObject("WScript.Shell")          WshShell.AppActivate 4484          WScript.Sleep 100          WshShell.SendKeys "/add user1~"          WScript.Sleep 100 …          WshShell.SendKeys "/add usern~"          WScript.Sleep 100       </script>    </job> </package> Add as many users as you need by copying the sendkeys and sleep lines.  Then, save the script to a .wsf file.  The AppActivate line needs to be changed to have the process id of skype instead of the number there.  To get that, open up Task Manager, click on Processes, then find skype.exe and find it’s PID. Before you double click on the file in windows explorer, you’ll need to have created the groups in skype.  For each group, open the group, and click in the chat window of the group.  Then double click on the WSF file.  If you don’t click in the chat window, you will likely get the add user dialog box instead of just adding the users. Technorati Tags: Skype,Script

    Read the article

  • Cisco Configuration backup with Windows Script.

    - by Jeff
    We have a client with a lot of Cisco Devices and we would like to automate the backups of these devices through telnet. We have both 2003 and 2008 servers and ideally use tftp to back it up. I wrote this: Set WshShell = WScript.CreateObject("WScript.Shell") Dim fso Set fso = CreateObject("Scripting.FileSystemObject") Dim ciscoList ciscoList = "D:\Scripts\SwitchList.txt" Set theSwitchList = fso.OpenTextFile(ciscoList, 1) Do While theSwitchList.AtEndOfStream <> True cisco = theSwitchList.ReadLine Run "cmd.exe" SendKeys "telnet " SendKeys cisco SendKeys "{ENTER}" SendKeys "USERNAME" SendKeys "{ENTER}" SendKeys "PASSWORD" SendKeys "{ENTER}" SendKeys "en" SendKeys "{ENTER}" SendKeys "PASSWORD" SendKeys "{ENTER}" SendKeys "copy startup-config tftp{ENTER}" SendKeys "(TFTP IP){ENTER}" SendKeys "FileName.txt{ENTER}" SendKeys "exit{ENTER}" 'close telnet session' SendKeys "{ENTER}" 'get command prompt back SendKeys "{ENTER}" SendKeys "exit{ENTER}" 'close cmd.exe On Error Resume Next WScript.Sleep 3000 Loop Sub SendKeys(s) WshShell.SendKeys s WScript.Sleep 300 End Sub Sub Run(command) WshShell.Run command WScript.Sleep 100 WshShell.AppActivate command WScript.Sleep 300 End Sub But the problem with this is the sendkeys are sent to the console session, I'm trying to find a solution that would not require a user to be logged in. Does anyone have any ideas? I have some knowlage of VBS, PowerShell and a pretty good grasp on batching.

    Read the article

  • Remote installing an msi on citrix servers using WMI

    - by capn
    OK, I'm a C# programmer that is trying to streamline the deployment of a custom windows form app I inherited and built an installer for with WiX (this app will need to be reinstalled regularly as I'm making changes to it). I'm not really used to admin type things (or vbs, or WMI, or terminal servers, or Citrix, and even WiX and MSI are not things I usually deal with) but so far I put together some vbs and have an end goal in mind. The msi does work, and I've installed it from the mapped O: drive on my dev machine and while RDP'd to a citrix machine. End Goal: Deploy code written on my dev machine and compiled into an MSI (that I can improve upon within the confines of WiX and whatever the Windows Installer Engine allows) to the cluster of Citrix machines my users have access to. What am I missing in my script to get the MSI to execute on the remote machines? Layout: Machine A is my dev machine, and has the vbs script and the msi file (XP SP3) Machines C1 - C6 are the Citrix Servers that need the application installed them via the msi (Server 2003 R2 SP2) There is also optionally a shared network resource that all the machines can access. Script: 'Set WMI Constants Const wbemImpersonationLevelImpersonate = 3 Const wbemAuthenticationLevelPktPrivacy = 6 'Set whether this is installing to the debug Citrix Servers Const isDebug = true 'Set MSI location 'Network location yields error 1619 (This installation package could not be opened.) msiLocation = "\\255.255.255.255\odrive\Citrix Deployment\Setup.msi" 'Directory on machine A yields error 3 (file not found) 'msiLocation = "C:\Temp\Deploy\Setup.msi" 'Mapped network drive (on both machines) yield error 3 (file not found) 'msiLocation = "O:\Citrix Deployment\Setup.msi" 'Set login information strDomain = "MyDomain" Wscript.StdOut.Write "user name:" strUser = Wscript.StdIn.ReadLine Set objPassword = CreateObject("ScriptPW.Password") Wscript.StdOut.Write "password:" strPassword = objPassword.GetPassword() 'Names of Citrix Servers Dim citrixServerArray If isDebug Then citrixServerArray = array("C4") Else 'citrixServerArray = array("C1","C2","C3","C5","C6") End If 'Loop through each Citrix Server For Each citrixServer in citrixServerArray 'Login to remote computer Set objLocator = CreateObject("WbemScripting.SWbemLocator") Set objWMIService = objLocator.ConnectServer(citrixServer, _ "root\cimv2", _ strUser, _ strPassword, _ "MS_409", _ "ntlmdomain:" + strDomain) 'Set Remote Impersonation level objWMIService.Security_.ImpersonationLevel = wbemImpersonationLevelImpersonate objWMIService.Security_.AuthenticationLevel = wbemAuthenticationLevelPktPrivacy 'Reference to a process on the machine Dim objProcess : Set objProcess = objWMIService.Get("Win32_Process") 'Change user to install for terminal services errReturn = objProcess.Create _ ("cmd.exe /c change user /install", Null, Null, intProcessID) WScript.Echo errReturn 'Install MSI here 'Reference to a product on the machine Set objSoftware = objWMIService.Get("Win32_Product") 'All users set in option parameter, I'm led to believe that the third parameter is actually ignored 'http://www.webmasterkb.com/Uwe/Forum.aspx/vbscript/2433/Installing-programs-with-VbScript errReturn = objSoftware.Install(msiLocation,"ALLUSERS=2 REBOOT=ReallySuppress",True) Wscript.Echo errReturn 'Change user back to execute errReturn = objProcess.Create _ ("cmd.exe /c change user /execute", Null, Null, intProcessID) WScript.Echo errReturn Next I also tried using this to install, it doesn't return an error code, but doesn't install the msi either, and it makes me wonder if the change user /install command is even really working. errReturn = objProcess.Create _ ("cmd.exe /c msiexec /i ""O:\Citrix Deployment\Setup.msi"" /quiet") Wscript.Echo errReturn

    Read the article

  • VBScript wont work on www.meteor.ie

    - by Davey Flavin
    The .Focus() function will not work in Windows Server 2003. Is there any thing i can do to make it work? WScript.Sleep 1000 .getElementByID("quickSearchMsisdn").value = "085729916" WScript.Sleep 1000 .getElementByID("quickSearchMsisdn").value = "0857299167" WScript.Sleep 1000 .getElementByID("quickSearchMsisdn").value = "0857299167" .getElementByID("quickSearchMsisdn").Focus WScript.Sleep 10000 .getElementByID("doSendSMS").click It is to log into my online mobile account and send me an automated text. What ever way the page is designed the number field needs to be clicked into.

    Read the article

  • vbscript calling svnadmin dump

    - by Dexton
    Hi, Running the following vbscript to call svnadmin dump fails (i.e. no dump is being created) Set objShell = CreateObject("WScript.Shell") Set objShellExec = objShell.Exec("svnadmin dump C:\svn_repos > C:\fullbackup") I discovered from another post, http://stackoverflow.com/questions/445121/svn-dump-fails-with-wscript-shell/2400011#2400011 that i had to create a new command interpreter using cmd as follows: Set objShellExec = objShell.Exec("%comspec% /c" & "svnadmin dump C:\svn_repos > C:\fullbackup") This successfully created the dump but I could never read the output information (i.e. * Dumped revision 100. * Dumped revision 101. etc). I tried Do While objWshScriptExec.Status = 0 Wscript.Echo objShellExec.StdOut.Readline Wscript.Echo objShellExec.StdErr.Readline WScript.Sleep 100 Loop but nothing ever gets displayed. May I know how i can read the output information and also why I needed to create a new command interpreter using "%comspec% /c" before the svnadmin dump command would execute correctly? Thanks. Regards, Dexton

    Read the article

  • VBScript Catching Erroring Varialble Value

    - by Soren
    I have a VB Script (.vbs file) that is just a simple directory listing of a drive. It will the base of a drive back up script. But when running it as it is below, I am getting a Permission Denied error on some folder. What I need to find is what that folder is so I can figure out what the problem is with the folder. The line that is giving the error is "For Each TempFolder In MoreFolders". So what I am trying to figure out is how to WScript.Echo the current path (objDirectory) if there is an error. I am not sure if it matters much, but just in case, the error that I am getting is Permission Denied 800A0046 on line 12. So some folder, I do not know which one, is not letting me look inside. Set WSShell = WScript.CreateObject("WScript.Shell") Set objFSO = CreateObject ("Scripting.FileSystemObject") Dim FolderArr() FolderCount = 0 TopCopyFrom = "G:\" Sub WorkWithSubFolders(objDirectory) Set MoreFolders = objDirectory.SubFolders 'The next line is where the error occurs (line 12) For Each TempFolder In MoreFolders FolderCount = FolderCount + 1 ReDim Preserve FolderArr(FolderCount) FolderArr(FolderCount) = TempFolder.Path ' WScript.Echo TempFolder.Path WorkWithSubFolders(TempFolder) Next End Sub ReDim Preserve FolderArr(FolderCount) FolderArr(FolderCount) = TopCopyFrom Set objDirectory = objFSO.GetFolder(TopCopyFrom) WorkWithSubFolders(objDirectory) Set objDirectory = Nothing WScript.Echo "FolderCount = " & FolderCount WScript.Sleep 30000 Set objFSO = Nothing Set WSShell = Nothing

    Read the article

  • Trying to rename a computer via the netdom command and force a reboot

    - by user57020
    Why doesn't this work? it looks like it will but nothing happens. Option Explicit Dim wshNetwork Dim wshShell Dim PCname Dim Newname Set wshNetwork = WScript.CreateObject("WScript.Network") Set wshShell = WScript.CreateObject("WScript.Shell") PCname = InputBox("Type in the name of the pc you want to rename") Newname = InputBox("Type in the name of the new pc name") wshShell.run("netdom renamecomputer " &PCname& " /NewName:"&Newname& " /reboot:00 " ) 'MsgBox("netdom renamecomputer " &PCname& " /NewName:"&Newname& " /reboot:00 /y")

    Read the article

  • Script to set NO_HEARTBEAT Flag

    - by Koppar
    The new plugin provides some flags to help debug the browser side VM. Below are the flags: JPI_PLUGIN2_DEBUG=1JPI_PLUGIN2_VERBOSE=1 The above 2 provide tracing information JPI_PLUGIN2_NO_HEARTBEAT = 1 This disables sending of  heartbeat messages between browser side VM and the client JVM instance(s). This lets the client JVM stay independent of browser side VM. These are to be set as system environment variables. Many a times we are required to set them using scripts. Here is a small script to achieve the same: -----------set_jpi_flags.vbs------------------------------------------ Set WSHShell = WScript.CreateObject("WScript.Shell")Set WshEnv = WshShell.Environment("USER")WshEnv("JPI_PLUGIN2_NO_HEARTBEAT") = "1"WshEnv("JPI_PLUGIN2_DEBUG") = "1"WshEnv("JPI_PLUGIN2_VERBOSE") = "1"WScript.Echo WshEnv("JPI_PLUGIN2_NO_HEARTBEAT")   ---- displays the value of the NO_HEARTBEAT var ---------------------------------------------------------------------------

    Read the article

  • Find Users E-Mail via SID using VBScript and Active Directory

    - by er4z0r
    Hi, I am parsing log messages about changes to user accounts on a windows system. I want to notify the user about the changes so I need to retrieve their personal information (First,Last, E-Mail) from Active Directory. I already found a way to retrieve the username but that is only via WMI and not ADSI: Function FindUser(Message) Dim objWMIService Dim strAccountRegex Dim objRegex Dim objMatch Dim strComputer Dim objUser Dim objShell strAccountRegex = "(\%\{[A-Z,0-9,\-]*\})" strComputer = "." Wscript.StdOut.writeLine "Querying WMI to retrieve user-data" Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set objShell = WScript.CreateObject("WScript.Shell") Set objRegex = new RegExp objRegex.Pattern= strAccountRegex for each objMatch in objRegex.Execute(Message) REM Wscript.StdOut.writeLine "Found an Account ID: " & objMatch.value Dim strSID strSID=NormalizeSID(objMatch.value) REM Wscript.Echo "SID after escaping: " & strSID Set objUser = objWMIService.Get _ ("Win32_SID.SID='" & strSID & "'") next FindUser=objUser.ReferencedDomainName & "\" & objUser.AccountName End Function It works fine, but I would like to do it via Active Directory instead of going via WMI. Can you help me?

    Read the article

  • Find Users E-Mail via SID using VBScript and ADSI

    - by er4z0r
    Hi, I am parsing log messages about changes to user accounts on a windows system. I want to notify the user about the changes so I need to retrieve their personal information (First,Last, E-Mail) from Active Directory. I already found a way to retrieve the username but that is only via WMI and not ADSI: Function FindUser(Message) Dim objWMIService Dim strAccountRegex Dim objRegex Dim objMatch Dim strComputer Dim objUser Dim objShell strAccountRegex = "(\%\{[A-Z,0-9,\-]*\})" strComputer = "." Wscript.StdOut.writeLine "Querying WMI to retrieve user-data" Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set objShell = WScript.CreateObject("WScript.Shell") Set objRegex = new RegExp objRegex.Pattern= strAccountRegex for each objMatch in objRegex.Execute(Message) REM Wscript.StdOut.writeLine "Found an Account ID: " & objMatch.value Dim strSID strSID=NormalizeSID(objMatch.value) REM Wscript.Echo "SID after escaping: " & strSID Set objUser = objWMIService.Get _ ("Win32_SID.SID='" & strSID & "'") next FindUser=objUser.ReferencedDomainName & "\" & objUser.AccountName End Function It works fine, but I would like to do it via Active Directory instead of going via WMI. Can you help me?

    Read the article

  • How to refresh a webpage in IE

    - by Ramesh
    HI all, I have Ishare URL " www.example.com\ishare " which i opened it thru wshshell. I want this page to be reloaded every 10 seconds. any help on this would be much appreciated. following is the script, Dim WSHShell Dim oShell Set WSHShell = WScript.CreateObject("WScript.Shell") WSHShell.Run("iexplore https://Infrastructure/IA/Lists/Incidents/AllItems.aspx") oShell = "Incidents - Microsoft Internet Explorer" WSHShell.appActivate(oShell) WScript.sleep 500 WSHShell.SendKeys "{F5}" Set WSHShell = Nothing

    Read the article

  • Boolean Not operator in VBScript

    - by Lumi
    Consider the following two conditionals (involving bitwise comparisons) in VBScript: If 1 And 3 Then WScript.Echo "yes" Else WScript.Echo "no" If Not(1 And 3) Then WScript.Echo "yes" Else WScript.Echo "no" Prints first yes, then no, right? cscript not.vbs Wrong! It prints yes twice! Wait a second, the Not operator is supposed to perform logical negation on an expression. The logical negation of true is false, as far as I know. Must I conclude that it doesn't live up to that promise? How and why and what is going on here? What is the rationale, if any?

    Read the article

  • How to Execute an Oracle SQL Statements with VBScript

    - by Arno Conradie
    I am trying to execute an Oracle SQL statement or Oracle Functions through Microsoft VBScript and the loop throught the result set or display the value returned by the function So far I have managed to connect to Oracle via SQLPlus*, but now I am stuck. Can anybody help? Dim output Dim WshShell, oExec, input set WshShell = CreateObject("WScript.Shell") set oEnv=WshShell.Environment("Process") cmdString = "C:\Oracle\11g\product\11.1.0\ruby\BIN\sqlplus.exe -S stradmin/stradmin@ruby select * from dual" Set oExec = WshShell.Exec(cmdString) WScript.Echo "Status" & oExec.Status Do While oExec.Status = 0 WScript.Sleep 2 Loop input = "" Do While Not oExec.StdOut.AtEndOfStream input = input & oExec.StdOut.Read(1) Loop wscript.echo input

    Read the article

  • VBScript Writing to Server Text File

    - by Keyfer Mathewson
    I have created a VBScript which pulls the service tag, username, and computer name from a computer. What I need to do now is compile this information in a text document. How it's set up is as follows: We have an Active Directory Server, with a folder for login scripts. I have created a batch file to run this .vbs script, and the script works well so far. What I now need is for a file on the AD server, called "logging.txt", to be populated with the information that is created with the .vbs script. This is the script I have so far: 'Get Dell Service Tag Info set ProSet = GetObject("winmgmts:").InstancesOf("Win32_BIOS") Set ProSet1 = GetObject("winmgmts:").InstancesOf("Win32_SystemEnclosure") For each Pro in ProSet For each Pro1 in ProSet1 ServiceTag=Pro.SerialNumber wscript.echo ServiceTag exit for Next exit for Next 'get username and computername, could also be asked in a batch Set oShell = WScript.CreateObject("WScript.Shell") Set oShellEnv = oShell.Environment("Process") sComputerName = oShellEnv("ComputerName") sUsername = oShellEnv("username") wscript.echo sComputerName & " " & sUsername Thank you very much in advance!

    Read the article

  • Enumerating Environment keys with VBScript?

    - by Stabledog
    I need to enumerate the keys in the WScript.Shell.Environment object. It's clear that if you already know the name of the key, you're home free with: Set oShell = WScript.CreateObject("WScript.Shell") Debug.WriteLine "PATH=" & oShell.Environment("PATH") ...but if you want to list the keys, it looks like you're out of luck! Is there a secret passageway somewhere?

    Read the article

  • VBScript Multiple folder check if then statement

    - by user2868186
    I had this working before just fine with the exception of getting an error if one of the folders was not there, so I tried to fix it. Searched for a while (as much as I can at work) for a solution and tried different methods, still no luck and my IT tickets are stacking up at work, lol, woohoo. Thanks for any help provided. Getting syntax error on line 60 character 60, thanks again. Option Explicit Dim objFSO, Folder1, Folder2, Folder3, zipFile Dim ShellApp, zip, oFile, CurDate, MacAdd, objWMIService Dim MyTarget, MyHex, MyBinary, i, strComputer, objItem, FormatMAC Dim oShell, oCTF, CurDir, scriptPath, oRegEx, colItems Dim FoldPath1, FoldPath2, FoldPath3, foldPathArray Const FOF_SIMPLEPROGRESS = 256 'Grabs MAC from current machine strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery _ ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True") For Each objItem in colItems MacAdd = objItem.MACAddress Next 'Finds the pattern of a MAC address then changes it for 'file naming purposes. You can change the FormatMAC line of the code 'in parenthesis where the periods are, to whatever you like 'as long as its within the standard file naming convention Set oRegEx = CreateObject("VBScript.RegExp") oRegEx.Pattern = "([\dA-F]{2}).?([\dA-F]{2}).?([\dA-F]" _ & "{2}).?([\dA-F]{2}).?([\dA-F]{2}).?([\dA-F]{2})" FormatMAC = oRegEx.Replace(MacAdd, "$1.$2.$3.$4.$5.$6") 'Gets current date in a format for file naming 'Periods can be replaced with anything that is standard to 'file naming convention CurDate = Month(Date) & "." & Day(Date) & "." & Year(Date) 'Gets path of the directory where the script is being ran from Set objFSO = CreateObject("Scripting.FileSystemObject") scriptPath = Wscript.ScriptFullName Set oFile = objFSO.GetFile(scriptPath) CurDir = objFSO.GetParentFolderName(oFile) 'where and what the zip file will be called/saved MyTarget = CurDir & "\" & "IRAP_LOGS_" & CurDate & "_" & FormatMAC & ".zip" 'Actual creation of the zip file MyHex = Array(80, 75, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0) For i = 0 To UBound(MyHex) MyBinary = MyBinary & Chr(MyHex(i)) Next Set oShell = CreateObject("WScript.Shell") Set oCTF = objFSO.CreateTextFile(MyTarget, True) oCTF.Write MyBinary oCTF.Close Set oCTF = Nothing wScript.Sleep(3000) folder1 = True folder2 = True folder3 = True 'Adds folders to the zip file created earlier 'change these folders to whatever is needing to be copied into the zip folder 'Folder1 If not objFSO.FolderExists("C:\Windows\Temp\SMSTSLog") and If not objFSO.FolderExists("X:\Windows\Temp\SMSTSLog") then Folder1 = false End If If objFSO.FolderExists("C:\Windows\Temp\SMSTSLog") Then Folder1 = "C:\Windows\Temp\SMSTSLog" Set FoldPath1 = objFSO.getFolder(Folder1) Else Folder1 = "X:\windows\Temp\SMSTSLog" Set FoldPath1 = objFSO.getFolder(Folder1) End If 'Folder2 If not objFSO.FolderExists("C:\Windows\System32\CCM\Logs") and If not objFSO.FolderExists("X:\Windows\System32\CCM\Logs") then Folder2 = false End If If objFSO.FolderEXists("C:\Windows\System32\CCM\Logs") Then Folder2 = "C:\Windows\System32\CCM\Logs" Set FoldPath2 = objFSO.getFolder(Folder2) Else Folder2 = "X:\Windows\System32\CCM\Logs" Set FoldPath2 = objFSO.getFolder(Folder2) End If 'Folder3 If not objFSO.FolderExists("C:\Windows\SysWOW64\CCM\Logs") and If not objFSO.FolderExists("X:\Windows\SysWOW64\CCM\Logs") then Folder3 = false End If If objFSO.FolderExists("C:\Windows\SysWOW64\CCM\Logs") Then Folder3 = "C:\Windows\SysWOW64\CCM\Logs" set FolderPath3 =objFSO.getFolder(Folder3) Else Folder3 = "X:\Windows\SysWOW64\CCM\Logs" Set FoldPath3 = objFSO.getFolder(Folder3) End If set objFSO = CreateObject("Scripting.FileSystemObject") objFSO.OpenTextFile(MyTarget, 2, True).Write "PK" & Chr(5) & Chr(6) _ & String(18, Chr(0)) Set ShellApp = CreateObject("Shell.Application") Set zip = ShellApp.NameSpace(MyTarget) 'checks if files are there before trying to copy 'otherwise it will error out If folder1 = True And FoldPath1.files.Count >= 1 Then zip.CopyHere Folder1 End If WScript.Sleep 3000 If folder2 = true And FoldPath2.files.Count >= 1 Then zip.CopyHere Folder2 End If WScript.Sleep 3000 If folder3 = true And FoldPath3.files.Count >= 1 Then zip.CopyHere Folder3 End If WScript.Sleep 5000 set ShellApp = Nothing set ZipFile = Nothing Set Folder1 = Nothing Set Folder2 = Nothing Set Folder3 = Nothing createobject("wscript.shell").popup "Zip File Created Successfully", 3

    Read the article

  • IIS7 bulk bindings in vbscript , how to remove a binding

    - by minus4
    I have a script to manage adding over a thousand domains to a single site bindings, this has gone fine, but now client wants about 20 of them removed, Microsoft programmers don't think it would be nice to sort the bindings alphabetically, so does anyone know the code to remove the domains ( array list ) in bulk please. this is what i am using: Set adminManager = createObject("Microsoft.ApplicationHost.WritableAdminManager") adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST" Set sitesSection = adminManager.GetAdminSection("system.applicationHost/sites", "MACHINE/WEBROOT/APPHOST") Set sitesCollection = sitesSection.Collection siteElementPos = FindElement(sitesCollection, "site", Array("name", "microsites")) If siteElementPos = -1 Then WScript.Echo "Element not found!" WScript.Quit End If on error resume next Set siteElement = sitesCollection.Item(siteElementPos) Set bindingsCollection = siteElement.ChildElements.Item("bindings").Collection Dim arrFileNames : arrFileNames = Array("list of domains") Dim objDict : Set objDict = CreateObject("Scripting.Dictionary") Dim strFileName, strTemp For Each strFileName In arrFileNames Set bindingElement = bindingsCollection.CreateNewElement("binding") bindingElement.Properties.Item("protocol").Value = "http" bindingElement.Properties.Item("bindingInformation").Value = "192.168.100.19:80:" & strFileName bindingsCollection.AddElement(bindingElement) Next adminManager.CommitChanges() WScript.Echo "Job Completed" WScript.Quit Function FindElement(collection, elementTagName, valuesToMatch) For i = 0 To CInt(collection.Count) - 1 Set element = collection.Item(i) If element.Name = elementTagName Then matches = True For iVal = 0 To UBound(valuesToMatch) Step 2 Set property = element.GetPropertyByName(valuesToMatch(iVal)) value = property.Value If Not IsNull(value) Then value = CStr(value) End If If Not value = CStr(valuesToMatch(iVal + 1)) Then matches = False Exit For End If Next If matches Then Exit For End If End If Next If matches Then FindElement = i Else FindElement = -1 End If End Function so as you can see it is easy to add, but i can find no code or manual or instructions for the removal. i cant seem to run appcmd either. at first i tried creating a batch file using the appcmd but this never worked, saying appcmd can not be found. thanks

    Read the article

  • How can I cause Task Scheduler to "fail" if a dialog box returns a certain result?

    - by Roger
    I'm working on a VBScript to do a weekly reboot of all machines on our network. I want to run this script via Task Scheduler. The script runs at 3:00 AM, but there is a small chance that users may still be on the network at that time, and I need to give them the option to terminate the reboot. If they do so, I would like the reboot to occur the next night at 3:00 AM. I've set Task Scheduler up to repeat in this way. So far, so good. The problem is that if the user selects "Cancel" in my script, the Task Scheduler does not see my task as failed, and won't run it again the next night. Any ideas? Can I pass an errorcode to task scheduler or otherwise abort the task via VBScript? My code is below: Option Explicit Dim objShell, intShutdown Dim strShutdown, strAbort ' -r = restart, -t 600 = 10 minutes, -f = force programs to close strShutdown = "shutdown.exe -r -t 600 -f" set objShell = CreateObject("WScript.Shell") objShell.Run strShutdown, 0, false 'go to sleep so message box appears on top WScript.Sleep 100 ' Input Box to abort shutdown intShutdown = (MsgBox("Computer will restart in 10 minutes. Do you want to cancel computer restart?",vbYesNo+vbExclamation+vbApplicationModal,"Cancel Restart")) If intShutdown = vbYes Then ' Abort Shutdown strAbort = "shutdown.exe -a" set objShell = CreateObject("WScript.Shell") objShell.Run strAbort, 0, false End if Wscript.Quit Appreciate any thoughts.

    Read the article

  • A script that writes errors and should create a event-error

    - by helmich
    this if it works should check the internet connection if there is a connection it does nothing. if there isn't a connection it should write a error in a txtfile if that happend 5 times it should create a error but it doesn't I will show you the whole code that i have now and the piece of code that i want in a loop. I can't get it in the way i want. I want it to creat 1 Event-error after 5 times writing to the file. this is the whole code i will put the code i want in a loop under it strDirectory = "Z:\text2" strFile = "\foutmelding.txt" strText = "De connectie is verbroken" strWebsite = "www.helmichbeens.com" If PingSite(strWebsite) Then WScript.Quit 'Website is pingable - no further action required Set objFSO = CreateObject("Scripting.FileSystemObject") RecordSingleEvent Dim fout For fout = 1 To 5 : Do If fout = 5 Then Exit Do Set WshShell = WScript.CreateObject("WScript.Shell") Call WshShell.LogEvent(1, "Test Event") Loop While False : next '------------------------------------ 'Record a single event in a text file '------------------------------------ Sub RecordSingleEvent If Not objFSO.FolderExists(strDirectory) Then objFSO.CreateFolder(strDirectory) Set objTextFile = objFSO.OpenTextFile(strDirectory & strFile, 8, True) objTextFile.WriteLine(Now & strText) objTextFile.Close End sub '---------------- 'Ping my web site '---------------- Function PingSite( myWebsite ) Set objHTTP = CreateObject( "WinHttp.WinHttpRequest.5.1" ) objHTTP.Open "GET", "http://" & myWebsite & "/", False objHTTP.SetRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MyApp 1.0; Windows NT 5.1)" On Error Resume Next objHTTP.Send PingSite = (objHTTP.Status = 200) On Error Goto 0 End Function '----------------------------------------------- 'Counts the number of lines inside the text file '----------------------------------------------- Function EventCount(fout) strData = objFSO.OpenTextFile(strDirectory & strFile,ForReading).ReadAll arrLines = Split(strData,vbCrLf) EventCount = UBound(arrLines) End Function This is the whole code, and it doesnt work correctly becaus it creats a event-log rightaway and it should do that after the script has written 5 times to the textfile here is the code that writes to a textfile Sub RecordSingleEvent If Not objFSO.FolderExists(strDirectory) Then objFSO.CreateFolder(strDirectory) Set objTextFile = objFSO.OpenTextFile(strDirectory & strFile, 8, True) objTextFile.WriteLine(Now & strText) objTextFile.Close End sub and here is the code but this part doesnt not work or atleast i think it is this part Dim fout For fout = 1 To 5 : Do If fout = 5 Then Exit Do Set WshShell = WScript.CreateObject("WScript.Shell") Call WshShell.LogEvent(1, "Test Event") Loop While False : next Function EventCount(fout) strData = objFSO.OpenTextFile(strDirectory & strFile,ForReading).ReadAll arrLines = Split(strData,vbCrLf) EventCount = UBound(arrLines) End Function this is the not working part and I don't know what to do anymore so can you please take a look at it tank you very much. btw: this code can be very usefull for a network administrator

    Read the article

  • VBS Runtime error code 800A01B6

    - by salvationishere
    I am a newbie to VBS scripting. I am getting above error on line 54, character 5 in script below. This error says "Object doesn't support this property or method: 'MimeMapArray'". And line it is referring to is: MimeMapArray(i) = CreateObject("MimeMap") Can u tell me what I am doing wrong? Here is the script in its entirety. Note, I am trying to run this on an XP OS by double-clicking this VBS file. ' This script adds the necessary Windows Presentation Foundation MIME types ' to an IIS Server. ' To use this script, just double-click or execute it from a command line. ' Running this script multiple times results in multiple entries in the IIS MimeMap. ' Set the MIME types to be added Dim MimeMapObj Dim MimeMapArray Dim WshShell Dim oExec Const ADS_PROPERTY_UPDATE = 2 Dim MimeTypesToAddArray MimeTypesToAddArray = Array(".manifest", "application/manifest", ".xaml", _ "application/xaml+xml", ".application", "application/x-ms-application", _ ".deploy", "application/octet-stream", ".xbap", "application/x-ms-xbap", _ ".xps", "application/vnd.ms-xpsdocument") ' Get the mimemap object Set MimeMapObj = GetObject("IIS://LocalHost/MimeMap") ' Call AddMimeType for every pair of extension/MIME type For counter = 0 to UBound(MimeTypesToAddArray) Step 2 AddMimeType MimeTypesToAddArray(counter), MimeTypesToAddArray(counter+1) Next ' Create a Shell object Set WshShell = CreateObject("WScript.Shell") ' Stop and Start the IIS Service Set oExec = WshShell.Exec("net stop w3svc") Do While oExec.Status = 0 WScript.Sleep 100 Loop Set oExec = WshShell.Exec("net start w3svc") Do While oExec.Status = 0 WScript.Sleep 100 Loop Set oExec = Nothing ' Report status to user WScript.Echo "Windows Presentation Foundation MIME types have been registered." ' AddMimeType Sub Sub AddMimeType(ByVal Ext, ByVal MType) ' Get the mappings from the MimeMap property. MimeMapArray = MimeMapObj.GetEx("MimeMap") ' Add a new mapping. i = UBound(MimeMapArray) + 1 ReDim Preserve MimeMapArray(i) MimeMapArray(i) = CreateObject("MimeMap") MimeMapArray(i).Extension = Ext MimeMapArray(i).MimeType = MType MimeMapObj.PutEx ADS_PROPERTY_UPDATE, "MimeMap", MimeMapArray MimeMapObj.SetInfo() End Sub

    Read the article

  • wait for the second VB script untill ended from primary VB script

    - by yael
    Hi I have VB script that run second VB script The second VB script ask some questions from the input box My problem is that “MyShell.Run” not wait until SecondVBscript.vbs will ended And the Other VB syntax run immodestly also Need to wait for MyShell.Run process ended and then perform the Other VB syntax How can I do that? Set MyShell = Wscript.CreateObject("WScript.Shell") MyShell.Run " C:\Program Files\SecondVBscript.vbs" Set MyShell = Nothing Other VB syntax

    Read the article

  • Why won't my logon scripts map drives under Windows 7?

    - by Steven
    Why won't my logon scripts map drives under Windows 7? I'm using a vb script similar to the one below, the script runs using a group policy. Dim WshNetwork Set WshNetwork = WScript.CreateObject("WScript.Network") WshNetwork.MapNetworkDrive "g:", "\\\Saturn\data\" WshNetwork.MapNetworkDrive "k:", "\\\Saturn\stuff\" Works fine for Windows XP. Update: Copying the script locally and running it runs fine so I suspect the Group Policy isn't running the script on Windows 7. Many thanks Steve

    Read the article

  • executing two functions with wshshell

    - by sushant
    i have two different functions (copy and zip) to b executed. can i do it with with a single wshshell script.i tried---- Dim WshShell, oExec,g,h h="D:\d" g="xcopy " & h & " " & "D:\y\ /E & cmd /c cd D:\c & D: & winzip32.exe -min -a D:\a" Set WshShell = CreateObject("WScript.Shell") Set oExec = WshShell.Exec(g) Do While oExec.Status = 0 WScript.Sleep 100 Loop WScript.Echo oExec.Status it dint work.though separate programs i.e g="xcopy " & h & " " & "D:\y\ /E" and g="cmd /c cd D:\d & D: & winzip32.exe -min -a D:\a" works. i am sorry for the formatting problem. any help is appreciated.

    Read the article

  • How do you set up your JScript (NOT JScript.NET) development environment?

    - by jJack
    In my environment, if I create a class in JScript syntax: class test{ } and then save it to a file named "test.js" and run it with wscript, I get a Microsoft JScript "Syntax error" at line 1. However, if I simply, say, write a function: function getInput() { var wshell = WScript.CreateObject("WScript.Shell"); wshell.Popup ("Do you want to continue?"); return userInput } getInput() and run it the same way, it works. Hopefully, there is something fundamentally wrong with my class definition. If that is the case, I am excited to find out.

    Read the article

< Previous Page | 1 2 3 4 5 6 7  | Next Page >