Advertisement
jcunews

SmartRun.vbs

Apr 5th, 2019 (edited)
533
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 0.93 KB | None | 0 0
  1. prog = ""
  2. args = ""
  3. set xe = new regexp
  4. xe.pattern = "\s|[&<>|]"
  5. for i = 0 to wscript.arguments.count - 1
  6.   if prog = "" then
  7.     prog = wscript.arguments(i)
  8.   else
  9.     s = wscript.arguments(i)
  10.     if xe.test(s) then s = """" & s & """"
  11.     if args <> "" then
  12.       args = args & " " & s
  13.     else
  14.       args = s
  15.     end if
  16.   end if
  17. next
  18. if prog = "" then wscript.quit
  19. set ws = createobject("wscript.shell")
  20. set fs = createobject("scripting.filesystemobject")
  21. set f = fs.opentextfile(prog, 1, false, 0)
  22. if f.read(2) = "MZ" then
  23.   f.skip &H3a
  24.   f.skip (asc(f.read(1)) or (asc(f.read(1)) * 256) or (asc(f.read(1)) * 65536) or (asc(f.read(1)) * 16777216)) - &H40
  25.   if f.read(2) = "PE" then
  26.     f.skip &H5a
  27.     if (asc(f.read(1)) or (asc(f.read(1)) * 256)) = 3 then ws.run "cmd /c (" & prog & " " & args & ") & set/p a=Press any key to close this window...<nul & pause>nul", 1
  28.   end if
  29. end if
  30. f.close
  31. ws.run prog & " " & args, 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement