none
Spousteni aplikace scriptem

    Dotaz

  • Mam GUI aplikaci ktera bezi v konzolove session w2k3. Po delsim behu se
    obcas chova nevyzpytatelne a je treba ji restartovat. Vysledoval jsem ze
    pred jejim zblbnutim vyrazne naroste objem spotrebovavane pameti a na
    tom jsem postavil periodickou kontrolu aplikace a jeji shozeni shell
    scriptem.
     
    Problem je ze ji pote potrebuju opet nastartovat do konzolove session
    pod specifickym uctem a to se mi nedari. Monitorovaci script spoustim co
    pet minut pomoci http://cronw.sourceforge.net ktery bezi pod admin
    uctem, ale session je zalogovana pod jinym uctem.
     
    Bez problemu to program shodi, ale uz nespusti. Zkousel jsem RunAs jenze
    tomu se neda zadat heslo. Dale jsem experimentoval u utilitou
    Mate nekdo nejaky napad? Uz se v tom placam dost dlouho a tak jsem se
    mozna dostal do slepe ulicky.
     
    diky L.
      
    17. dubna 2012 7:42

Odpovědi

  • Ahoj,

    proč používáš nějaký Cronw? Co obyčejné naplánované úlohy? Ty nefungují?

    Jinak si můžeš udělat naplánovanou úlohu a tu pak spouštět z toho skriptu. Tu naplánovanou úlohu nastavíš tak, aby se spouštěla pod určitým účtem a máš to.

    This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.

    Microsoft Student Partner 2010 / 2011 / 2012
    Microsoft Certified Professional | Connected Home Integrator | Consumer Sales Specialist
    Microsoft Certified IT Professional: Consumer Support Technician on Windows Vista
    Microsoft Certified IT Professional: Enterprise Support Technician on Windows Vista
    Microsoft Certified IT Professional: Server Administrator on Windows Server 2008
    Microsoft Certified Technology Specialist:
    Windows 7, Configuration | Microsoft Windows Vista, Configuration
    Pre-Installing Windows 7 for OEMs | Windows 7 and Office 2010, Deployment | Windows Vista and Server Operating Systems, Preinstallation
    Windows Server 2008 AD, Conf | Windows Server 2008 Network Infrastructure, Conf | Windows Server 2008 Apps Infrastructure, Conf
    Windows Server 2008 R2, Server Virtualization | Windows Server Virtualization, Configuration | Microsoft Lync Server 2010, Configuring
    Windows SBS 2011, Configuring | Windows EBS 2008, Configuration | Windows SBS 2008, Configuration
    Windows HPC Server 2008, Development | Windows Internals | MDOP, Configuration | SharePoint 2010, Configuration
    Microsoft SCOM, Configuration | Microsoft SCDPM 2007, Configuration | Microsoft SCVMM 2008, Configuration

    17. dubna 2012 7:46
  • jak rikaji panove, lepsi je to asi delat pres naplanovane ulohy, nicmene, kdysi jsem taky neco podobneho potreboval nasel jsem peknej skriptik, takze treba to pomuze

    neni to muj vytvor, ale funguje to jak ma ;)

    wscript.echo VBCRLF & "? HELP ?" & VBCRLF
    Usage
    end if
    
    if oArgs.Count <3 then
    wscript.echo VBCRLF & "! Usage Error !" & VBCRLF
    Usage
    end if
    
    sUser=oArgs(0)
    sPass=oArgs(1)&VBCRLF
    sCmd=oArgs(2)
    
    set WshShell = CreateObject("WScript.Shell")
    set WshEnv = WshShell.Environment("Process")
    WinPath = WshEnv("SystemRoot")&"\System32\runas.exe"
    set FSO = CreateObject("Scripting.FileSystemObject")
    
    if FSO.FileExists(winpath) then
    'wscript.echo winpath & " " & "verified"
    else
    wscript.echo "!! ERROR !!" & VBCRLF & "Can't find or verify " & winpath &"." & VBCRLF & "You must be running Windows 2000 for this script to work."
    set WshShell=Nothing
    set WshEnv=Nothing
    set oArgs=Nothing
    set FSO=Nothing
    wscript.quit
    end if
    
    rc=WshShell.Run("runas /user:" & sUser & " " & CHR(34) & sCmd & CHR(34), 2, FALSE)
    Wscript.Sleep 30 'need to give time for window to open.
    WshShell.AppActivate(WinPath) 'make sure we grab the right window to send password to
    WshShell.SendKeys sPass 'send the password to the waiting window.
    
    set WshShell=Nothing
    set oArgs=Nothing
    set WshEnv=Nothing
    set FSO=Nothing
    
    wscript.quit
    
    '************************
    '* Usage Subroutine *
    '************************
    Sub Usage()
    On Error Resume Next
    msg="Usage: cscript|wscript vbrunas.vbs Username Password Command" & VBCRLF & VBCRLF & "You should use the full path where necessary and put long file names or commands" & VBCRLF & "with parameters in quotes" & VBCRLF & VBCRLF &"For example:" & VBCRLF &" cscript vbrunas.vbs domain\user password path:\scripts\admin.vbs" & VBCRLF & VBCRLF &" cscript vbrunas.vbs domain\user password " & CHR(34) &"path:\program files\scripts\admin.vbs 1stParameter 2ndParameter" & CHR(34)& VBCRLF & VBCRLF & VBCLRF & "cscript vbrunas.vbs /?|-? will display this message."
    
    wscript.echo msg
    
    wscript.quit
    
    end sub
    'End of Script 

    
    
    17. dubna 2012 8:19

