Jump to content

WIN7 - cscript works from command line but not from autoit script


Recommended Posts

OK, I've been wrestling with this for a while. I have a printer install script (that installs a printer to a given set of remote machines) that works great from an XP machine, but I cannot get it to work from a Windows 7 machine (to an XP).

I've started breaking it down bit by bit and, for the life of me, cannot figure out why it won't work. If I run the csript command from Windows command line, it adds the port to the remote xp machine fine, but if I try to run it from Autoit, it seems to run, but the port does not get added.

Can someone modify and test this first bit of code from a win7 machine and tell me if you can get it working?

$mkport = "cscript /nologo %windir%\System32\Printing_Admin_Scripts\en-US\prnport.vbs -a -s yourRemoteComputer -r yourtestport -h yourtestport -o raw -n 9100"
RunAs(YOURADMIN,  @ComputerName, YOURPASSWORD, 0, $mkport, '', @sw_hide)

I've tried adding #requireAdmin and #AutoIt3Wrapper_Res_File_Add=#AutoIt3Wrapper_Res_File_Add=#AutoIt3Wrapper_Res_RequestedExecutionLevel=RequireAdministrator with no luck.

ANyone else able to get thses typoe of scripts working from Win7. Is it a permissions issue with the way Win7 (and Vista) handle elevated rights? I'm just out of ideas

Link to comment
Share on other sites

I did. Forgot to mention that. I tried it this way:

$mkport = @Comspec & "/c cscript /nologo %windir%\System32\Printing_Admin_Scripts\en-US\prnport.vbs -a -s yourRemoteComputer -r yourtestport -h yourtestport -o raw -n 9100"
RunAs(YOURADMIN, @ComputerName, YOURPASSWORD, 0, $mkport, '', @sw_hide)

Doesn't work either. Thanks for the quick response, though.

Link to comment
Share on other sites

No need of @comspec : this for INTERNAL command line programs of windows.

Don't set the flag @SW_HIDE, it makes the command line software don't work on launch.

Delete this and use a GUICtrlSetState("Name of your window", "", @SW_HIDE)

After executing you software.

It'll show the window about a half second but it's the only workaround I found to get it to work.

I just added the issue: hope the devs will fix it.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...