开发者

wshshell how can we use variable value in .Run

开发者 https://www.devze.com 2023-02-16 12:38 出处:网络
i want to read file line by line and want to use each line as argument in below lines. Set objIniFile = objFSO.OpenTextFile( \"C:\\Users\\rahulsh\\Desktop\\inputfile.txt\",ForReading, False )

i want to read file line by line and want to use each line as argument in below lines.

Set objIniFile = objFSO.OpenTextFile( "C:\Users\rahulsh\Desktop\inputfile.txt",ForReading, False )

Do While objIniFile.AtEndOfStream = False
    strLine = Trim( objIniFile.ReadLine )

    WshShell.Run "cmd /k shutdo开发者_开发技巧wn -m \\ **-add ""strLine"""**           


if I understand correctly, this is just a string concatenation of the computer name of the /m option of the shutdown command

Set objIniFile = objFSO.OpenTextFile( "C:\Users\rahulsh\Desktop\inputfile.txt",ForReading, False )

Do While Not objIniFile.AtEndOfStream
    strLine = Trim( objIniFile.ReadLine )

    WshShell.Run "cmd /k shutdown -m \\" & strLine 
loop

assuming that strLine will only contain your computer name

0

精彩评论

暂无评论...
验证码 换一张
取 消