windows-scripting

Windows Equivalent of Unix Shell Script

岁酱吖の 提交于 2019-12-08 04:36:27
问题 To begin, please excuse my lack of knowledge on windows batch scripting (even the basic). I would like to ask for help on the equivalent of a working Unix script. This is the working script that I have. #!/bin/bash list=`cat view_tags` for i in $list; do cleartool lsview -l -prop -full $i | grep "Last accessed" >& /dev/null if [ $? -eq 0 ]; then echo -n $i echo " " `cleartool lsview -reg ccase_win -l -prop -full $i | grep "Last accessed" | awk '{print $3}'` else echo $i cannot be found fi

Windows Equivalent of Unix Shell Script

寵の児 提交于 2019-12-06 15:38:12
To begin, please excuse my lack of knowledge on windows batch scripting (even the basic). I would like to ask for help on the equivalent of a working Unix script. This is the working script that I have. #!/bin/bash list=`cat view_tags` for i in $list; do cleartool lsview -l -prop -full $i | grep "Last accessed" >& /dev/null if [ $? -eq 0 ]; then echo -n $i echo " " `cleartool lsview -reg ccase_win -l -prop -full $i | grep "Last accessed" | awk '{print $3}'` else echo $i cannot be found fi done The "view tags" file contain: pompei.s1272.hwdig_b12.default dincsori.arisumf.s2637b_dig.default

How to suppress output and check whether or not a command is successful?

五迷三道 提交于 2019-12-06 13:34:39
I am trying to write a powershell script that tests if a MySQL login is successful by using $? to check if an error occurs. I also want to suppress all output - successful or not successful - from the command. These are the things I've tried: mysql -u root --password=mypass -e "show databases" If ( $? ) { echo "Hooray!" } Else { echo "Boo!" } This works correctly but doesn't suppress any output. mysql -u root --password=mypass -e "show databases" > $null Works correctly still but does not suppress the errors if the password is wrong. mysql -u root --password=mypass -e "show databases" 2> $null

Batch - Set/Reset parameters calling subroutine with exclamation mark (!) and delayed expansion?

这一生的挚爱 提交于 2019-12-05 19:23:47
I have 2 Locals using delayed expansion. The 1. Local calls a subroutine which includes the 2. Local which defines 2 variables and set the values of those as the parameter values using FOR /F ... . This works fine as long as the string do not include one or more exclamation marks. The following working script shows the issue: @ECHO OFF SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION CALL :get_substrings testString substr ECHO Inside 1. local: ECHO !testString! ECHO !substr! EXIT /B 0 ENDLOCAL :get_substrings SETLOCAL ENABLEDELAYEDEXPANSION SET string="World^! wasserschutzpolizei^!" SET

Prompt dialog in WSH using JScript?

青春壹個敷衍的年華 提交于 2019-12-05 01:36:40
How to open a prompt dialog box in WSH usig JScript?? The only pop-up dialog I've found in the doc is the WshShell.Popup() method. But I need a way to request the user to enter a string, like the window.prompt() method in DOM. Thanks. I think the WScript object does not provide such a method however you can show an input box from vbscript running on WSH. So here is one possible solution which lets you call that VB function from within JS! Please note the file extension for the following code fragment ".wsf". <!-- Test.wsf --> <job id="InputBoxInJS"> <script language="VBScript"> Function

WScript.CreateObject crashes Windows Scripting Host when event handler prefix is specified for WinHTTPRequest

时间秒杀一切 提交于 2019-12-04 01:59:59
问题 According to the MSDN documentation WinHTTPRequest has four event handlers which should be accessible by specifying an event handler prefix. Unfortunately, doing so causes Windows Scripting Host to crash. The following code crashes Windows Scripting Host: Set oHTTP = WScript.CreateObject( "WinHttp.WinHttpRequest.5.1", "oHTTP_" ) This code works just fine: Set oHTTP = WScript.CreateObject( "WinHttp.WinHttpRequest.5.1" ) Any thoughts as to why? 回答1: It's not part of the specification in any way

Loading the TypeScript compiler into ClearScript, “WScript is undefined”, impossible task?

*爱你&永不变心* 提交于 2019-12-03 14:39:06
I tried using ClearScript to load the TypeScript compiler in order to compile some basic TypeScript code. Unfortunately, when executing the TypeScript compiler source I get this error: 'WScript' is undefined This is the LINQPad program I've used, place the ClearScript dll's and the TypeScript compiler file alongside the .linq program: void Main() { using (var js = new Microsoft.ClearScript.Windows.JScriptEngine(Microsoft.ClearScript.Windows.WindowsScriptEngineFlags.DisableSourceManagement)) { var typeScriptSource = File.ReadAllText(Path.Combine(Path.GetDirectoryName(Util.CurrentQueryPath),

Get size of the sub folders only using batch command

旧时模样 提交于 2019-12-02 10:22:05
问题 I am passing my base folder name ( C:\Users\IAM\Desktop\MHW\* ) in script and want to get the size of the underlying sub folders. The below code is not working. Need help to fix it. @echo off setLocal EnableDelayedExpansion FOR /D %%G in ("C:\Users\IAM\Desktop\MHW\*") DO ( set /a value=0 set /a sum=0 FOR /R "%%G" %%I IN (*) DO ( set /a value=%%~zI/1024 set /a sum=!sum!+!value! ) @echo %%G: !sum! K ) pause From my understanding, the value "%%G" is not getting passed to the second FOR loop. 回答1

Copy-Item for copy files from local to remove server using credentials

北战南征 提交于 2019-12-02 10:12:58
问题 I am trying to copy some files and folder from my local machine to a remote server: Copy-Item .\copy_test.txt -destination "\\serverip\c$\backups\" but I'm getting an error: Copy-Item : Logon failure: unknown user name or bad password. At line:1 char:10 + Copy-Item <<<< .\copy_test.txt -destination "\\serverip\c$\backups\" -verbose + CategoryInfo : NotSpecified: (:) [Copy-Item], IOException + FullyQualifiedErrorId : System.IO.IOException,Microsoft.PowerShell.Commands.CopyItemCommand I was

Batch Scripting Help - Replace Substring of a DelayedExpansion Var with another DelayedExpansion Var

纵饮孤独 提交于 2019-12-01 19:03:41
Basically I'm trying to do !var1:SomeText=!var2!! but this code doesn't work. What am I missing? dbenham The order of expansion is critical when doing a search and replace operation that uses a variable for the search and/or the replace. The inner variable must be expanded before the outer search and replace expansion takes place. Trying to used delayed expansion for both obviously can't work because the delayed expansion occurs at one point in time. The classic method for expansion of a variable within another variable uses delayed expansion for the outer, and normal for the inner: echo !var1