batch-file

store the output of powershell command in a variable

霸气de小男生 提交于 2021-01-20 05:01:44
问题 The following commnad: $sun=PowerShell [DateTime]::Today.AddDays(-8).ToString('dd-MMM-yyyy') echo %sun % the output of the echo is PowerShell [DateTime]::Today.AddDays(-8).ToString('dd-MMM-yyyy') how do i get it to output something like 22-Sep-2013 回答1: You need to use for /f : for /f "usebackq" %%x in (`powershell "(Get-Date).AddDays(-8).ToString('dd-MMM-yyyy')"`) do set sun=%%x 来源: https://stackoverflow.com/questions/19089736/store-the-output-of-powershell-command-in-a-variable

A way of typing multiple commands in cmd.txt file using PuTTY batch against Cisco

风流意气都作罢 提交于 2021-01-15 10:11:52
问题 I am running batch file in Windows environment using PuTTY.exe command below: for /L %%n in (1,1,5) do ( SET z=Site%%n% start c:\Users\emrpocadmin\desktop\putty.exe -ssh IPAddress -l User -pw Password -m c:\Users\emrpocadmin\desktop\cmds.txt -load Site%%n% ) This batch should load variable profiles ( n from 1 to 5) predefined in PuTTY and run on them one-by-one the commands defined in cmds.txt file; then save the output to certain folder.. However, in cmds.txt file i could only enter one

A way of typing multiple commands in cmd.txt file using PuTTY batch against Cisco

妖精的绣舞 提交于 2021-01-15 10:10:59
问题 I am running batch file in Windows environment using PuTTY.exe command below: for /L %%n in (1,1,5) do ( SET z=Site%%n% start c:\Users\emrpocadmin\desktop\putty.exe -ssh IPAddress -l User -pw Password -m c:\Users\emrpocadmin\desktop\cmds.txt -load Site%%n% ) This batch should load variable profiles ( n from 1 to 5) predefined in PuTTY and run on them one-by-one the commands defined in cmds.txt file; then save the output to certain folder.. However, in cmds.txt file i could only enter one

A way of typing multiple commands in cmd.txt file using PuTTY batch against Cisco

╄→гoц情女王★ 提交于 2021-01-15 10:05:38
问题 I am running batch file in Windows environment using PuTTY.exe command below: for /L %%n in (1,1,5) do ( SET z=Site%%n% start c:\Users\emrpocadmin\desktop\putty.exe -ssh IPAddress -l User -pw Password -m c:\Users\emrpocadmin\desktop\cmds.txt -load Site%%n% ) This batch should load variable profiles ( n from 1 to 5) predefined in PuTTY and run on them one-by-one the commands defined in cmds.txt file; then save the output to certain folder.. However, in cmds.txt file i could only enter one

How can I send a batch variable to a powershell command

牧云@^-^@ 提交于 2021-01-07 03:02:59
问题 I don't know how to fix it... I'm trying to move random files from one folder to another but I want so I can determine the folders inside the batch file but when I run the batch file it doesn't work and if I change the %var% manual from editing the batch file it's working. I'm sorry if this is a simple question but I'm kinda new to batch and still learning. @echo off set /p var1=Enter first dir: set /p var2=Enter second dir: ::Var (Folder Directory) echo %var1% echo %var2% powershell -Command

Windows batch/powershell file to regex find and replace only in files having specific text [closed]

那年仲夏 提交于 2021-01-07 02:31:45
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed yesterday . Improve this question How could I make a Windows batch file to find and rename with regex in files, that have specific text in them? This is the needed scenario: If file path is C:\Folder\ and file name is something_*.xml (wildcards allowed) and the file has specific text

Error running with input a parameter in bat script

筅森魡賤 提交于 2021-01-07 01:00:08
问题 I am trying to convert a number of .doc files into .docx files and I found a solution: for %F in (*.doc) do "C:\Program Files\Microsoft Office\Office12\wordconv.exe" -oice -nme "%F" "%Fx" For the detailed info see: Automation: how to automate transforming .doc to .docx? Now I want to use the absolute path of wordconv.exe as an input parameter. Then my approach is like this: The contents of doc2docx.bat : for %F in (*.doc) do (%1 -oice -nme "%F" "%Fx") Run doc2docx.bat in console with:

need to change file created date based on csv

谁都会走 提交于 2021-01-06 05:33:39
问题 Good evening everyone. I have been able to change date created attribute of a file using the following command $(Get-Item test1.html).CreationTime=$(Get-Date "11/24/2010 06:00 am") My problem is that I have 10000 files that need to have this done based on a csv file. CSV has two columns file name or and file created date. CSV and files are in same folder. How can I rename the files based on the corresponding date in column 2 eg. 1.pdf 2010/12/12 2.pdf 2011/13/01 3.pdf 1989/12/12 etc Thanks in

need to change file created date based on csv

烂漫一生 提交于 2021-01-06 05:31:43
问题 Good evening everyone. I have been able to change date created attribute of a file using the following command $(Get-Item test1.html).CreationTime=$(Get-Date "11/24/2010 06:00 am") My problem is that I have 10000 files that need to have this done based on a csv file. CSV has two columns file name or and file created date. CSV and files are in same folder. How can I rename the files based on the corresponding date in column 2 eg. 1.pdf 2010/12/12 2.pdf 2011/13/01 3.pdf 1989/12/12 etc Thanks in

unable to run prometheus on windows 10 for Cassandra [duplicate]

时光总嘲笑我的痴心妄想 提交于 2021-01-05 11:25:13
问题 This question already has an answer here : convert a .sh command into .bat equivalent (1 answer) Closed 17 days ago . I am following this tutorial to run Prometheus on Windows10 . The tutorial is for linux . I suppose the only command I need to change is for powershell . However, when I try to access the metrics, the application doesn't connect. https://www.robustperception.io/monitoring-cassandra-with-prometheus Instead of echo 'JVM_OPTS="$JVM_OPTS -javaagent:'$PWD/jmx_prometheus_javaagent-0