Vbscript

I have a vbscript(xxx.vbs) on my local machine and would like to kick this from an oracle procedure. Any Ideas???

Assuming you can expose this in a DLL (my VBScript is rusty, but I'm pretty confident you can), you can set up an external procedure that would call the script. I'm assuming that the script will live on the database machine here.
Justin

Similar Messages

  • Ipod and Windows Vista - VBScript

    When trying to downlaod Itunes 7.1.1 - I am getting an error message "Itunes can not be installed beacuse Visual Basic Script is not installed or has been diabled". Dell tried downlaoding it still the same error message. They say Apple is not compadable with Itunes yet.

    even though the following document talks about Windows XP rather than Vista, try using the instructions for registering VBScript.dll from it:
    iTunes and QuickTime for Windows cannot be installed without Visual Basic Script (VBScript)

  • Can No Longer Read Uninstall Keys with vbscript package run by SCCM

    Hi, 
    I've been using vbscript packages in SCCM for over a decade, and one thing I do is use the registry to determine if I need to uninstall an old program with the Value:
    HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\
    or
    HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall
    Example code snip:
    UnstKey = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{81BE0B17-563B-45D4-B198-5721E6C665CD}"
    UnstVal = wshShell.RegRead(UnstKey & "\UninstallString")
    If I run this manually, it works great, but all of a sudden, when I run a vbscript like this in SCCM it now returns: 
    Invalid root in registry key "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{...}\UninstallString"
    I normally run everything whether or not a user is logged on as System, but I did a test, and it even fails if I run the package as the user, which really surprised me. I check permissions in registry key, and Everyone has read, System has Modify.
    This code was working about a month ago. No changes to SCCM that I know. Sadly, we are still running 2007 SP2
    Please help!

    If anyone else stumbles on this issue, you're almost certainly running into the issue with 64bit clients.  Config Manager Agent runs as a 32bit process so won't read the registry key from the location you're expecting.  This uninstall strings will
    be in the following location:
    HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\
    If you need an existing VBScript to run you'll want to call the following:
    %windir%\Sysnative\wscript.exe 
    Hope this helps.  I should have spotted this with my Config Manager earlier.  Had me scratching my head for a while.

  • Need help in writing a vbscript

    Hi,
    I need help in wring a vbscript. I have serached for the vbscript on the net, but could not find any.
    I need to add a file to an msi using vbscript. - That's the requirement.
    For this I have done the following with the help of vbscript.
    1. With the insert statement I inserted a new copmonent in the FeatureComponent Table.
    2. Now the next thing I did is, I inserted a new row in the File table using insert statement again. The file is uncompressed.
    3. Since the file is a non-version file I also added a row in the MSIFileHash table.
    4. Also, now added the Component in the component table.
    After doing this I am able to see the chnages in the mst, however whrn I try to install it I get an error 2725 (Invalid database tables).
    Can somebody please post a vbscript which can add a file to an msi?

    Hi All,
    Thanks for all your responses.
    Yes, It is not so easy. I never said it was.  Thanks for pointing out Orca. We use Orca on a daily basis.
    What exactly I am looking at, is this.
    We have some standard applications which needs to be repackaged every month. The repackaging process is same and does not change at least for these packages. So I was actually looking at automating these things.
    What I did so far.
    First we have created an object for Windows installer. I have then taken a copy of the original msi and then opened the database of this temporary msi database in transact mode. Once the database is opened we can use select, insert, update
    and delete statements to update the database.  
    I could successfully add a registry to the msi. The component was also added successfully to the component table. I also could make changes to the Property table.
    The tricky part comes with the addition of file to the file table.
    The addition of file requires the following steps.
    1. Add a new row to the file table. This can be done with the Insert statement.
    2. We then need to associate the file to a new component or any other component already existing in the msi. In my case I am creating a new component.
    3. We then have to associate this components to a feature in the FeatureComponents table.
    4. Since the file I am adding is a non-versioned file, a new row also has to be added to the MSIFILEHASH table.
    I could see the changes that I have done using the mst. But when I try to install the msi with the mst, I get the error 2725. I checked everything. All the other steps except for the file addition works fine.
    To check whether I am indeed right, I have did this.
    Skipped the file addition part to the msi. Every other change that I make works and I am able to install the msi with the mst successfully.
    For obvious security reasons I will not be able to share the vbscript with you. If you guys think, that this is not a right forum for this question, please let me know the right forum. I have been stuck with this issue from the past 6 months. Any help would
    really be appreciated.

  • VBScript editor with Intellisense/Code Hinting support for Adobe App

    I am looking for some tool to write my InDesign VBScript files in. I would really like to know if there is any which support Intellisense/Code hinting for Adobe programs (InDesign especialy). Do you have anything to recommend?
    I am quite good at hacking my computer, so no registry change etc. is a problem for me, I just can not find any. I already tried PrimalScript 2009 but it doesn not work.
    What I need is that in following block of code
    Set myInDesign = CreateObject("InDesign.Application.CS4")
    Set myDialog = myInDesign.Dialogs.Add
    I will get list of all methods/properties after I write the dot after "myInDesign" in second line. But it never worked. I even tried to put "InDesign.Application.CS4/C:\ProgramData\Adobe\InDesign\Version 6.0\cs_CZ\Scripting Support\6.0\Resources for Visual Basic.tlb" line into Options>Text editor>Type libraries.
    I am using Windows Vista SP1 and I have Adobe Creative Suite CS4 installed (upgrade from CS3 which was upgraded from CS2)
    Thanks a lot for any help/suggestion, as I start feeling desperate.

    Hi Everyone!
    As I have said, I waited for next service release, which is as of now PrimalScript 2009 version 5.0.614 and I did some testing with it.
    Results:
    WinXP EN Professional
    - Just pointing PrimalScript 2009 to typelib, no creative suite installed, working
    - Installed Creative Suite CS3 Czech (trial mode) - Working, no need to setup anything
    - Installed Creative Suite CS3 + CS4 Czech (trial mode) - Need to point PrimalScript 2009 to correct typelib, then 100% working
    Windows Vista SP1 Ultimate EN (in trial/not activated mode)
    - Just pointing PrimalScript 2009 to typelib, no creative suite installed, working
    - Installed Creative Suite CS3 Czech (trial mode) - Need to point PrimalScript 2009 to correct typelib, then 100% working
    - Installed Creative Suite CS3 + CS4 Czech (trial mode) - Need to point PrimalScript 2009 to correct typelib, then 100% working
    Windows 7
    I am not planning to use Win7 in near future, so I did not not run any test on it.
    Windows Vista SP1 Home Premium Slovak (fully activated)
    - Installed Creative Suite CS3 + CS4 Czech (full mode) - Not working. This is my main machine. It is Creative Suite CS2 upgraded to CS3 then CS4 (it is running for years without reinstall). I use CS3/CS4 side by side for some older projects. There are still references to CS2 in registry. I tried pointing PrimalScript 2009 to correct typelib, but to no avail. My conclussion is that there is someting messed with its config or registry, but I am pretty sure it would run after complete system reinstall.
    Both WinXP EN Pro and Vista SP1 Ultimate EN were clean install into MS Virtual PC 2007, with only Creative Suite and PrimalScript 2009 5.0.614 installed into each machine so I made sure there are no other issues involved.
    As I spend 80% of my time with developement of websites and scripting of MS Office/Creative Suite, I have some virtual machines set up for testing purposes. I will use one of them for development in PrimalScript and move it to main (real) Windows Vista Home Premium Slovak installed once I will decide to completely reinstall it. The need for seting up the typelibray link is no deal for me, as it is working as expected then, and I expect a lot ;-)
    So problem solved, I found o program I will use. There may be others which do better or are cheaper (but I do not know about any) but $299 is not a big issue when I get what I want.
    P.S.: The solution with making VBScript code with VBA declaration (using Dim) is not a solution I like, as I would need to comment it out everytime I run/edit  the script and it would be pain in the *** while debugging it as i would need to do lot of comment/uncomment cycles and i can use my ime better then doing the monkey work as some fo the scripts I write are quite huge and I prefer to build them incrementaly and test/debug a lot.
    I wish to thank everyone for their help and suggestions,
    Matus

  • Call a Vbscript from a stored procedure

    Hi,
    I wonder is it possible to call a Vbscript from a stored procedure, any good reference for this.
    thanks

    Well here is quick and dirty example I just created.
    Step 1. Create a test_batch.bat file that creates a folder "c:\test_dir" and copy "c:emp.lst" into it.
    C:\oracle102\examples\test_batch.bat
    md c:\test_dir
    copy c:\emp.lst c:\test_dir
    Step2. From SQLPLUS, spool scott.emp into c:\emp.lst and call the batch from the dbms_scheduler that kicks off right away,
    set echo off
    set feedback off
    spool c:\emp.lst;
    select * from scott.emp;
    spool off;
    begin
         dbms_scheduler.create_job(job_name => 'run_batch',
         job_type => 'EXECUTABLE',
         job_action => 'C:\oracle102\examples\test_batch.bat',
         start_date => sysdate,
         enabled => true,
         comments => 'Run VB Script');
    end;
    Check if the directory is created and if the file is copied over. Task is to kick off the executable and test is the VBscript within the batch. Challenge is how long the script runs before the next statement in the PL/SQL runs. May be you have to introduce sleep in between.
    Note: You must have at least "CREATE JOB" privilege.
    Happy coding!
    Prakash
    Message was edited by:
    Prakash Rai

  • Trying to simply connect to Oracle with VBscript/ASP - and I cannot.

    This is rather embarrassing. I am pretty fluent with ASP and VBscript, and I have written many a web application connecting to Microsoft SQL Server. Now I have a need to connect to an Oracle database, and I'm beating my head against the wall.
    1) Web server is Windows Server 2003 SP1
    2) Using ASP (not ASP.NET) & VBscript
    3) I have installed the Oracle drivers on the server - it is version 10g
    4) The administrator of the Oracle database to which I want to connect has created a username and password for me to use from within my code
    5) Here is the code I am trying to run:
    Set objConn = Server.CreateObject("ADODB.Connection")
    objConn.Open "Provider=MSDAORA;Data Source=XXXXXXX;User Id=YYYYYYY;Password=ZZZZZZZ;"
    That's it. 2 lines of code just trying to establish a connection. Using the user name and password provided to me by the administrator, and for Data Source I am using the IP address of the Oracle server (like I have done in the past when connecting to SQL Server). I receive the following error message when viewing this in a browser:
    Microsoft OLE DB Provider for Oracle error '80004005'
    ORA-12154: TNS:could not resolve the connect identifier specified
    Evidently, the Data Source I am using is not correct, but I was provided no other information from the admin. This is the first time any of us have tried to connect to Oracle using ASP/VBScript, so the administrator isn't sure what I need to do ... any help would be so appreciated.

    Hello,
    I got mine to work by setting up an ODBC System DSN and connecting to it. I think this bypasses the Microsoft driver, which might be what's causing the problem.
    Set Db = Server.CreateObject("ADODB.Connection")
    Db.Open "DSN=TEST;User ID=userid;Password=password;"
    Good luck, I've found it requires a lot of persistence...
    Al
    Springfield, MO

  • How to open and edit a VBscript file?

    Hi,
    I'm fairly proficient with Dreamweaver CS3.  However, i'm finding one aspect of CS4 to be baffling to the extreme.
    I work with VBScript files.  When I open up a script file that includes other script files, the name of the parent file is seen on a tab (with an x to the right of it).  Below it are tabs for all of the files that are included (via an include statement in the code).  That's nice.
    When I click on one of the included files I see that file show up in my window.  However, I am unable at this point to get back to the file that included this one; i.e., the master file that is still above the other files.
    If I click on the tab for the master file, I don't see the contents of this file.  If I click on the small white paper icon (with the top right corner folded) on the left navigation bar, I see the name of the master file.  Selecting it still doesn't fill my editor window with the master file.
    There is a little symbol on the right side of the tabs for the included files.  (It looks like >>, except the arrows face down.)  This has the list of all of the files that I have open, minus the master file.
    It is very hard to believe that Dreamweaver would make CS4 this hard to use.  Unfortunately, I have no idea how to get the master file back in the editor window after I have clicked on one of the files it includes.  Can anyone point me in the right direction?  thanks.

    Hi,
    Use JDeveloper to import the mwp project .In Jdeveloper,File->Import->ToplinkWorkbench->Select the .mwp file and can work from JDeveloper in editing the tlmap.xml and session.xml.
    Regards,
    P.Vinay Kumar

  • VBscript and Process Responding to flag a script exit?

    Hey All
    I work for a small game company called The Good Mood Creators and I am trying to build a software kit that can be handed to someone, and with minimal effort on their part. Copy the folder to their PC, plug in an xbox controller, click the BEGIN.*** and play
    while our testing tools and streaming software have a chance to successfully start.
    FYI I do not program for our game..
    The tool I am including with this kit is a controller emulator (XBCE) that allows us to print controller input directly to the screen.
    I am using Open Broadcasting Software to stream gameplay to a private twitch channel via a simple batch called in this vb.
    My problem is that XBCE often hangs, and with some computers requires reinstalling .NET frameworks as well as the full directx distribution before updating again to get it to start. When it works however, XBCE will hang once started 1/10 times or so, then
    randomly a few times in a row. I don't want the remote playtester to start recording video before the tools are started. So I wrote a script that checks to see if the program is running a short time after its been started.
    <job>
    <script language="VBScript">
    Option Explicit
    On Error GoTo 0
    Dim os
    Dim wmi
    Dim procs
    set os=CreateObject("WScript.Shell")
    set wmi = GetObject ("winmgmts:")
    os.CurrentDirectory = "C:\Users\Public\TESTPC-remote\"
    os.run "XBCE.exe"
    While True
        Set procs = wmi.ExecQuery("select * from Win32_Process Where Name = 'XBCE.exe'")
        If procs.Count > 0 Then
            Wscript.echo "Initiate Good Mood?"        
            os.run "DATA\Mekazoo.exe"
            WScript.Sleep 1000
            os.run "DATA\obsSTART.bat"
            WScript.Sleep 1000
            WScript.Quit
        Else
            WScript.Echo "Good Mood Initialization Had Failed! Please Close All Running Applications And Try Again"
            WScript.Quit
        End If
    Wend
    </script>
    </job>
    But when its hung and not responding to the task manager, the process XBCE.exe is still getting listed in Win32 Processes. The script believes all is good and initializes the stream, but XBCE wont show up on the recording because it has crashed and windows
    is waiting for me to wait or close.
    I have searched but to no avail have I found a way to check if the task manager thinks if XBCE is hung, then proceed to quit the script. That's all I really need. If its not hung proceed, if it's hung quit. Can someone please help?
    Edit
    I have updated the code above to reflect my current progress with this question and so you dont have to dig through my terrible formatting.

    I have a few questions that I haven't got the vocabulary to figure out I guess.
    -Is there anyway to automate changing the execution policy?
    I tried sending powershell two commands from a ps1. Set-ExecutionPolicy Restricted and Set-ExecutionPolicy Unrestricted. Obviously it blocks the script from running to change from restricted. So I either needed a way through the problem or around it. I could
    ask the person playtesting to Win+R powershell.exe and type Set-ExecutionPolicy to Unrestricted and then include a line in the script to change it back once everything has started. The problem with this is the user having to change the executionpolicy
    every time they try to play, and the biggest reason I dont like this is that the user has to mess with powershell at all. That was my way around the problem.
    My way through the problem was to find a way to bypass the execution policy. I tried running a few lines of code I picked up here in cmd as a batch file and a javascript file. The line I ran was:
    http://stackoverflow.com/questions/9271681/how-to-run-powershell-script-even-if-set-executionpolicy-is-banned
    powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -WindowStyle Hidden -File <C:\Users\Public\TESTPC-remote\switchrun.ps1>
    Batch through cmd gave me bad syntax, JS basically said the same thing and suggested adding semicolons to fix the problems.
    -What is the script syntax to start a diagnostic process and then check to see if its true?
    I can not figure out how to write the script to both start XBCE as a diagnostic process and then immediately after see if its responding. I can send the command to start but powershell doesnt move to the next line.
    $p=[System.Diagnostics.Process]::Start('C:\Users\Public\TESTPC-remote\XBCE.exe')
    While $p.Responding = True
    Invoke and start both cause powershell to stop..
    -Can I use this command and chain the start commands together?
    While writing the script I have now I thought about the possibility of running a program, check to see if responding equals true as a case to start the next program, or else stop the previous process and close the session. Here's my gibberish with that:
    $p=[System.Diagnostics.Process]::Start('C:\Users\Public\TESTPC-remote\XBCE.exe')
    While $p.Responding = True
    $p=[System.Diagnostics.Process]::Start('C:\Users\Public\TESTPC-remote\Mekazoo.exe')
    Else Stop-Process ('XBCE.exe')
    Exit-PSSession
    While $p.Responding = True
    $p=[System.Diagnostics.Process]::Start('C:\Users\Public\TESTPC-remote\OBS.exe')
    Else Stop-Process ('Mekazoo.exe', 'XBCE.exe')
    Exit-PSSession
    I have more questions but honestly with how many people have viewed my question vs answered it's clear I'm just an idiot and need to read more.. but Ill keep posting.
    Youneed to drop back andlearn a bit more about how software based systems wotj and how progrmming systems work.
    THe code you posted cannot funciton because it makes no technical sense.
    We cannot answer every little questionfor you. You need to spend time learning the basics and ask quesitons when a real issue confuses you.
    You cannot use a non-existent variable in a loop test becase it wil always evaluate to false and the loop will never execute.  This si programming 101.
    Execution policy IS automated via Group Policy. Please as you domain admmisn or Netowrk Admmin to explain the to you. 
    Your original question has been answered.  If you have another issue please open a new topic.
    ¯\_(ツ)_/¯

  • Export to excel with javascript/vbscript or with plsql(html table)

    i have searched for a way to export data from OracleXe to excel without losing formatting .
    So far i have found 2 possible relatively easy ways that i am still researching
    (i do not include the ask tom sylk format way of exporting )
    1 to export the query to a html table, while using stylesheets for formatting
    (using microsoft specific styles)
    2. use of javascript/vbscript to fill an array and write this array to excel with use
    of visual basic for applications in excel.This also provides charting capabilities.
    I am still researching this two ways, and have
    encountered a few obstacles (help would be appreciated)
    1 the first way:
    a. create a button " export to excel"
    b. create the following pl/sql procedure:
    owa_util.mime_header('application/vnd.ms-excel');
    owa_util.http_header_close;
      HTP.PRINT('<html>');
      HTP.PRINT('<head>');
      HTP.PRINT('<meta http-equiv="Content-Type" content="text/html">');
      HTP.PRINT('<title>Title of the HTML File</title>');
      HTP.PRINT('</head>');
      HTP.PRINT('<body TEXT="#000000" BGCOLOR="#FFFFFF">');
      HTP.PRINT('<h1>Heading in the HTML File</h1>');
      HTP.PRINT('<p>Some text in the HTML file.');
      HTP.PRINT('</body>');
      HTP.PRINT('</html>');
    htmldb_application.g_page_text_generated := true;
    htmldb_application.g_unrecoverable_error := true;
    c: run the procedure conditionally based on the button  "export to excel"
    the problem with this way is that using htmldb_application.g_unrecoverable_error := true; is not the ideal way, because it
    stops further processing, but if i leave it out, the export doesn't happen.
    To export to excel while retaining data formatting  you have to use microsoft excel
    specific styles(Seedocumentation on the microsoft site)
    2.The second way:
    a create a pl/sql procedure or sql query.
    b use this query to fill a vbscript/javascript array with values
    c write these values to excel with use of vba in excel :
    the obstacle i encountered here was that i dont know how to export the result of a
    query to a visual basic script or javascript array.

    Using approach 1) works fine for me.
    the problem with this way is that using htmldb_application.g_unrecoverable_error := true;
    is not the ideal way, because it
    stops further processing, but if i leave it out, the export doesn't happen. Why is this a problem?
    I created the button to export the excel file on page 1 and created your pl/sql procedure on page 2 using an onload process.
    Works fine.
    Other approaches for exporting to excel are:
    http://www.oracle.com/technology/pub/articles/saternos_broadcast.html
    http://htmldb.oracle.com/pls/otn/f?p=18326:54:5685133631021176591::::P54_ID:1962
    ~Dietmar.

  • Adobe VBScript or COM API fails when Adobe application not already open on a certain machine

    Was wondering if anybody might have input on this or observed this themselves. Is there a known issue/bug for this?
    I'm building scripted tooling to automate tasks in Adobe Illustrator and Photoshop, using the COM API (what Adobe lists as VBScript scripting reference, but is really COM). I've tested with both JScript (Microsoft Javascript, for doing same things you would use VBScript for) and Python using COM. In both cases got the same issue.
    When I was building the tooling, it works fine for me. But on a colleagues machine, the problem comes up. Sadly the error messaging is vague to pinpoint the root cause of the problem. We just know when it happens, but not why/how. We both have Windows 7 64-bit and are using 64-bit version of the Adobe apps, version CS6. Though we also have 32-bit version installed as well.
    The funny thing about my colleague's machine is the the tool/script will execute fine if Adobe Illustrator/Photoshop is already open. But if the app is not open already, it just fails at the point of instantiating the COM object. On my machine it works fine in both cases.
    Here's the error output observed:
    in JScript
    C:\scripts>cscript windows_cli_script_runner.js /s:C:\scripts\test.jsx
    Microsoft (R) Windows Script Host Version 5.8
    Copyright (C) Microsoft Corporation. All rights reserved.
    C:\scripts\windows_cli_script_runner.js(25, 5) (null): 0x800700C1
    in Python
    C:\scripts>python cli_script_runner.py -s C:\scripts\test.jsx
    cli_script_runner.py:33: SyntaxWarning: import * only allowed at module level
      def run_script(script,doc=None,app=None):
    Traceback (most recent call last):
      File "cli_script_runner.py", line 89, in <module>
        run_script(args.script)
      File "cli_script_runner.py", line 68, in run_script
        app_ref = win32com.client.Dispatch(app)
      File "C:\Python27\lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch
        dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
      File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 114, in _GetGoodDispatchAndUserName
        return (_GetGoodDispatch(IDispatch, clsctx), userName)
      File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 91, in _GetGoodDispatch
        IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch)
    pywintypes.com_error: (-2147024703, 'OLE error 0x800700c1', None, None)
    C:\scripts>
    basically both point to this line at failure:
    in JScript
    var app_ref = new ActiveXObject(app);
    in Python
    app_ref = win32com.client.Dispatch(app)
    where app is "Illustrator.Application.CS6" or "Photoshop.Application", per the Adobe scripting guide and VBScript scripting reference.
    I didn't test VBScript but assume it's the same since JScript and VBScript and Python are all using same COM interface, and VBScript and JScript using same Windows Scripting Host interface.

    Also, there appears to be rather an unfortunate bug.  If the publisher does not yet have a subscriber, it looks like these two properties return an error.  Oof.
    So. there is this other way to do it.  Embarrassing.
    var allowAudio:Boolean = true;
    var allowVideo:Boolean = true;
    publishingStream.send("|RtmpSampleAccess", allowAudio, allowVideo);
    Yep.  The secret vertical bar call.  I believe you can make this call once on the publishing stream.  However, that'll only get to the subscribers that are currently connected and it won't get to subscribers that have yet to connect.
    You can also call send on the specific subscribing streams to give different permissions to each subscriber.
    More...
    http://forums.adobe.com/thread/632355?tstart=0

  • Extracting data from Excel To Illustrator javascript or vbscript

    Hi all-
    I was wondering if there was a way to extract data from Excel to be used in Illustrator. I know there is an option of variables and xml, and I don't want that. I've seen and tried out how to read illustrator and write to excel, and I get that.  What I would like to do is pretty much the opposite:
    1.Pre-fill in an Excel file(.xls,.csv, doesn't matter) with data such as a filename in column 1 and (Replacement Text) in column 2 and close manually.
    2. Run script(VBSCRIPT,Javascript, doesn't matter)
    3.For each column in Excel file where cell in first column is not empty, open Illustrator Template with placeholder of "DWG" textframe and replace the frame titled "DWG" with Replacement text from Excel in Column2.
    4, Save each to a PDF file and name file with text from Excel Column1(Filename)
    In a nutshell, there will be a single illustrator template with a premade textFrame with a name of "DWG". Excel will contain two columns, one for the filename to be named and one for the relative text to replace with the placeholder in AI. I hoped I explained this well enough without causing too much confusion. Thanks in advance.
    Filename
    Replacement Text
    test1.pdf
    DWG01
    test2.pdf
    DWG02
    test3.pdf
    DWG03
    test4.pdf
    DWG04

    As text… \n is new line character and \r is return character. I can't remember which excel uses but they both equate to a line/paragraph… I very quickly threw together an example for you…
    #target Illustrator
    textToPDF();
    function textToPDF() {
              if ( app.documents.length == 0 ) { return; }
              var doc, csvFile, i, fileArray, opts;
              csvFile = File( '~/Desktop/ScriptTest/Test.csv' );
              if ( !csvFile.exists ) { return; }
              fileArray = readInCSV( csvFile );
              doc = app.activeDocument;
              opts = new PDFSaveOptions();
              opts.pDFPreset = '[Press Quality]';
              // Here we loop the main array
              for ( i = 0; i < fileArray.length; i++ ) {
                        // Here we get the second item of sub array i
                        doc.textFrames.getByName( 'DWG' ).contents = fileArray[i].[1];
                        // Here we get the first item of sub array i
                        doc.saveAs( File( fileArray[i].[0] ), opts );
    function readInCSV( fileObj ) {
              var fileArray, thisLine, csvArray;
              fileArray =[];
              fileObj.open( 'r' );
              while( !fileObj.eof ) {
                        thisLine = fileObj.readln();
                        csvArray = thisLine.split( ',' );
                        fileArray.push( csvArray );
              fileObj.close();
              return fileArray;
    I haven't tested it but it should be close…?

  • Vbscript RegRead function not behaving consistently and/or returning correct values when they exist in the registry

    Hello.
    I seem to be having a problem using the RegRead function within vbscript to return a simple value from the registry. When I run it on my workstation (windows 7 x64 sp1), it seems to miss certain registry values that are indeed there (specifically, I am looking
    for instances of "Adobe" in the displayName value of HKLM\Software\wow6432node\microsoft\windows\uninstall). However, when I run on a test VM, it returns the values fine. I am hoping someone might be able to explain this inconsistency and why it
    is happening.
    The code is very simple:
    On Error Resume Next
    if wscript.arguments.count < 1 then
    wscript.echo "usage: regread.vbs <hostname> <appname>"
    wscript.quit
    end if
    AppName = wscript.arguments(1)
    strComputer = wscript.arguments(0)
    const HKEY_LOCAL_MACHINE = &H80000002
    Set WshShell = WScript.CreateObject("WScript.Shell")
    Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!//"& strComputer & "/root/default:StdRegProv")
    strKeyPath = "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
    objReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
    For Each subkey In arrSubKeys
    'wscript.echo subkey
    InstalledAppName = ""
    InstalledAppName = WshShell.RegRead("HKLM\" & strKeyPath & "\" & subkey & "\DisplayName")
    wscript.echo vbtab&"DisplayName: "&InstalledAppName
    if instr(InstalledAppName,AppName) > 0 then
    wscript.echo vbcrlf&"found"&vbcrlf
    end if
    Next
    When I run "cscript regread.vbs remoteHost Adobe" on my local machine, it does not "find" any instance of Adobe within the registry of machine "remoteHost". However, when I run it from a test VM, it does find the existing instances
    of Adobe within the DisplayName value of the uninstall key of the registry, here is the output from both, first the non-working one, then the working test VM.
    Non-working:
    Microsoft (R) Windows Script Host Version 5.8
    Copyright (C) Microsoft Corporation. All rights reserved.
    DisplayName:
    DisplayName:
    DisplayName:
    DisplayName:
    DisplayName:
    DisplayName: GPL Ghostscript 8.60
    DisplayName: GPL Ghostscript Fonts
    DisplayName:
    DisplayName:
    DisplayName:
    DisplayName:
    DisplayName:
    DisplayName: Microsoft Office Professional Plus 2010
    DisplayName:
    DisplayName:
    DisplayName:
    DisplayName: Microsoft ASP.NET 2.0 AJAX Extensions 1.0
    DisplayName:
    DisplayName: Sybase PowerBuilder 12.0 Standard Runtime
    DisplayName: MSXML 4.0 SP3 Parser
    DisplayName:
    DisplayName:
    DisplayName:
    DisplayName:
    DisplayName:
    DisplayName:
    DisplayName:
    DisplayName: MSXML 4.0 SP3 Parser (KB2758694)
    DisplayName: Microsoft Visual C++ 2008 Redistributable - x86 9.0.30729.4148
    DisplayName:
    DisplayName:
    DisplayName:
    DisplayName:
    DisplayName:
    DisplayName: Microsoft Windows Journal Viewer
    DisplayName: Java Auto Updater
    DisplayName: VBA (2627.01)
    DisplayName: Microsoft Visual C++ 2005 Redistributable
    DisplayName:
    DisplayName: Apple Software Update
    DisplayName: SQL Anywhere 9 for Windows x64
    DisplayName: Microsoft Office Professional Plus 2010
    DisplayName:
    DisplayName:
    DisplayName:
    DisplayName: Update for Microsoft Office 2010 (KB2553267) 32-Bit Edition
    DisplayName:
    DisplayName:
    DisplayName:
    DisplayName: Update for Microsoft Office 2010 (KB2760631) 32-Bit Edition
    DisplayName:
    DisplayName:
    DisplayName: Update for Microsoft Office 2010 (KB2494150)
    DisplayName:
    DisplayName:
    DisplayName:
    DisplayName:
    DisplayName:
    DisplayName:
    DisplayName:
    DisplayName:
    DisplayName:
    DisplayName: HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{90140000-0011-0000-0000-0000000FF1CE}_Office14.PROPLUS_{9569DE03-1425-4D12-96EB-44D852AF759A}\DisplayName
    DisplayName:
    DisplayName:
    DisplayName:
    DisplayName: Update for Microsoft Office 2010 (KB2553065)
    DisplayName:
    DisplayName: Security Update for Microsoft Office 2010 (KB2598243) 32-Bit Edition
    DisplayName: Update for Microsoft Office 2010 (KB2825640) 32-Bit Edition
    DisplayName:
    DisplayName: Update for Microsoft Outlook Social Connector 2010 (KB2553406) 32-Bit Edition
    DisplayName: Security Update for Microsoft Office 2010 (KB2553371) 32-Bit Edition
    DisplayName:
    DisplayName:
    DisplayName:
    DisplayName: Security Update for Microsoft Office 2010 (KB2589320) 32-Bit Edition
    DisplayName:
    DisplayName:
    DisplayName:
    DisplayName: Update for Microsoft Office 2010 (KB2596964) 32-Bit Edition
    DisplayName: Update for Microsoft Office 2010 (KB2566458)
    DisplayName:
    DisplayName:
    DisplayName: Microsoft Office Access MUI (English) 2010
    DisplayName:
    DisplayName: Microsoft Office Excel MUI (English) 2010
    DisplayName:
    DisplayName: Microsoft Office PowerPoint MUI (English) 2010
    DisplayName:
    DisplayName:
    DisplayName: Microsoft Office Publisher MUI (English) 2010
    DisplayName:
    DisplayName: Microsoft Office Outlook MUI (English) 2010
    DisplayName: Update for Microsoft Outlook Social Connector 2010 (KB2553406) 32-Bit Edition
    DisplayName:
    DisplayName:
    DisplayName: Microsoft Office Word MUI (English) 2010
    DisplayName:
    DisplayName: Microsoft Office Proof (English) 2010
    DisplayName:
    DisplayName:
    DisplayName: Microsoft Office Proof (French) 2010
    DisplayName:
    DisplayName:
    DisplayName: Microsoft Office Proof (Spanish) 2010
    DisplayName:
    DisplayName:
    DisplayName:
    DisplayName:
    DisplayName:
    DisplayName:
    DisplayName:
    DisplayName:
    DisplayName:
    DisplayName: Microsoft Office Proofing (English) 2010
    DisplayName:
    DisplayName: Microsoft Office InfoPath MUI (English) 2010
    DisplayName:
    DisplayName: Microsoft Office Shared MUI (English) 2010
    DisplayName:
    DisplayName:
    DisplayName: Update for Microsoft Office 2010 (KB2553310) 32-Bit Edition
    DisplayName: Microsoft Office OneNote MUI (English) 2010
    DisplayName:
    DisplayName: Update for Microsoft OneNote 2010 (KB2553290) 32-Bit Edition
    DisplayName: Microsoft Office Groove MUI (English) 2010
    DisplayName:
    DisplayName: Microsoft Office Shared Setup Metadata MUI (English) 2010
    DisplayName:
    DisplayName:
    DisplayName: Microsoft Office Access Setup Metadata MUI (English) 2010
    DisplayName:
    DisplayName: Microsoft Office Visio Viewer 2003 (English)
    DisplayName: Cardiff TeleForm
    DisplayName:
    DisplayName:
    DisplayName: CodeMax Runtime Installer
    DisplayName: Microsoft .NET Framework 1.1
    DisplayName:
    DisplayName:
    DisplayName: Microsoft XML Parser
    DisplayName:
    DisplayName: Microsoft Visual C++ 2010 x86 Redistributable - 10.0.40219
    DisplayName:
    DisplayName:
    DisplayName:
    DisplayName:
    DisplayName:
    DisplayName:
    DisplayName:
    DisplayName:
    Working:
    Microsoft (R) Windows Script Host Version 5.8
    Copyright (C) Microsoft Corporation. All rights reserved.
    DisplayName:
    DisplayName:
    DisplayName:
    DisplayName: DYMO Label v.8
    DisplayName:
    DisplayName: GPL Ghostscript 8.60
    DisplayName: GPL Ghostscript Fonts
    DisplayName:
    DisplayName:
    DisplayName:
    DisplayName:
    DisplayName:
    DisplayName: Microsoft Office Professional Plus 2010
    DisplayName:
    DisplayName:
    DisplayName:
    DisplayName: Microsoft ASP.NET 2.0 AJAX Extensions 1.0
    DisplayName: Adobe Flash Player 11 Plugin
    found
    DisplayName: Sybase PowerBuilder 12.0 Standard Runtime
    DisplayName: MSXML 4.0 SP3 Parser
    DisplayName:
    DisplayName:
    DisplayName:
    DisplayName:
    DisplayName:
    DisplayName:
    DisplayName:
    DisplayName: MSXML 4.0 SP3 Parser (KB2758694)
    DisplayName: Microsoft Visual C++ 2008 Redistributable - x86 9.0.30729.4148
    DisplayName: Cisco WebEx Meeting Center for Internet Explorer
    DisplayName: Configuration Manager Client
    DisplayName: Java 7 Update 51
    DisplayName: Citrix Online Launcher
    DisplayName: MSXML 4.0 SP3 Parser (KB2721691)
    DisplayName: Microsoft Windows Journal Viewer
    DisplayName: Java Auto Updater
    DisplayName: VBA (2627.01)
    DisplayName: Microsoft Visual C++ 2005 Redistributable
    DisplayName: Microsoft Visual C++ 2005 Redistributable
    DisplayName: Apple Software Update
    DisplayName: SQL Anywhere 9 for Windows x64
    DisplayName: Microsoft Office Professional Plus 2010
    DisplayName: Update for Microsoft Filter Pack 2.0 (KB2810071) 32-Bit Edition
    DisplayName: Security Update for Microsoft Office 2010 (KB2826035) 32-Bit Edition
    DisplayName: Microsoft Office 2010 Service Pack 1 (SP1)
    DisplayName: Update for Microsoft Office 2010 (KB2553267) 32-Bit Edition
    DisplayName: Update for Microsoft PowerPoint 2010 (KB2553145) 32-Bit Edition
    DisplayName: Update for Microsoft Office 2010 (KB2589375) 32-Bit Edition
    DisplayName: Security Update for Microsoft Office 2010 (KB2687276) 32-Bit Edition
    DisplayName: Update for Microsoft Office 2010 (KB2760631) 32-Bit Edition
    DisplayName: Update for Microsoft OneNote 2010 (KB2810072) 32-Bit Edition
    DisplayName: Security Update for Microsoft InfoPath 2010 (KB2687422) 32-Bit Edition
    DisplayName: Update for Microsoft Office 2010 (KB2494150)
    DisplayName: Security Update for Microsoft Office 2010 (KB2687423) 32-Bit Edition
    DisplayName: Security Update for Microsoft Office 2010 (KB2597986) 32-Bit Edition
    DisplayName: Update for Microsoft Office 2010 (KB2794737) 32-Bit Edition
    DisplayName: Update for Microsoft SharePoint Workspace 2010 (KB2589371) 32-Bit Edition
    DisplayName: Security Update for Microsoft Publisher 2010 (KB2553147) 32-Bit Edition
    DisplayName: Security Update for Microsoft Office 2010 (KB2850016) 32-Bit Edition
    DisplayName: Definition Update for Microsoft Office 2010 (KB982726) 32-Bit Edition
    DisplayName: Security Update for Microsoft InfoPath 2010 (KB2760406) 32-Bit Edition
    DisplayName: Update for Microsoft Visio Viewer 2010 (KB2810066) 32-Bit Edition
    DisplayName: HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{90140000-0011-0000-0000-0000000FF1CE}_Office14.PROPLUS_{9569DE03-1425-4D12-96EB-44D852AF759A}\DisplayName
    DisplayName: Update for Microsoft Office 2010 (KB2767886) 32-Bit Edition
    DisplayName: Update for Microsoft Office 2010 (KB2597087) 32-Bit Edition
    DisplayName: Security Update for Microsoft Office 2010 (KB2687510) 32-Bit Edition
    DisplayName: Update for Microsoft Office 2010 (KB2553065)
    DisplayName: Update for Microsoft Access 2010 (KB2553446) 32-Bit Edition
    DisplayName: Security Update for Microsoft Office 2010 (KB2598243) 32-Bit Edition
    DisplayName: Update for Microsoft Office 2010 (KB2825640) 32-Bit Edition
    DisplayName: Security Update for Microsoft Visio 2010 (KB2810068) 32-Bit Edition
    DisplayName: Update for Microsoft Outlook Social Connector 2010 (KB2553406) 32-Bit Edition
    DisplayName: Security Update for Microsoft Office 2010 (KB2553371) 32-Bit Edition
    DisplayName: Update for Microsoft Office 2010 (KB2826026) 32-Bit Edition
    DisplayName: Update for Microsoft Office 2010 (KB2589298) 32-Bit Edition
    DisplayName: Security Update for Microsoft Excel 2010 (KB2826033) 32-Bit Edition
    DisplayName: Security Update for Microsoft Office 2010 (KB2589320) 32-Bit Edition
    DisplayName: Security Update for Microsoft Word 2010 (KB2863902) 32-Bit Edition
    DisplayName: Security Update for Microsoft Office 2010 (KB2826023) 32-Bit Edition
    DisplayName: Update for Microsoft Office 2010 (KB2760598) 32-Bit Edition
    DisplayName: Update for Microsoft Office 2010 (KB2596964) 32-Bit Edition
    DisplayName: Update for Microsoft Office 2010 (KB2566458)
    DisplayName: Update for Microsoft Office 2010 (KB2589352) 32-Bit Edition
    DisplayName: Security Update for Microsoft Outlook 2010 (KB2837597) 32-Bit Edition
    DisplayName: Microsoft Office Access MUI (English) 2010
    DisplayName: Microsoft Office 2010 Service Pack 1 (SP1)
    DisplayName: Microsoft Office Excel MUI (English) 2010
    DisplayName: Microsoft Office 2010 Service Pack 1 (SP1)
    DisplayName: Microsoft Office PowerPoint MUI (English) 2010
    DisplayName: Microsoft Office 2010 Service Pack 1 (SP1)
    DisplayName: Update for Microsoft PowerPoint 2010 (KB2553145) 32-Bit Edition
    DisplayName: Microsoft Office Publisher MUI (English) 2010
    DisplayName: Microsoft Office 2010 Service Pack 1 (SP1)
    DisplayName: Microsoft Office Outlook MUI (English) 2010
    DisplayName: Update for Microsoft Outlook Social Connector 2010 (KB2553406) 32-Bit Edition
    DisplayName: Update for Microsoft Outlook 2010 (KB2687623) 32-Bit Edition
    DisplayName: Microsoft Office 2010 Service Pack 1 (SP1)
    DisplayName: Microsoft Office Word MUI (English) 2010
    DisplayName: Microsoft Office 2010 Service Pack 1 (SP1)
    DisplayName: Microsoft Office Proof (English) 2010
    DisplayName: Microsoft Office 2010 Service Pack 1 (SP1)
    DisplayName: Update for Microsoft Office 2010 (KB2850079) 32-Bit Edition
    DisplayName: Microsoft Office Proof (French) 2010
    DisplayName: Microsoft Office 2010 Service Pack 1 (SP1)
    DisplayName: Update for Microsoft Office 2010 (KB2850079) 32-Bit Edition
    DisplayName: Microsoft Office Proof (Spanish) 2010
    DisplayName: Update for Microsoft Office 2010 (KB2850079) 32-Bit Edition
    DisplayName: Microsoft Office 2010 Service Pack 1 (SP1)
    DisplayName: Update for Microsoft Filter Pack 2.0 (KB2810071) 32-Bit Edition
    DisplayName: Update for Microsoft OneNote 2010 (KB2810072) 32-Bit Edition
    DisplayName: Update for Microsoft SharePoint Workspace 2010 (KB2589371) 32-Bit Edition
    DisplayName: Microsoft Office 2010 Service Pack 1 (SP1)
    DisplayName: Update for Microsoft Office 2010 (KB2760598) 32-Bit Edition
    DisplayName: Update for Microsoft Office 2010 (KB2589352) 32-Bit Edition
    DisplayName: Microsoft Office 2010 Service Pack 1 (SP1)
    DisplayName: Microsoft Office Proofing (English) 2010
    DisplayName: Microsoft Office 2010 Service Pack 1 (SP1)
    DisplayName: Microsoft Office InfoPath MUI (English) 2010
    DisplayName: Microsoft Office 2010 Service Pack 1 (SP1)
    DisplayName: Microsoft Office Shared MUI (English) 2010
    DisplayName: Microsoft Office 2010 Service Pack 1 (SP1)
    DisplayName: Security Update for Microsoft Office 2010 (KB2553284) 32-Bit Edition
    DisplayName: Update for Microsoft Office 2010 (KB2553310) 32-Bit Edition
    DisplayName: Microsoft Office OneNote MUI (English) 2010
    DisplayName: Microsoft Office 2010 Service Pack 1 (SP1)
    DisplayName: Update for Microsoft OneNote 2010 (KB2553290) 32-Bit Edition
    DisplayName: Microsoft Office Groove MUI (English) 2010
    DisplayName: Microsoft Office 2010 Service Pack 1 (SP1)
    DisplayName: Microsoft Office Shared Setup Metadata MUI (English) 2010
    DisplayName: Microsoft Office 2010 Service Pack 1 (SP1)
    DisplayName: Microsoft Office 2010 Service Pack 1 (SP1)
    DisplayName: Microsoft Office Access Setup Metadata MUI (English) 2010
    DisplayName: Microsoft Office 2010 Service Pack 1 (SP1)
    DisplayName: Microsoft Office Visio Viewer 2003 (English)
    DisplayName: Cardiff TeleForm
    DisplayName: Adobe Acrobat XI Pro
    found
    DisplayName: QuickTime
    DisplayName: CodeMax Runtime Installer
    DisplayName: Microsoft .NET Framework 1.1
    DisplayName: WinZip 15.0
    DisplayName: McAfee VirusScan Enterprise
    DisplayName: Microsoft XML Parser
    DisplayName: McAfee Agent
    DisplayName: Microsoft Visual C++ 2010 x86 Redistributable - 10.0.40219
    DisplayName:
    DisplayName:
    DisplayName:
    DisplayName:
    DisplayName:
    DisplayName:
    DisplayName:
    DisplayName: Apple Application Support
    Does anyone know why this might be happening? The only main difference is that the machine that the script does not work on, has visual studio 2013 installed.
    Please help

    Well I think we can agree that it is not supported remotely. Because while it did initially work remotely, it didnt behave consistently; that is, it worked on the VM, but not my desktop. That's the whole reason I created this thread. Sorry if you are confused,
    but I most certainly was not lying and not trying to troll the forum or whatever it is you are insuinuating. Chill out a little bit and maybe you might get that Microsoft MVP.
    I am trying to get you t understand why what you are saying is wrong.  You may have thought it worked but there were a number of things that make it impossible to actually work.
    You were enumerating a remote key.  You were using that key name with RegRead and it was looking up the local value.  That is why it could not find remote keys and values.  The local and remote machines will not match on all keys.
    The correct call is the "GetStringValue" of the registry provider because it is the only call that can read remote values. My point is that you were fooling yourself by thinking that it ever actually worked.  If anything it was just dumb luck
    that the keys would match. 
    So maybe you weren't actually lying but you were surely foolingyourself and confusing us.
    Anyway - glad you fixed it and just remember to not mix calls like you did.  Also don't use On Error Resume Next unless you plan on test every call for an error.
    ¯\_(ツ)_/¯

  • Is there a way of embedding JSP code in VBScript?

    I am launching MS Excel using VBScript in the JSP Page. I want to populate the spread sheet with the values coming from a Java Bean. I am not sure how I can embed JSP code in VBScript.
    Thanks

    I tried doing that with Javascript but it gives me error..
    here is the code I was testing..
    <script language="JavaScript">
    function test(){
    var name = <%=(bean.getName())%>;
    alert(name);
    </script>
    <input type="button" name="Button" value="test" onClick=javascript:test()>
    Error : Object Expected
    If I do a similar thing with VBScript, it doesnt work either.
    here is the test code for VBScript
    <SCRIPT LANGUAGE="VBScript">
    sub button1_onclick()
         dim name = <%=(bean.getName())%>
    ' Launch Excel
    dim app
    set app = createobject("Excel.Application")
    ' Make it visible
    app.Visible = true
    set rng2 = wb.Activesheet.Range("A1").Resize(2,2)
    rng2.value = name
    ' Give the user control of Excel
    app.UserControl = true
    end sub
    </SCRIPT>

  • How do I get the number of channels available in DIAdem using VBScript?

    I want to know the last number of the available channels in DIAdem-DATA using VBScript. If there are not enough channels, I'll allocate new ones using ChnAlloc.
    For the first run of the script, I do know there're 60 channels, but in a second run I might have created the additional channels already (if the script didn't fail) and I don't want to do the allocation a second time. So I need to know the number of the last channel. Unfortunatly I didn't find any function in the help providing this number.
    Thanks,
    Carsten

    Hi Carsten,
    I have a few thoughts for you plus some useful code. Bear in mind that you can change the number of static DIAdem channels (by default 60 of length 8192) as well as the number of available dynamic channels (by default 1000) to whatever you want. These memory matrix settings get stored in your Desktop.DDD file (DIAdem's ini file), so that each time you launch DIAdem it will create the channels according to your specifications. The maximum number of channels of all types that DIAdem can have is 65536 (2^16).
    Secondly, don't forget that you can address channels by name or by number. If the channels are named distinctly, addressing channels by name is the most reliable method. If you use ChnAlloc() to allocate new channels, and you want to address those new channels by channel number, you MUST use CNo() immediately after creating the new channel in order to find out that channel's number. It will not always be the next available channel number, because the next available channel may not be long enough. ChnAlloc() will latch on to an existing channel if it can find one long enough, and it will create new channels only if it finds none of the existing channels suitable.
    In the VBScript I attached to this email you will find all the DIAdem variables which contain information about the maximum available channels and the maximum length of each channel (not its currently set length). Note that DIAdem's data matrix is divided into 8 submatrices, each with 2 GBytes of addressable memory (2^31 Bytes). Each submatrix can have multiple static channels assigned to it. DIAdem's dynamic channels come first from DIAdem's application RAM (Windows allocates no more than 2 GBytes per application) then from the Windows swap file for its virtual memory
    Now, in addition to the variables which tell you the maximum possible channel count and lengths, another very useful variable is "GlobUsedChn", which returns the highest channel number currently filled with some amount of data.
    Ask if you have additional questions,
    Brad Turpin
    NI
    Attachments:
    View_DataMatrix.VBS ‏2 KB

  • VBScript which is called with Arguments from Command Line

    Hi There.
    I have been tasked to create a VBScript which needs to accomplish the following:
    It needs to be called from a command line using 4 different arguments, the arguments in order as follows:
    -          Drive letter including colon
    Warning threshold in percentage
    Warning threshold in GB remaining
    Recipient email address
    I need to be able to set up a scheduled task, to run this script, but at the same time I need to be able to specify multiple drive letters as separate steps but on a single task.  The script needs to automatically run every 4 hours, starting at 06:00AM
    in the morning and running no later than 22:00 at night.
    The end results, need to then be e-mailed to the Recipient which is specified in Argument (3).
    Following is my current script, it is not complete as I am currently pulling my hair out due to having a lack of knowledge of VBScripting....  :(  The current script also loops every 10 minutes or so, and uses the incorrect way of sending the results,
    we would like to use POSTIE.EXE to send the mail as we would want to eliminate web traffic (Microsoft Schema's) in this script.
    =====================================================================================
    Const emailFrom = "default_from_email_address_comes_here"      'From email address 
    Const ExchangeServer = "ExchangeServerName_comes_here"      'Enter your Exchange server name here (FQDN)
    Const WaitTimeInMinutes = 10                   'Wait time between loops. This is will be in minutes
    Dim WshShell, objArgs, strIP, objWMIService, LogicalVolumes, strDriveLetter
    Dim objItem, strDriveName, IntCapacity, IntFree, DiskFreePct
    Dim strIgnoreFlag
    Dim strMessage, IntStatistic
    on error resume next
      strDriveLetter         = WScript.Arguments(0)   'This is the drive letter which you want to monitor on the localhost
      DiskFreePct            = WScript.Arguments(1)   'This is the threshold percentage of free space
      ThresholdGB           = WScript.Arguments(2)
      Recipient                = WScript.Arguments(3)   'This is where the e-mail needs to be sent to
    If Err.Number <> 0 Then
      msgbox "You did not supply the arguments after calling the VBS file:" & vbcrlf & "<Drive Letter, eg:  C:>"& vbcrlf & "<Warning Threshold in Percentage> "& vbcrlf &"<Warning
    Threshold in GB Remaining> "& vbcrlf &"<Recipient E-Mail Address>"
      WScript.Quit
    End If  
    Set WshNetwork = WScript.CreateObject("WScript.Network")
    WScript.Echo WshNetwork.ComputerName
    arrServerList = array(WshNetwork.ComputerName)    'This is where your localhost will be used as the query
    Do until i = 2
        'Clear the message variable
        strMessage = ""
        'Poll the array of servers
        PollServers(WshNetwork.ComputerName)
        'Email if there is a message
        if strMessage <> "" then
            EmailAlert(strMessage)
        end if
        'The script will loop for now just for testing. Uncomment the line that follows the loop logic to cancel the loop.
        WScript.Sleep(WaitTimeInMinutes*60000)
            'i = i + 1
    Loop
    Sub PollServers(arrServers)
        on error resume next
        for each Server in arrServers
            set objSvc = GetObject("winmgmts:{impersonationLevel=impersonate}//" & Server & "/root/cimv2")
            set objRet = objSvc.InstancesOf("win32_LogicalDisk")
            for each item in objRet
                if item.DriveType = 7 then
                    end if
                    if item.FreeSpace/item.size <= AlertHigh then
                        strMessage = strMessage & UCase(strPC) & "  Drive '" & item.caption & "' is low on disk space!  There are " & FormatNumber((item.FreeSpace/1024000),0)
    & " MB free" & vbCRLF
                    end if
            next
        next
        set objSvc = Nothing
        set objRet = Nothing
    End Sub
    Sub EmailAlert(Message)
        on error resume next
        Set objMessage = CreateObject("CDO.Message")
        with objMessage
            .From = emailFrom
            .To = Recipient
            .Subject = "Server " & WshNetwork.ComputerName & " is low on Disk Space" 
            .TextBody = Message
            .Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
            .Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = ExchangeServer
            .Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
            .Configuration.Fields.Update
            .Send
        end with
        Set objMessage = Nothing
    End Sub

    I've managed to get the script fully working as required.
    ================================================================
    Const emailFrom = "your_email_here"      'From email address
    Const ExchangeServer = "exchange_server_name"      'Enter your Exchange server name here (FQDN)
    Const WaitTimeInMinutes = 240                   'Wait time between loops. This is will be in minutes
    Dim WshShell, objArgs, strIP, objWMIService, LogicalVolumes, strDriveLetter
    Dim objItem, strDriveName, IntCapacity, IntFree, DiskFreePct
    Dim strIgnoreFlag
    Dim strMessage, IntStatistic
    Dim DrivePercentage
    Dim DriveSpaceRem
    Dim mbFreeSpace
    Dim intFreeSpace
    Dim UsedPercentage
    on error resume next
      strDriveLetter           = WScript.Arguments(0)   'This is the drive letter which you want to monitor on the localhost
      DiskFreePct              = WScript.Arguments(1)   'This is the threshold percentage of free space
      ThresholdGB              = WScript.Arguments(2)
      Recipient                = WScript.Arguments(3)   'This is where the e-mail needs to be sent to             
    If Err.Number <> 0 Then
      msgbox "You did not supply the arguments after calling the VBS file:" & vbcrlf & "<Drive Letter, eg:  C:>"& vbcrlf & "<Warning Threshold in Percentage> "& vbcrlf &"<Warning Threshold in GB Remaining> "&
    vbcrlf &"<Recipient E-Mail Address>"
      WScript.Quit
    End If 
    strComputer = "."
    'WScript.Echo strComputer
    Set WshNetwork = WScript.CreateObject("WScript.Network")
    'WScript.Echo WshNetwork.ComputerName
    arrServerList = array(strComputer)    'This is where your local host will be used as the query
    Do until i = 1
        'Clear the message variable
        strMessage = ""
        'Poll the array of servers
        PollServers strComputer,strDriveLetter
        'Email if there is a message
        if strMessage <> "" then
            EmailAlert(strMessage)
        end if
        'The script will loop for now just for testing. Uncomment the line that follows the loop logic to cancel the loop.
        'WScript.Sleep(WaitTimeInMinutes*60000)
            i = i + 1
    Loop
    Sub PollServers(strComputer,strDriveLetter)
        Selectstring = "Select * from Win32_LogicalDisk Where DeviceID = '" & strDriveLetter & "'"
        on error resume next
        Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
        Set colItems = objWMIService.ExecQuery(Selectstring)
        For Each objItem in colItems
     if objItem.FreeSpace/objItem.Size * 100 <= DiskFreePct or mbFreeSpace <= ThresholdGB then
         DrivePercentage = FormatNumber(objItem.FreeSpace/objItem.Size *100,0)
         DriveSpaceRem   = FormatNumber((objItem.FreeSpace/1024000),0)
         intFreeSpace    = objItem.FreeSpace
         mbFreeSpace     = intFreeSpace / 1024 / 1024 / 1024
         mbFreeSpace     = round(mbFreeSpace,0)
         intTotalSpace   = objDisk.Size
         UsedPercentage  = 100 - DrivePercentage
              strMessage      = strMessage & " "
            end if
        Next
    End Sub
    Sub EmailAlert(Message)
        on error resume next
        Set objMessage = CreateObject("CDO.Message")
     with objMessage
            .From = emailFrom
            .To = Recipient
            .Subject = "" & WshNetwork.ComputerName & ": Alert " & Now & " -> " & UCase(strDriveLetter) & " fill level = " & UsedPercentage & "%, Space Remaining = " & mbFreeSpace & "
    GB"
            .TextBody = Message
            .Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
            .Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = ExchangeServer
            .Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
            .Configuration.Fields.Update
            .Send
        end with
        Set objMessage = Nothing
    End Sub
    'WScript.Echo "done"

Maybe you are looking for