none
Need help to modify vb script used in XP for Windows 7 RRS feed

  • Question

  • Can somebody help me in modifying scripts that were used for Windows XP, to run on Windows 7.

    My friend advised me to change it to .ps1, but still some flaws..

    Cscript \\nologo ????  is used for what purpose ?

     

    Monday, July 25, 2011 8:25 AM

Answers

  • cscript //nologo

    ...will prevent the banner at execution time.  The banner looks something like:

    Microsoft (R) Windows Script Host Version 5.8
    Copyright (C) Microsoft Corporation. All rights reserved.

     

    But DO move to Powershell.  It's easier to write, and very Powerful!


    If you found this post helpful, please give it a "Helpful" vote. If it answered your question, remember to mark it as an "Answer".
    • Marked as answer by IamMred Monday, August 1, 2011 4:04 AM
    Monday, July 25, 2011 10:06 AM
  • VB Scripts written for Windows XP will run happily under Windows 7. However, Windows 7 has some restrictions that apply to any script or action, e.g. attempting to create or modify a file in a protected area. If you have a problem then you must post these three items:

    a) The script that causes you a problem.
    b) The script line that fails.
    c) The error message you see.

    To see the error messages, invoke your script like so:

    cscript //nologo  "c:\scripts\MyScript.exe"

    The "//nologo" switch has no effect on the script itself. Its sole purpose is to suppress the VB Script copyright message.

    Note also that all VB Script files must have a .vbs extension. Files with a .ps1 extension are Powershell scripts, which is a completely different scripting language.

    • Marked as answer by IamMred Monday, August 1, 2011 4:04 AM
    Monday, July 25, 2011 11:03 AM
  • Almost all VBScripts written to work in Windows XP will also work for Windows 7, so there's not much to modify (unless you have specific examples of scripts not working).

    Having said that, PowerShell is the future! It takes a bit more than to just change the file extension to .ps1 though (this may be why your scripts aren't working!).

    The VBScript-to-Windows PowerShell Conversion Guide
    http://technet.microsoft.com/en-us/library/ee221101.aspx

     

    C:\>cscript /?
    Microsoft (R) Windows Script Host Version 5.7
    Copyright (C) Microsoft Corporation. All rights reserved.

    Usage: CScript scriptname.extension [option...] [arguments...]

    Options:
     //B         Batch mode: Suppresses script errors and prompts from displaying
     //D         Enable Active Debugging
     //E:engine  Use engine for executing script
     //H:CScript Changes the default script host to CScript.exe
     //H:WScript Changes the default script host to WScript.exe (default)
     //I         Interactive mode (default, opposite of //B)
     //Job:xxxx  Execute a WSF job
     //Logo      Display logo (default)
     //Nologo    Prevent logo display: No banner will be shown at execution time
     //S         Save current command line options for this user
     //T:nn      Time out in seconds:  Maximum time a script is permitted to run
     //X         Execute script in debugger
     //U         Use Unicode for redirected I/O from the console

    C:\>


    Andreas Hultgren
    MCTS, MCITP
    http://ahultgren.blogspot.com/
    • Marked as answer by IamMred Monday, August 1, 2011 4:04 AM
    Monday, July 25, 2011 11:04 AM
  • I have never found any VBScript program that works on XP but not Windows 7, except scripts that use IE or expect something to be installed that is not (like a certain version of Excel).

    If you are having issues, the problem might be permissions. Even though you are logged on with an Administrator account, you only have normal user permissions when you run a script on Windows 7 (and Vista and Windows Server 2008). If the script requires administrator privileges, you must run it using the "Run as administrator" feature. I keep a shortcut to cmd.exe on my desktop. When I need to run a script with admin privileges, I right click the shortcut and select "Run as administrator". Then all scripts I run in the command prompt will have Administrator privileges. I run all scripts at a command prompt using the cscript host program. For example:

    cscript //nologo Example.vbs

    If you run a *.vbs from Windows Explorer, there is no "Run as administrator" option, like there is for *.exe files (unless you modify the right click menu).

     


    Richard Mueller - MVP Directory Services
    • Marked as answer by IamMred Monday, August 1, 2011 4:04 AM
    Monday, July 25, 2011 11:36 AM
    Moderator

All replies

  • cscript //nologo

    ...will prevent the banner at execution time.  The banner looks something like:

    Microsoft (R) Windows Script Host Version 5.8
    Copyright (C) Microsoft Corporation. All rights reserved.

     

    But DO move to Powershell.  It's easier to write, and very Powerful!


    If you found this post helpful, please give it a "Helpful" vote. If it answered your question, remember to mark it as an "Answer".
    • Marked as answer by IamMred Monday, August 1, 2011 4:04 AM
    Monday, July 25, 2011 10:06 AM
  • VB Scripts written for Windows XP will run happily under Windows 7. However, Windows 7 has some restrictions that apply to any script or action, e.g. attempting to create or modify a file in a protected area. If you have a problem then you must post these three items:

    a) The script that causes you a problem.
    b) The script line that fails.
    c) The error message you see.

    To see the error messages, invoke your script like so:

    cscript //nologo  "c:\scripts\MyScript.exe"

    The "//nologo" switch has no effect on the script itself. Its sole purpose is to suppress the VB Script copyright message.

    Note also that all VB Script files must have a .vbs extension. Files with a .ps1 extension are Powershell scripts, which is a completely different scripting language.

    • Marked as answer by IamMred Monday, August 1, 2011 4:04 AM
    Monday, July 25, 2011 11:03 AM
  • Almost all VBScripts written to work in Windows XP will also work for Windows 7, so there's not much to modify (unless you have specific examples of scripts not working).

    Having said that, PowerShell is the future! It takes a bit more than to just change the file extension to .ps1 though (this may be why your scripts aren't working!).

    The VBScript-to-Windows PowerShell Conversion Guide
    http://technet.microsoft.com/en-us/library/ee221101.aspx

     

    C:\>cscript /?
    Microsoft (R) Windows Script Host Version 5.7
    Copyright (C) Microsoft Corporation. All rights reserved.

    Usage: CScript scriptname.extension [option...] [arguments...]

    Options:
     //B         Batch mode: Suppresses script errors and prompts from displaying
     //D         Enable Active Debugging
     //E:engine  Use engine for executing script
     //H:CScript Changes the default script host to CScript.exe
     //H:WScript Changes the default script host to WScript.exe (default)
     //I         Interactive mode (default, opposite of //B)
     //Job:xxxx  Execute a WSF job
     //Logo      Display logo (default)
     //Nologo    Prevent logo display: No banner will be shown at execution time
     //S         Save current command line options for this user
     //T:nn      Time out in seconds:  Maximum time a script is permitted to run
     //X         Execute script in debugger
     //U         Use Unicode for redirected I/O from the console

    C:\>


    Andreas Hultgren
    MCTS, MCITP
    http://ahultgren.blogspot.com/
    • Marked as answer by IamMred Monday, August 1, 2011 4:04 AM
    Monday, July 25, 2011 11:04 AM
  • I have never found any VBScript program that works on XP but not Windows 7, except scripts that use IE or expect something to be installed that is not (like a certain version of Excel).

    If you are having issues, the problem might be permissions. Even though you are logged on with an Administrator account, you only have normal user permissions when you run a script on Windows 7 (and Vista and Windows Server 2008). If the script requires administrator privileges, you must run it using the "Run as administrator" feature. I keep a shortcut to cmd.exe on my desktop. When I need to run a script with admin privileges, I right click the shortcut and select "Run as administrator". Then all scripts I run in the command prompt will have Administrator privileges. I run all scripts at a command prompt using the cscript host program. For example:

    cscript //nologo Example.vbs

    If you run a *.vbs from Windows Explorer, there is no "Run as administrator" option, like there is for *.exe files (unless you modify the right click menu).

     


    Richard Mueller - MVP Directory Services
    • Marked as answer by IamMred Monday, August 1, 2011 4:04 AM
    Monday, July 25, 2011 11:36 AM
    Moderator
  • I am unable to cycle to another screen using a VBScript that worked fine in XP. Windows 7 seems to just stop the ability for the script to allow sendkeys ("%{tab}") to work. Any suggestion?
    Friday, December 20, 2013 6:41 PM
  • Any suggestion?

    Yes. Start your own thread, this one is old and already marked as answered.

    I can tell you that sendkeys works on Win7, but it's just as unreliable as it was on XP.


    Don't retire TechNet! - (Don't give up yet - 12,420+ strong and growing)

    Friday, December 20, 2013 6:47 PM