Rahul
Rahul

Reputation: 11

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 shutdown -m \\ **-add ""strLine"""**           

Upvotes: 0

Views: 1956

Answers (1)

user69820
user69820

Reputation:

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

Upvotes: 1

Related Questions