locked
Startup a BAT file Run As Administrator RRS feed

  • Question

  • Hello,

    I want to execute a bat file at startup, not have it show up as a window (I don't want the user to mistakenly stop the job running in the window), and I don't want the user to receive the "Windows needs your permission to continue" prompt from Vista.

    In XP this worked fine using two files that I created: 1) "C:\Windows\System32\PrintServer.vbs" and 2) "C:\PrintServer.bat"

    When the vbs is placed in the XP "C:\Documents and Settings\Startup" folder, things work perfectly.  The jobs are launched, and the user doesn't see a window.

    I'd like to replicate this functionality in Vista.  The VBS hides the window.  The BAT actually calls the application I need to run.

    Here are the two files.  The VBS calls the BAT.

    --PrintServer.VBS--

    Const HIDDEN_WINDOW = 12

    strComputer = "."

    Set objWMIService = GetObject("winmgmts:" _

        & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

    Set objStartup = objWMIService.Get("Win32_ProcessStartup")

    Set objConfig = objStartup.SpawnInstance_

    objConfig.ShowWindow = HIDDEN_WINDOW

    Set objProcess = GetObject("winmgmts:root\cimv2:Win32_Process")

    errReturn = objProcess.Create("C:\printserver.bat", null, objConfig, intProcessID)

     

     

    --PrintServer.BAT--

    Shell(C:\OracleXE\Oracle Containers for J2EE\bin, AppWinStyle.Hide, True, -1)

    cd C:\OracleXE\Oracle Containers for J2EE\bin

    oc4j –start

    Thanks for your help.

    Saturday, December 4, 2010 12:44 AM

Answers

  • Hi,

    Thanks for posting!

    You can refer to http://www.tutorial5.com/content/view/157/47/ for detailed steps.

    Please Note: Since the website is not hosted by Microsoft, the link may change without notice. Microsoft does not guarantee the accuracy of this information.

    Regards,


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ”
    Wednesday, December 8, 2010 10:45 AM
    Moderator

All replies