The task is to run a batch file to register the DLL, everything works on the computer under the administrator. But if you run on another computer under the user writes "Invalid folder name"

Created account specifically for these needs with admin rights

Process pr = new Process(); pr.StartInfo.UseShellExecute = false; pr.StartInfo.FileName = @"C:\Users\" + userName + @"\Documents\DLL2.bat"; pr.StartInfo.Verb = "runas"; pr.StartInfo.UserName = "admin"; pr.StartInfo.Domain = "os"; pr.StartInfo.Password = "password"; pr.Start(); 

I tried to run and so "C: \ DLL2.bat" - the error is the same.

  • "Invalid folder name". The path to the folder was checked, does it exist exactly like that? No gaps in the way? Does non-system folders work? - Kromster
  • I tried to run and so "C: \ DLL2.bat"; Error is the same - Eugene
  • Added to the question. The part with the password was removed - it is an extra question for the question. - Kromster
  • If you run the batch file is not vlob, but through cmd /c "C:\Users\userName\Documents\DLL2.bat" - the same garbage? And what exactly is written in a batch file? maybe some of the lines of the batch file results in the specified error? - Akina
  • C: \ Windows \ SysWOW64 \ regsvr32 "C: \ Program Files (x86) \ 1cv8 \ 8.3.10.2699 \ bin \ comcntr.dll" / u C: \ Windows \ SysWOW64 \ regsvr32 "C: \ Program Files (x86) \ 1cv8 \ 8.3.12.1685 \ bin \ comcntr.dll "This is written in a batch file - Eugene

1 answer 1

Added a line and the problem disappeared

pr.StartInfo.WorkingDirectory = Path.GetDirectoryName (@ "C: \ Windows \ System32 \ cmd.exe");