小编rsc*_*rin的帖子

批量从变量中提取路径和文件名

如何从变量中提取路径和文件名?

Setlocal EnableDelayedExpansion
set file=C:\Users\l72rugschiri\Desktop\fs.cfg
Run Code Online (Sandbox Code Playgroud)

我想在不使用任何功能或任何GOTO的情况下这样做.可能吗?

path batch-file

73
推荐指数
3
解决办法
19万
查看次数

未定义的'pthread_create'引用 - 链接器命令选项顺序(目标文件之前/之后的库?)

当我尝试编译时,我收到一个特定的错误.但是,这是不可能的,因为我使用正确的旗帜.在server.c那里有图书馆pthread.h.那么,我该如何解决链接问题呢?我正在使用Linux(Ubuntu).

make
gcc -c -Wall -Wunused -ansi -pedantic -ggdb  -o Server1.o Server.c
gcc -c -Wall -Wunused -ansi -pedantic -ggdb  Util.c
gcc -o Server1.exe -Wall -Wunused -ansi -pedantic -ggdb -lpthread -lm Server1.o Util.o
Server1.o: In function `main':
/home/ruggero/ruggero_fine/Server.c:1002: undefined reference to `pthread_create'
collect2: ld returned 1 exit status
make: *** [Server1.exe] Errore 1
Run Code Online (Sandbox Code Playgroud)

c ubuntu linker pthreads

13
推荐指数
1
解决办法
4万
查看次数

Powershell如何获得2个月前的最后一天

我每个月的第4天和第14天安排一个脚本.

当脚本在4号开始时,我需要获取上个月的最后一天(简单,$ a.AddDays(-5))

当脚本在14日开始时,我需要获得2个月前的最后一天.

例如:

 14 april.

 I want to get:28 february 2013
Run Code Online (Sandbox Code Playgroud)

这怎么可能?我也希望以格式yyyymmdd获取日期

UDPDATE:

您的解决方案是否可能无法适应当年的变化?

如果我在1月,$(获取日期).month -1结果0.所以我这样做:

 $datenow = Get-date
 if $datenow.day -eq 14
 $datenow.AddDays(-14)
Run Code Online (Sandbox Code Playgroud)

然后我计算

 $LastDayInMonth = [System.DateTime]::DaysInMonth($(Get-date).Year, $(Get-date.Month))
 $datenow.AddDays(-$LastDayInMonth)
 $datestring = $datenow.ToString("yyyyMMdd")
Run Code Online (Sandbox Code Playgroud)

powershell date getdate

5
推荐指数
1
解决办法
8152
查看次数

Powershell如何在变量中添加数字

如何将数字添加到变量中包含的另一个数字?

$t0 = Get-date -UFormat "%H%M"
$t1 = $t0 + 10
Run Code Online (Sandbox Code Playgroud)

所以,如果$ t0是1030,我会将$ t1的值设为1040.

powershell

4
推荐指数
1
解决办法
2万
查看次数

Powershell如何使用仅知道一部分文件名的测试路径

我可以使用经典的Test-Path来检查在特定文件夹中是否存在名称中带有特定单词的文件?

例如,我想检查是否存在以单词“ LAB”开头的文件。这个词后面有我无法计算的日期戳。

powershell powershell-2.0

4
推荐指数
1
解决办法
5613
查看次数

$ LASTEXITCODE命令后未定义

我疯了,有人可以解释为什么$ lastexitcode的值是未定义的吗?

看看我的简单尝试:如果我启动命令目录,我得到正确的输出,所以$ LASTEXITCODE必须为0.

不幸的是,如果我尝试:

$LASTEXITCODE
Run Code Online (Sandbox Code Playgroud)

我没有任何回报价值.如果我在像"diiiiir"之类的命令或类似的不存在的命令之前给出的话,情况也是如此.

powershell powershell-2.0

4
推荐指数
1
解决办法
3379
查看次数

Invoke-Expression和Invoke-Expression -Command之间的差异

有人可以解释之间的差异Invoke-Expression $testInvoke-Expression -Command $test

变量测试是:

 $test = "notepad.exe myfile.txt"
Run Code Online (Sandbox Code Playgroud)

powershell powershell-2.0

4
推荐指数
2
解决办法
8328
查看次数

BITS使用多域传输文件

如何在不同域的服务器之间传输文件?

i.e
PS C:\Users\Desktop> Import-Module bitstransfer
PS C:\Users\Desktop> $c=get-credential
PS C:\Users\Desktop> start-bitstransfer -Credential $c -source \\server\c$\test.txt -destination .
Run Code Online (Sandbox Code Playgroud)

输出是:

Start-BitsTransfer : Cannot find path '\\server\c$\test.txt' because it does not exist.
Run Code Online (Sandbox Code Playgroud)

我有权探索该服务器,但我无法使用BitsTransfer.

它只有在我将\ server\c $作为共享挂载时才有效(即使用"net use"命令),但我想逃避它.

谢谢

powershell powershell-2.0 microsoft-bits

4
推荐指数
1
解决办法
6574
查看次数

了解如何使用记事本(MS)进行反击

如果我用powershell做的话

    [string]$text = "this `nis a `ntest"
    $text > c:\test.txt
Run Code Online (Sandbox Code Playgroud)

用notepad ++这就是结果:

    this
    is a
    test
Run Code Online (Sandbox Code Playgroud)

但如果我用Windows的记事本打开它它不起作用:

    this is a test
Run Code Online (Sandbox Code Playgroud)

为什么?我该怎么解决?

powershell notepad backticks

3
推荐指数
1
解决办法
239
查看次数

Powershell将文件作为邮件附件发送

我需要检查文件是否存在于路径中.

如果是,我需要将其作为邮件附件发送.

我的代码现在:

$file='STREAM_preg.txt'
$pathfile ='c:\Users\root\Desktop'
$dest ='C:\Users\root\Desktop\test'

cd $pathfile
if(Test-Path $file){
        $datestamp = get-date -uformat "%Y%m%d%H%M"
    Copy-Item $file $dest\$datestamp"_"$file
    $new_file = echo $datestamp"_"$file
    echo $new_file
      # Send-MailMessage -SmtpServer xxxxxxxxxx -To pluto@pippo.com -From preg_new_stream@pippo.com -Subject "test mail" -Body "file name is: $new_file"
}else{
        echo false
}
Run Code Online (Sandbox Code Playgroud)

powershell sendmail powershell-2.0

2
推荐指数
1
解决办法
1万
查看次数