Page 1 of 1

CMD auth in VB script -- permission problem

Posted: 2021-Jul-25, 8:23 am
by MigrationUser
26 Oct 2014 23:22
chouse


Hello,

I have a script like:

Code: Select all

Option Explicit
Dim objShell

Set objShell = WScript.CreateObject ("WScript.shell")
objShell.run "cmd /K CD C:\ & Dir"
Set objShell = Nothing
When I am logged on as Admin, this script runs fine from the prompt on local (test machine) as well as on remote server (production server).
It also works fine when I use the browser (web server) on local machine.

Problem is that it does NOT work on remote server when I use the browser. I think it is the user account which executes the command and I am looking for a solution which allows the browser account to run this command.

Thanks
Ken

----------------------------

#2 27 Oct 2014 06:11
foxidrive


Re: CMD auth in VB script -- permission problem

What error do you see on the screen?

----------------------------

#3 28 Oct 2014 04:16
chouse


Re: CMD auth in VB script -- permission problem

The error message that I get depends on objShell.RUN "xxxxxxxxx" command line which I try to run. For example, if I run a BCP command (MS SQL) I see no error message AND no result (appears as totally ignored command) or rarely, there the message is error 28000 (failed authentication user+password info).

As I mentioned the account which invokes the Shell / CMD is important and the browser account does not have that authority to perform (Windows 7). The same command (plus same SQL user+password) performs perfect when I connect as Administrator and start CMD manually.

Thanks,
Ken

----------------------------

#4 29 Dec 2014 10:56
tomjery

Code: Select all

Dim objWMIService, colProcessList
  Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
  Set colProcessList = objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'outlook.exe'")
original thread: https://ss64.org/oldforum/viewtopic.php?id=1933