Všechny reakce

  • Ahoj,

    proč používáš nějaký Cronw? Co obyčejné naplánované úlohy? Ty nefungují?

    Jinak si můžeš udělat naplánovanou úlohu a tu pak spouštět z toho skriptu. Tu naplánovanou úlohu nastavíš tak, aby se spouštěla pod určitým účtem a máš to.

    This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.

    Microsoft Student Partner 2010 / 2011 / 2012
    Microsoft Certified Professional | Connected Home Integrator | Consumer Sales Specialist
    Microsoft Certified IT Professional: Consumer Support Technician on Windows Vista
    Microsoft Certified IT Professional: Enterprise Support Technician on Windows Vista
    Microsoft Certified IT Professional: Server Administrator on Windows Server 2008
    Microsoft Certified Technology Specialist:
    Windows 7, Configuration | Microsoft Windows Vista, Configuration
    Pre-Installing Windows 7 for OEMs | Windows 7 and Office 2010, Deployment | Windows Vista and Server Operating Systems, Preinstallation
    Windows Server 2008 AD, Conf | Windows Server 2008 Network Infrastructure, Conf | Windows Server 2008 Apps Infrastructure, Conf
    Windows Server 2008 R2, Server Virtualization | Windows Server Virtualization, Configuration | Microsoft Lync Server 2010, Configuring
    Windows SBS 2011, Configuring | Windows EBS 2008, Configuration | Windows SBS 2008, Configuration
    Windows HPC Server 2008, Development | Windows Internals | MDOP, Configuration | SharePoint 2010, Configuration
    Microsoft SCOM, Configuration | Microsoft SCDPM 2007, Configuration | Microsoft SCVMM 2008, Configuration

    17. dubna 2012 7:46
  • RunAs /savecred neni zrovna bezpecne ale je to presne zpusob JAK ZADAT HESLO. Jinak jak pise Jirka: ve Windows je Task Scheduler, ktery umi vse, co je potreba. Samozrejme muzes pouzivat alternativy 3. stran, pak ale nechod pro radu sem :)

    MP

    17. dubna 2012 7:49
    Moderátor
  • jak rikaji panove, lepsi je to asi delat pres naplanovane ulohy, nicmene, kdysi jsem taky neco podobneho potreboval nasel jsem peknej skriptik, takze treba to pomuze

    neni to muj vytvor, ale funguje to jak ma ;)

    wscript.echo VBCRLF & "? HELP ?" & VBCRLF
    Usage
    end if
    
    if oArgs.Count <3 then
    wscript.echo VBCRLF & "! Usage Error !" & VBCRLF
    Usage
    end if
    
    sUser=oArgs(0)
    sPass=oArgs(1)&VBCRLF
    sCmd=oArgs(2)
    
    set WshShell = CreateObject("WScript.Shell")
    set WshEnv = WshShell.Environment("Process")
    WinPath = WshEnv("SystemRoot")&"\System32\runas.exe"
    set FSO = CreateObject("Scripting.FileSystemObject")
    
    if FSO.FileExists(winpath) then
    'wscript.echo winpath & " " & "verified"
    else
    wscript.echo "!! ERROR !!" & VBCRLF & "Can't find or verify " & winpath &"." & VBCRLF & "You must be running Windows 2000 for this script to work."
    set WshShell=Nothing
    set WshEnv=Nothing
    set oArgs=Nothing
    set FSO=Nothing
    wscript.quit
    end if
    
    rc=WshShell.Run("runas /user:" & sUser & " " & CHR(34) & sCmd & CHR(34), 2, FALSE)
    Wscript.Sleep 30 'need to give time for window to open.
    WshShell.AppActivate(WinPath) 'make sure we grab the right window to send password to
    WshShell.SendKeys sPass 'send the password to the waiting window.
    
    set WshShell=Nothing
    set oArgs=Nothing
    set WshEnv=Nothing
    set FSO=Nothing
    
    wscript.quit
    
    '************************
    '* Usage Subroutine *
    '************************
    Sub Usage()
    On Error Resume Next
    msg="Usage: cscript|wscript vbrunas.vbs Username Password Command" & VBCRLF & VBCRLF & "You should use the full path where necessary and put long file names or commands" & VBCRLF & "with parameters in quotes" & VBCRLF & VBCRLF &"For example:" & VBCRLF &" cscript vbrunas.vbs domain\user password path:\scripts\admin.vbs" & VBCRLF & VBCRLF &" cscript vbrunas.vbs domain\user password " & CHR(34) &"path:\program files\scripts\admin.vbs 1stParameter 2ndParameter" & CHR(34)& VBCRLF & VBCRLF & VBCLRF & "cscript vbrunas.vbs /?|-? will display this message."
    
    wscript.echo msg
    
    wscript.quit
    
    end sub
    'End of Script 

    
    
    17. dubna 2012 8:19