Information on runas command

2.3k Views Asked by At

This question may be duplicate but since I didn't find any answer I am posting it here

  1. My username has space in between; so how should I write it while using runas; should I use double quote or single quote or \

    e.g. runas /noprofile /user:mymachine-pc\john smith cmd

in above e.g john & smith have space in-between

  1. My cmd contains path,double quote etc ; so how should I pass whole thing as cmd to runas ; for e.g.

    cmd=icacls "C:\Users\Public\Public Desktop" /GRANT John smith:F /T

I want to run above command as

"runas /noprofile /user:mymachine-pc\john smith icacls "C:\Users\Public\Public Desktop" /GRANT John smith:F /T

Now above command has lot of problem ; I am really confused; john smith has admin right also; and I am trying to run this from batch file

1

There are 1 best solutions below

9
On

Try escaping inner quotes.

runas /noprofile /user:"mymachine-pc\john smith" "icacls \"C:\Users\Public\Public Desktop\" /GRANT \"John smith\":F /T"