开发者

wshshell how can we use variable value in .Run

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