Use runas in VB script on a batch file

Joseph Boban 1 Reputation point
2021-04-21T05:46:56.347+00:00

Hello Team

Using a "vb script" and in that script at a particluar point need to run a "batch file" with a different account ,so am using runas in the vbscript that will pass the username and password for the batch file to execute.The issue is when i use runas in vbscript if ispecify the path to the batch file where it resides then it works.
I need to pass the location of this batch file as a variable for runas to execute, is it possible?
If i keep this batch file in system32 folder runas in vbscript executes the batch file just by mentioning the batch file name as runas by default opens to the location system32 folder.

These scripts all together including the vb and batch can be at location on the PC, so the idea is to get the current working directory and then pass that location of the batch file to a variable and then give it to runas command for execution.. is it possible?

I tried but was not effective..

Please suggest

Community Center Not monitored
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Daniel Zhang-MSFT 9,651 Reputation points
    2021-04-21T06:45:11.51+00:00

    Hi JosephBoban-8202,
    The windows-forms tag is discussing and asking questions about the Windows Forms such as Winforms controls, libraries, samples, publication and installation.
    The supported products are listed over here (more to be added later on).
    For questions about vb script, I suggest you ask the question on the VBScrip tag under stack overflow and you can get more professional answer.
    Thank you for your understanding.
    Best Regards,
    Daniel Zhang


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.