• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Execute a system command in windows environment as administrator

Participant ,
Jul 14, 2017 Jul 14, 2017

Copy link to clipboard

Copied

Hi All,

Is there a way to execute system commands using the C:/windows/system32/cmd.exe from panels?

We tried the CEP HTML test Extension-> Create Process options, but cannot figure out how it is working

When we try to run the commands under set StdErr Handler but that is always creating ".exe Argument1" folder in the document folder.

How can we execute system commands in windows environment?

How can we run certain commands/ programme  as a specific user?

Thanks and Regards,

Anoop NR

TOPICS
SDK

Views

2.7K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Engaged , Jul 18, 2017 Jul 18, 2017

Hi Anoop,

the trouble is you only need elevated privileges to create a symlink because these can traverse partitions / logical volumes. You wouldn't have that problem with a hard link or junction because they're bound to a partition / logical volume.

The clean solution is to advise admins to enable symbolic link creation for the respective user, see here, or here.

People need to be aware of what changes have been applied on a system, it's bad pratice to do this in disguise.

Votes

Translate

Translate
Engaged ,
Jul 14, 2017 Jul 14, 2017

Copy link to clipboard

Copied

Hi Anoop,

basically cep.create.process works like:

var myProc = window.cep.process.createProcess('C:\\Windows\\SysWOW64\\ping.exe','www.adobe.com','-4'); // max. 2 parameters

if ( 0 == myProc.err ) {

var myProcPID = myProc.data;

var myProcStdout = window.cep.process.stdout(myProcPID, function(output){

    // do stuff with output

    });

} else {

    alert ("error:" + myProc.err);

}

Now, trying to run any shell command as a different user (especially with elevated privileges) is a very bad idea. It requires the system admin to reveal privileged information which is a no-no, especially because you will have to hard-code it (or have someone type it in).

The problem you're trying to solve will need a different approach.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 14, 2017 Jul 14, 2017

Copy link to clipboard

Copied

Hi e.d,

Thank you for your immediate response.

We will not be able to run the system commands using the createProcess command right?

createProcess("C:\\windows\\system32\\cmd.exe",mkdir,"E:\\testfolder") -> will not work

We tried with the node framework,

var process=require('child_process');

var result=process.exexSync(cmd.exe /c mkdir E:\testf)->working fine

From command prompt we can execute this script as an administrator by,

runas /user:administrator "cmd /c mkdir E:\testfolder"-> we need to give the password in command prompt itself
But not able to perform the same using process.exexSync()

This is what made us again go back to createProcess()

It will be grate if you can suggest some workaround/ running a bat file with admin privilege

Thanks and regards,

Anoop NR

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jul 14, 2017 Jul 14, 2017

Copy link to clipboard

Copied

Hi Anoop,

I wonder why you're not using Folder.create() in JSX, or window.cep.fs.makeDir(), if creating folders is all that's needed...

and also why creating a folder on an arbitrary non-system disk should require admin privileges?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 18, 2017 Jul 18, 2017

Copy link to clipboard

Copied

Hi ed,

mkdir was just an example, actually we are trying to create a softlink using mklink command, mklink needs admin privilege in windows.

Thanks and Regards,

Anoop NR

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jul 18, 2017 Jul 18, 2017

Copy link to clipboard

Copied

LATEST

Hi Anoop,

the trouble is you only need elevated privileges to create a symlink because these can traverse partitions / logical volumes. You wouldn't have that problem with a hard link or junction because they're bound to a partition / logical volume.

The clean solution is to advise admins to enable symbolic link creation for the respective user, see here, or here.

People need to be aware of what changes have been applied on a system, it's bad pratice to do this in disguise.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Jul 17, 2017 Jul 17, 2017

Copy link to clipboard

Copied

mkdir works fine using createProcess(): search this web page for 'mkdir'.


https://medium.com/html5-css3/23357c99c774

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 18, 2017 Jul 18, 2017

Copy link to clipboard

Copied

Hi Bruce,

We have tested this functionality.

//create folder /tmp

var result = window.cep.process.createProcess(‘/bin/mkdir’,’/tmp');

mkdir works fine in MAC;

But how we run the same/any other system command in Windows environment using createProcess?

This is the sample code we used for windows

cep.process.createProcess('C:\\windows\\system32\\cmd.exe', 'mkdir','E:\\testfolder');

Thanks and Regards,

Anoop NR

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines