Unable to Service Request

Unable to Service Request

For the latest headlines and to see what's new, visit the MSDN home page.

Check out the various MSDN Developer Centers where you can find the latest product information, technical resources, and community offerings.

Visit the MSDN Library for the latest technical articles, reference documentation, downloads, and more.
© 2013 Microsoft. All rights reserved.
Need simple cscript/wscript file to run program

Odpovědět Need simple cscript/wscript file to run program

  • 17. března 2012 1:58
     
     

    I'm in need of vbscript file.  I'm planning to run something like "wscript.exe Psexec.vbs" on a WHS 2003.

    I've come up with the following but my server doesn't like it

    Line1: Set Command = WScript.CreateObject("WScript.Shell")
    Line2: cmd = "c:\windows\system32\Psexec.exe \\192.168.0.xx -i -h -d -u  Administrator -p Password "c:\program files\Internet Explorer\iexplore.exe" "http://192.168.0.xx/mControl/Editor.aspx#/PageCameras""
    Line3: Command.Run (cmd) 

    The Psexec code in Line2 works fine at the command prompt, but I don't know how to get it into a vbscript file.

Všechny reakce

  • 17. března 2012 7:48
     
     Odpovědět Obsahuje kód

    Try using this sub:

    Sub Run(ByVal sFile, sArgs) ' Create a shell object Dim shell Set shell = CreateObject("WScript.Shell") ' Run the file shell.Run Chr(34) & sFile & Chr(34) & " " & sArgs, 1, false ' Cleanup Set shell = Nothing End Sub

    ' Run a file like this:
    Run "FILENAME", "ARGUMENTS"

    It should be able to launch the file. Hope it works for you!

    Sincerely yours,
    - bilde2910


    If a post is helpful to you or solves a problem, remember to mark it as answer, propose it as answer or vote up.
    Check out my development so far!



    • Upravený bilde2910 17. března 2012 7:51
    • Upravený bilde2910 17. března 2012 7:51
    • Označen jako odpověď satwar1 17. března 2012 19:57
    • Zrušeno označení jako odpověď satwar1 17. března 2012 23:06
    • Navržen jako odpověď bilde2910 18. března 2012 6:32
    • Označen jako odpověď satwar1 18. března 2012 11:40
    •  
  • 17. března 2012 8:48
     
     

    check this blog

    http://customerfx.com/pages/crmdeveloper/2004/02/10/how-to-execute-a-file-program-in-vbscript.aspx

  • 17. března 2012 12:19
     
     

    Thanks Bilde2910, but a little over my head.

    I'm trying to execute the script file Psexec.vbs like this > cscript.exe Psexec.vbs

    Is the code you are showing me my Psexec.vbs file ?

    where "FILENAME" is "c:\windows\system32\Psexec.exe"

    where "ARGUMENTS" is " \\192.168.0.xx -i -h -d -u  Administrator -p Password "c:\program files\Internet Explorer\iexplore.exe" "http://192.168.0.xx/mControl/Editor.aspx#/PageCameras""

  • 17. března 2012 19:58
     
     
    Bingo, got it.  A nightmare with ".
  • 17. března 2012 21:21
     
     
    Bingo, got it.  A nightmare with ".

    Yup. Those quotation marks are annoying...
    I had hoped you'd get it, and you apparently did :)

    Sincerely yours,
    - bilde2910


    If a post is helpful to you or solves a problem, remember to mark it as answer, propose it as answer or vote up.
    Check out my development so far!

  • 17. března 2012 22:46
     
     

    Just one more request.  I need to run my program at User = Administrator, Password level of credentials.  Are there a few lines I can add to your script to make the program run at the desired user/pwd level ?

    Your script works fine in the command prompt window, but when I automate the call from a proprietary macro environment, I need to clarify the level of credentials to run at.



    • Upravený satwar1 17. března 2012 22:48
    • Upravený satwar1 18. března 2012 2:18
    •  
  • 17. března 2012 23:35
     
     

    ...system32\Psexec.exe \\192.168.0.xx -i -h -d ...

    I would have figured it would read more like:

    ...system32\Psexec.exe \\192.168.0.xxx -i -h -d...

    Hey, that lit up my screen. 

  • 18. března 2012 6:20
     
     Odpovědět Obsahuje kód
    1. You should post a new question if you need further help than first described, to make it easier for random visitors to find the correct answer.
    2. I am going to help you out, though, but perhaps a little googling first. Here is a post on another forum you may read.
    3. (EDIT:) Found some code on another forum, so you don't have to search further on this topic (code source).

    Sub Run(ByVal sFile, sArgs)
        
        ' Create a shell object
        Set objSh = CreateObject("Shell.Application")
        
        ' Run the shell object as administrator
        objSh.ShellExecute sFile, sArgs , "", "runas", 1
        
    End Sub

    Good luck!


    If a post is helpful to you or solves a problem, remember to mark it as answer, propose it as answer or vote up.
    Check out my development so far!





    • Upravený bilde2910 18. března 2012 6:30 Found more code and examples
    • Upravený bilde2910 18. března 2012 6:31 Typo
    • Upravený bilde2910 18. března 2012 6:31
    • Upravený bilde2910 18. března 2012 6:34
    • Upravený bilde2910 18. března 2012 6:34
    • Označen jako odpověď satwar1 18. března 2012 11:40
    •  
  • 18. března 2012 11:40
     
     

    Thank you.  I was afraid that the only tool available was runas.  Unfortunately it requires interacting with a dialog box to provide the Administrator Password, which is not possible when the script is being automatically called by a macro.

    I did google a lot before asking.  Seems like there is third party tool called Tqcrunas which does the job I require.

Unable to Service Request

Unable to Service Request

For the latest headlines and to see what's new, visit the MSDN home page.

Check out the various MSDN Developer Centers where you can find the latest product information, technical resources, and community offerings.

Visit the MSDN Library for the latest technical articles, reference documentation, downloads, and more.
© 2013 Microsoft. All rights reserved.