windows-scripting

How to capture the Return Value of a ScriptBlock invoked with Powershell's Invoke-Command

纵然是瞬间 提交于 2019-11-27 11:44:08
问题 My question is very similar to this one, except I'm trying to capture the return code of a ScriptBlock using Invoke-Command (so I can't use the -FilePath option). Here's my code: Invoke-Command -computername $server {\\fileserver\script.cmd $args} -ArgumentList $args exit $LASTEXITCODE The problem is that Invoke-Command doesn't capture the return code of script.cmd, so I have no way of knowing if it failed or not. I need to be able to know if script.cmd failed. I tried using a New-PSSession

VBScript getting results from Shell

二次信任 提交于 2019-11-27 06:12:53
问题 Set wshShell = WScript.CreateObject ("WSCript.shell") wshshell.run "runas ..." How do I get the results and display in a MsgBox 回答1: You will want to use the WshShell object's Exec method instead of Run. Then simply read the command line's output from the standard streams. Try this one: Const WshFinished = 1 Const WshFailed = 2 strCommand = "ping.exe 127.0.0.1" Set WshShell = CreateObject("WScript.Shell") Set WshShellExec = WshShell.Exec(strCommand) Select Case WshShellExec.Status Case

How can I create a javascript library in a separate file and “include” it in another?

喜夏-厌秋 提交于 2019-11-27 01:37:07
问题 First, a caveat. The main script is not run in a webpage . I will be running the .js file in Windows using Windows Script Host. The problem: I would like to create a javascript "library" containing a number of objects, each with a number of functions. I expect this library will get rather large with time and would like to keep it in a separate javascript file (let's call it Library.js ). I would like to access the objects from Library.js from another script (let's call this one User.js ). In

PSEXEC, access denied errors

狂风中的少年 提交于 2019-11-26 19:42:30
While I'm using PSEXEC.exe getting 'Access denied' error for remote systems. Any idea about how to solve this? james Hi i am placing here a summary from many sources online for various solutions to "access is denied" : most information can be found here (including requirements needed) - sysinternal help as someone mentioned add this reg key, and then restart the computer : reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\system /v LocalAccountTokenFilterPolicy /t REG_DWORD /d 1 /f Read this knowledge base article to learn what this does and why it is needed Disable firewall

How do I execute cmd commands through a batch file?

时光怂恿深爱的人放手 提交于 2019-11-26 19:04:43
问题 I want to write a batch file that will do following things in given order: Open cmd Run cmd command cd c:\Program files\IIS Express Run cmd command iisexpress /path:"C:\FormsAdmin.Site" /port:8088 /clr:v2.0 Open Internet Explorer 8 with URL= http://localhost:8088/default.aspx Note: The cmd window should not be closed after executing the commands. I tried start cmd.exe /k "cd\ & cd ProgramFiles\IIS Express" , but it is not solving my purpose. 回答1: So, make an actual batch file: open up notepad